无关风月
2024-09-03 85c4410b0948799a93f19f345b4ed18c253c89f3
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java
@@ -11,15 +11,18 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.chargingPile.api.dto.ApplyChargingQuery;
import com.ruoyi.chargingPile.api.dto.ApplyChargingRemarkDto;
import com.ruoyi.chargingPile.api.dto.TApplyChargingPileDTO;
import com.ruoyi.chargingPile.api.model.TApplyChargingPile;
import com.ruoyi.chargingPile.dto.TApplyChargingPileExportDto;
import com.ruoyi.chargingPile.service.TApplyChargingPileService;
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.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.log.enums.OperatorType;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.service.TokenService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.codec.CharEncoding;
@@ -51,11 +54,13 @@
    private final TApplyChargingPileService applyChargingPileService;
    private final TokenService tokenService;
    private final RedisService redisService;
    @Autowired
    public TApplyChargingPileController(TApplyChargingPileService applyChargingPileService, TokenService tokenService) {
    public TApplyChargingPileController(TApplyChargingPileService applyChargingPileService, TokenService tokenService, RedisService redisService) {
        this.applyChargingPileService = applyChargingPileService;
        this.tokenService = tokenService;
        this.redisService = redisService;
    }
    /**
@@ -64,7 +69,15 @@
    @Log(title = "建桩申请", businessType = BusinessType.INSERT,operatorType = OperatorType.MOBILE)
    @ApiOperation(tags = {"小程序-建桩申请"},value = "建桩申请")
    @PostMapping(value = "/add")
    public AjaxResult<Boolean> add(@RequestBody TApplyChargingPile dto) {
    public AjaxResult<Boolean> add(@RequestBody TApplyChargingPileDTO dto) {
        // 验证验证码
        String code = redisService.getCacheObject(dto.getLandlordPhone() + Constants.APPLY_CHARGING);
        if(StringUtils.isEmpty(code)){
            return AjaxResult.error("验证码已过期,请重新获取验证码!");
        }
        if(!code.equals(dto.getCode())){
            return AjaxResult.error("验证码错误!");
        }
        // 用户id
        Long userId = tokenService.getLoginUserApplet().getUserId();
        dto.setAppUserId(userId);
@@ -91,7 +104,7 @@
    @ApiOperation(tags = {"后台-申请表单-申请建桩"},value = "导出")
    @PutMapping(value = "/export")
    public R export(HttpServletResponse response) {
    public R export(String landlordPhone,HttpServletResponse response) {
        try {
        response.setCharacterEncoding(Constants.UTF8);
        response.setContentType("application/vnd.ms-excel");
@@ -102,7 +115,7 @@
            return R.fail("excel导出失败!");
        }
        try {
            List<TApplyChargingPile> list = applyChargingPileService.lambdaQuery().last("limit 1").list();
            List<TApplyChargingPile> list = applyChargingPileService.lambdaQuery().like(landlordPhone != null && !landlordPhone.equals(""), TApplyChargingPile::getLandlordPhone, landlordPhone).list();
            List<TApplyChargingPileExportDto> exportDtos =new ArrayList<>();
            for (TApplyChargingPile tApplyChargingPile : list) {