mitao
2024-09-04 ecca9ab70a9a87bcb60977c92fbf81053b8fc1bb
ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/RecoveryServeController.java
@@ -12,6 +12,7 @@
import com.ruoyi.admin.service.RecoveryServePriceService;
import com.ruoyi.admin.service.RecoveryServeService;
import com.ruoyi.admin.vo.RecoveryServeResultVO;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.annotation.RequiresPermissions;
@@ -57,18 +58,18 @@
    @ApiOperation(value = "回收服务分页查询列表", tags = {"后台-回收管理-回收服务管理"})
    @GetMapping(value = "/page")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "服务名称", name = "serverName", dataType = "String"),
            @ApiImplicitParam(value = "服务名称", name = "serveName", dataType = "String"),
            @ApiImplicitParam(value = "回收价格起点", name = "startPrice", dataType = "String"),
            @ApiImplicitParam(value = "回收价格终点", name = "endPrice", dataType = "String"),
            @ApiImplicitParam(value = "页码", name = "pageNum", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "每页条数", name = "pageSize", dataType = "Integer", required = true)
    })
    public R<IPage<RecoveryServe>> queryPageList(String serverName, String startPrice, String endPrice,
    public R<IPage<RecoveryServe>> queryPageList(String serveName, String startPrice, String endPrice,
                                                 @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        LambdaQueryChainWrapper<RecoveryServe> wrapper = recoveryServeService.lambdaQuery();
        // 服务名称模糊匹配
        wrapper = StringUtils.isNotBlank(serverName) ? wrapper.like(RecoveryServe::getServeName, serverName) : wrapper;
        wrapper = StringUtils.isNotBlank(serveName) ? wrapper.like(RecoveryServe::getServeName, serveName) : wrapper;
        // 回收价格区间匹配
        wrapper = null != startPrice ? wrapper.ge(RecoveryServe::getDefaultPrice, startPrice) : wrapper;
        wrapper = null != endPrice ? wrapper.le(RecoveryServe::getDefaultPrice, endPrice) : wrapper;
@@ -95,7 +96,9 @@
    @GetMapping(value = "/typeList")
    public R<List<RecoveryClassify>> typeList() {
        return R.ok(recoveryClassifyService.lambdaQuery()
                .orderByDesc(RecoveryClassify::getCreateTime).list());
                .eq(RecoveryClassify::getIsDelete, 0)
                .orderByDesc(RecoveryClassify::getCreateTime)
                .list());
    }
    /**
@@ -103,7 +106,7 @@
     *
     * @param id 回收服务id
     */
    @RequiresPermissions("serve_recycling_list")
    @RequiresPermissions("serve_detail")
    @ApiOperation(value = "回收服务详情", tags = {"后台-回收管理-回收服务管理"})
    @GetMapping(value = "/detail")
    @ApiImplicitParams({
@@ -122,7 +125,7 @@
     *
     * @param recoveryServeRequest 回收服务信息
     */
    @RequiresPermissions("serve_recycling_list")
    @RequiresPermissions("serve_save")
    @ApiOperation(value = "新增回收服务", tags = {"后台-回收管理-回收服务管理"})
    @PostMapping(value = "/save")
    public R<String> save(@RequestBody RecoveryServeRequest recoveryServeRequest) {
@@ -138,6 +141,7 @@
                price.setRecoveryServeId(serve.getId());
                price.setRecoveryPrice(recoveryPrice);
                price.setCity(city);
                price.setCityCode(data.getCityCode());
                save = save && recoveryServePriceService.save(price);
            }
        }
@@ -149,7 +153,7 @@
     *
     * @param recoveryServeRequest 回收服务信息
     */
    @RequiresPermissions("serve_recycling_list")
    @RequiresPermissions("serve_update")
    @ApiOperation(value = "修改回收服务", tags = {"后台-回收管理-回收服务管理"})
    @PostMapping(value = "/update")
    public R<String> update(@RequestBody RecoveryServeRequest recoveryServeRequest) {
@@ -157,10 +161,15 @@
        serve.setId(recoveryServeRequest.getId());
        boolean update = recoveryServeService.updateById(serve);
        // 城市及对应回收价
        update = update && recoveryServePriceService.lambdaUpdate()
                .set(RecoveryServePrice::getIsDelete, 1)
        List<RecoveryServePrice> priceList = recoveryServePriceService.lambdaQuery()
                .eq(RecoveryServePrice::getRecoveryServeId, recoveryServeRequest.getId())
                .update();
                .eq(RecoveryServePrice::getIsDelete, 0).list();
        if (!priceList.isEmpty()) {
            for (RecoveryServePrice price : priceList) {
                price.setIsDelete(Constants.ONE);
            }
            update = update && recoveryServePriceService.updateBatchById(priceList);
        }
        // 新增省市及回收价
        if (null != recoveryServeRequest.getPriceList()) {
            for (RecoveryServePriceRequest data : recoveryServeRequest.getPriceList()) {
@@ -171,6 +180,7 @@
                price.setRecoveryServeId(serve.getId());
                price.setRecoveryPrice(recoveryPrice);
                price.setCity(city);
                price.setCityCode(data.getCityCode());
                update = update && recoveryServePriceService.save(price);
            }
        }
@@ -182,7 +192,7 @@
     *
     * @param ids 回收服务多条id拼接
     */
    @RequiresPermissions("serve_recycling_list")
    @RequiresPermissions("serve_delete")
    @ApiOperation(value = "批量删除回收服务", tags = {"后台-回收管理-回收服务管理"})
    @GetMapping(value = "/batchDelete")
    @ApiImplicitParams({
@@ -192,6 +202,9 @@
        List<String> idList = Arrays.stream(ids.split(",")).collect(Collectors.toList());
        List<RecoveryServe> list = recoveryServeService.lambdaQuery().in(RecoveryServe::getId, idList).list();
        list.forEach(data -> data.setIsDelete(1));
        recoveryServePriceService.lambdaUpdate()
                .set(RecoveryServePrice::getIsDelete, Constants.ONE)
                .in(RecoveryServePrice::getRecoveryServeId, idList).update();
        return recoveryServeService.updateBatchById(list) ? R.ok() : R.fail();
    }