| | |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.model.TSysAppUser; |
| | | import com.ruoyi.system.model.TSysInspection; |
| | | import com.ruoyi.system.model.TSysOtherConfig; |
| | | import com.ruoyi.system.query.TSysInspectionQuery; |
| | | import com.ruoyi.system.service.TSysAppUserService; |
| | | import com.ruoyi.system.service.TSysInspectionService; |
| | | import com.ruoyi.system.service.TSysOtherConfigService; |
| | | import com.ruoyi.system.utils.util.AIUtil; |
| | | import com.ruoyi.system.vo.TSysInspectionVO; |
| | | import io.swagger.annotations.Api; |
| | |
| | | private final TSysInspectionService sysInspectionService; |
| | | private final TokenService tokenService; |
| | | private final TSysAppUserService sysAppUserService; |
| | | private final TSysOtherConfigService sysOtherConfigService; |
| | | private final AIUtil aiUtil; |
| | | private final RedisCache redisCache; |
| | | @Autowired |
| | | public TSysInspectionController(TSysInspectionService sysInspectionService, TokenService tokenService, TSysAppUserService sysAppUserService, AIUtil aiUtil, RedisCache redisCache) { |
| | | public TSysInspectionController(TSysInspectionService sysInspectionService, TokenService tokenService, TSysAppUserService sysAppUserService, TSysOtherConfigService sysOtherConfigService, AIUtil aiUtil, RedisCache redisCache) { |
| | | this.sysInspectionService = sysInspectionService; |
| | | this.tokenService = tokenService; |
| | | this.sysAppUserService = sysAppUserService; |
| | | this.sysOtherConfigService = sysOtherConfigService; |
| | | this.aiUtil = aiUtil; |
| | | this.redisCache = redisCache; |
| | | } |
| | |
| | | @ApiOperation(value = "查看用户检测信息管理详情") |
| | | @GetMapping(value = "/getDetailById") |
| | | public R<TSysInspection> getDetailById(@RequestParam String id) { |
| | | return R.ok(sysInspectionService.getById(id)); |
| | | // 查询用户信息 |
| | | String userId = tokenService.getLoginUserApplet().getUserId(); |
| | | TSysAppUser sysAppUser = sysAppUserService.getById(userId); |
| | | // 匹配免费次数 |
| | | TSysOtherConfig sysOtherConfig = sysOtherConfigService.getById(1); |
| | | TSysInspection sysInspection = sysInspectionService.getById(id); |
| | | if(sysInspection.getIsPay() == 0 && sysInspection.getInspectionType() == 2){ |
| | | // 匹配免费次数 |
| | | if(Objects.equals(sysAppUser.getUseAiFreeCount(), sysOtherConfig.getAiFreeCount())){ |
| | | return R.fail("您已使用完免费次数"); |
| | | } |
| | | // 检测免费次数 |
| | | sysAppUser.setUseAiFreeCount(sysAppUser.getUseAiFreeCount() + 1); |
| | | sysAppUserService.updateById(sysAppUser); |
| | | sysInspection.setIsPay(1); |
| | | sysInspectionService.updateById(sysInspection); |
| | | } |
| | | return R.ok(sysInspection); |
| | | } |
| | | |
| | | /** |