package com.ruoyi.admin.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.admin.entity.User; import com.ruoyi.admin.service.UserService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.security.annotation.Logical; import com.ruoyi.common.security.annotation.RequiresPermissions; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.api.entity.Evaluate; import com.ruoyi.order.api.entity.EvaluatePageVO; import com.ruoyi.order.api.feignClient.EvaluateClient; import com.ruoyi.order.api.request.EvaluatePageRequest; import com.ruoyi.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** *

* 用户评价表 前端控制器 *

* * @author hjl * @since 2024-05-29 */ @RestController @RequestMapping("/evaluate") @Api(tags = {"后台-系统设置-订单评价管理"}) public class EvaluateController { @Resource private EvaluateClient evaluateClient; @Resource private TokenService tokenService; @Resource private UserService userService; /** * 订单评价分页列表 * * @param pageNum 页码 * @param pageSize 每页显示条数 */ @RequiresPermissions(value = {"user_detail", "order_evaluate"}, logical = Logical.OR) @ApiOperation(value = "订单评价分页查询列表", tags = {"后台-系统设置-订单评价管理"}) @GetMapping(value = "/page") @ApiImplicitParams({ @ApiImplicitParam(value = "评价用户", name = "userNo", dataType = "String"), @ApiImplicitParam(value = "订单编号", name = "orderNumber", dataType = "String"), @ApiImplicitParam(value = "师傅姓名", name = "workerName", dataType = "String"), @ApiImplicitParam(value = "页码", name = "pageNum", dataType = "Integer", required = true), @ApiImplicitParam(value = "每页条数", name = "pageSize", dataType = "Integer", required = true) }) public R> queryPageList(String userNo, String orderNumber, String workerName, @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { LoginUser loginUser = tokenService.getLoginUser(); if (null == loginUser) { return R.loginExpire("登录失效!"); } List cityList = new ArrayList<>(); if (loginUser.getIsFranchisee()) { cityList = loginUser.getCityList(); } List userList; if (StringUtils.isNotBlank(userNo)) { userList = userService.lambdaQuery().like(User::getNickname, userNo).list(); if (userList.isEmpty()){ Page page = new Page<>(); return R.ok(page); } } else { userList = new ArrayList<>(); } List userIdList = userList.stream().map(User::getId).collect(Collectors.toList()); EvaluatePageRequest evaluatePageRequest = new EvaluatePageRequest(); evaluatePageRequest.setUserNo(userNo); evaluatePageRequest.setOrderNumber(orderNumber); evaluatePageRequest.setWorkerName(workerName); evaluatePageRequest.setCityList(cityList); evaluatePageRequest.setPageNum(pageNum); evaluatePageRequest.setPageSize(pageSize); evaluatePageRequest.setUserIdList(userIdList); R> r = evaluateClient.queryPageList(evaluatePageRequest); if (!r.getData().getRecords().isEmpty()) { for (EvaluatePageVO record : r.getData().getRecords()) { Integer userId = record.getUserId(); User user = userService.getById(userId); if (null != user) { record.setUserNo(user.getNickname()); } } } return r; } /** * 订单评价详情 * * @param id 订单评价id */ @RequiresPermissions(value = {"user_detail", "evaluate_detail"}, logical = Logical.OR) @ApiOperation(value = "订单评价详情", tags = {"后台-系统设置-订单评价管理"}) @GetMapping(value = "/detail") @ApiImplicitParams({ @ApiImplicitParam(value = "订单评价id", name = "id", dataType = "Integer", required = true) }) public R detail(@RequestParam Integer id) { return evaluateClient.detail(id); } /** * 根据id批量删除订单评价 * * @param ids 订单评价多条id拼接 */ @RequiresPermissions(value = {"user_detail", "evaluate_delete"}, logical = Logical.OR) @ApiOperation(value = "批量删除订单评价", tags = {"后台-系统设置-订单评价管理"}) @GetMapping(value = "/batchDelete") @ApiImplicitParams({ @ApiImplicitParam(value = "多条订单评价id ',' 拼接", name = "ids", dataType = "String", required = true) }) public R batchDelete(@RequestParam String ids) { return evaluateClient.batchDelete(ids); } }