无关风月
2025-04-23 ccbfaf4700422eda488f5807ee9a0f3ce3a94b2c
ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/RecoveryServeController.java
@@ -10,9 +10,12 @@
import com.ruoyi.user.entity.RecoveryClassify;
import com.ruoyi.user.entity.RecoveryServe;
import com.ruoyi.user.entity.UserCollect;
import com.ruoyi.user.entity.UserRecipient;
import com.ruoyi.user.service.RecoveryClassifyService;
import com.ruoyi.user.service.RecoveryServeService;
import com.ruoyi.user.service.UserCollectService;
import com.ruoyi.user.service.UserRecipientService;
import com.ruoyi.user.vo.ServeDetailVO;
import com.ruoyi.user.vo.ServeListVO;
import com.ruoyi.user.vo.UserServeTypeVO;
import io.swagger.annotations.Api;
@@ -49,6 +52,8 @@
    private UserCollectService collectService;
    @Resource
    private TokenService tokenService;
    @Resource
    private UserRecipientService userRecipientService;
    /**
     * 获取服务列表
@@ -83,13 +88,13 @@
     */
    @GetMapping(value = "/servePage")
    @ApiOperation(value = "根据所选分类获取服务列表", tags = {"用户端-服务"})
    public R<IPage<RecoveryServe>> servePage(@RequestParam("id") Integer id,
    public R<IPage<RecoveryServe>> servePage(@RequestParam("id") String id,
                                             @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
                                             @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        Page<RecoveryServe> page = recoveryServeService.lambdaQuery()
                .eq(RecoveryServe::getClassifyId, id)
                .eq(RecoveryServe::getIsDelete, 0)
                .orderByAsc(RecoveryServe::getSort)
                .orderByDesc(RecoveryServe::getSort)
                .orderByDesc(RecoveryServe::getCreateTime).page(Page.of(pageNum, pageSize));
        return R.ok(page);
    }
@@ -109,14 +114,34 @@
    @GetMapping(value = "/serveDetail")
    @ApiOperation(value = "获取服务详情", tags = {"用户端-服务"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "服务id", name = "serveId", dataType = "Integer", required = true)
            @ApiImplicitParam(value = "服务id", name = "serveId", dataType = "String", required = true)
    })
    public R<RecoveryServe> serveDetail(@RequestParam Integer serveId) {
    public R<ServeDetailVO> serveDetail(@RequestParam String serveId) {
        LoginUserInfo loginUser = tokenService.getLoginUserByUser();
        if (null == loginUser) {
            RecoveryServe recoveryServe = recoveryServeService.lambdaQuery().eq(RecoveryServe::getId, serveId)
                    .eq(RecoveryServe::getIsDelete, 0).one();
                recoveryServe.setIsCollect(Boolean.FALSE);
            // 获取服务分类
            Integer classifyId = recoveryServe.getClassifyId();
            RecoveryClassify classify = recoveryClassifyService.lambdaQuery()
                    .eq(RecoveryClassify::getId, classifyId).one();
            if (classify.getSupClassify().equals(Constants.TRADE_IN)) {
                recoveryServe.setType(Constants.ZERO);
            } else {
                recoveryServe.setType(Constants.ONE);
            }
            return R.ok(new ServeDetailVO(recoveryServe, null));
        }
        RecoveryServe recoveryServe = recoveryServeService.lambdaQuery().eq(RecoveryServe::getId, serveId)
                .eq(RecoveryServe::getIsDelete, 0).orderByAsc(RecoveryServe::getSort).one();
                .eq(RecoveryServe::getIsDelete, 0).one();
        // 用户是否收藏
        UserCollect one = collectService.lambdaQuery()
                .eq(UserCollect::getServeId, serveId)
                .eq(UserCollect::getUserId, loginUser.getUserid())
                .eq(UserCollect::getIsDelete, 0).one();
        if (null != one) {
            recoveryServe.setIsCollect(Boolean.TRUE);
@@ -126,14 +151,20 @@
        // 获取服务分类
        Integer classifyId = recoveryServe.getClassifyId();
        RecoveryClassify classify = recoveryClassifyService.lambdaQuery()
                .eq(RecoveryClassify::getId, classifyId)
                .eq(RecoveryClassify::getIsDelete, 0).one();
                .eq(RecoveryClassify::getId, classifyId).one();
        if (classify.getSupClassify().equals(Constants.TRADE_IN)) {
            recoveryServe.setType(Constants.ZERO);
        } else {
            recoveryServe.setType(Constants.ONE);
        }
        return R.ok(recoveryServe);
        // 获取用户默认收货地址
        UserRecipient userRecipient = userRecipientService.lambdaQuery()
                .eq(UserRecipient::getIsDefault, Constants.ONE)
                .eq(UserRecipient::getUserId, loginUser.getUserid())
                .eq(UserRecipient::getIsDelete, Constants.ZERO)
                .last("limit 1")
                .one();
        return R.ok(new ServeDetailVO(recoveryServe, userRecipient));
    }
    /**