yyy
2026-04-22 43e9944347e51d5628166f8c1b78d98cfd2013ea
xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/controller/XpPasswordFreePolicyController.java
@@ -1,5 +1,6 @@
package com.xiaopeng.operation.controller;
import com.xiaopeng.api.model.operation.XpOpenCity;
import com.xiaopeng.api.model.operation.XpPasswordFreePolicy;
import com.xiaopeng.api.query.operation.XpPasswordFreePolicyQuery;
import com.xiaopeng.api.vo.account.LoginUser;
@@ -7,6 +8,7 @@
import com.xiaopeng.common.core.exception.ServiceException;
import com.xiaopeng.common.core.web.page.PageInfo;
import com.xiaopeng.common.security.service.TokenService;
import com.xiaopeng.operation.service.XpOpenCityService;
import com.xiaopeng.operation.service.XpPasswordFreePolicyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -30,6 +32,9 @@
    @Resource
    private TokenService tokenService;
    @Resource
    private  XpOpenCityService xpOpenCityService;
    /**
     * 分页查询路线规划配置列表
     */
@@ -38,6 +43,17 @@
    public R<PageInfo<XpPasswordFreePolicy>> pageList(@RequestBody XpPasswordFreePolicyQuery query) {
        PageInfo<XpPasswordFreePolicy> pageInfo = xpPasswordFreePolicyService.pageList(query);
        return R.ok(pageInfo);
    }
    /**
     * 分页查询路线规划配置列表
     */
    @ApiOperation(value = "免密支付策略详情接口", tags = {"管理后台-交易定价-免密支付策略"}, response = XpPasswordFreePolicy.class)
    @GetMapping("/api/v1/passwordFreePolicy/getById/{id}")
    public R<XpPasswordFreePolicy> getById(@PathVariable Long id) {
        XpPasswordFreePolicy bean = xpPasswordFreePolicyService.getById(id);
        return R.ok(bean);
    }
    /**
@@ -52,6 +68,17 @@
        dto.setCreateBy(loginUser.getUsername());
        dto.setCreateTime(LocalDateTime.now());
        XpOpenCity xpOpenCity = xpOpenCityService.getByCode(dto.getCityCode());
        if(xpOpenCity == null){
            return R.fail("开通城市不存在");
        }
        dto.setProvinceName(xpOpenCity.getProvinceName());
        dto.setProvinceCode(xpOpenCity.getProvinceCode());
        if(xpOpenCity.getCityCode() .equals(dto.getCityCode())){
            dto.setCityName(xpOpenCity.getCityName());
        }else if(xpOpenCity.getDistrictCode().equals(dto.getCityCode())){
            dto.setCityName(xpOpenCity.getDistrictName());
        }
        xpPasswordFreePolicyService.save(dto);
        return R.ok();
    }
@@ -65,12 +92,23 @@
        // 1. 查询原记录是否存在
        XpPasswordFreePolicy routePlan = xpPasswordFreePolicyService.getById(dto.getId());
        if (routePlan == null) {
            throw new ServiceException("数据不存在");
            return R.fail("数据不存在");
        }
        LoginUser loginUser = tokenService.getLoginUser();
        dto.setUpdateBy(loginUser.getUsername());
        dto.setUpdateTime(LocalDateTime.now());
        XpOpenCity xpOpenCity = xpOpenCityService.getByCode(dto.getCityCode());
        if(xpOpenCity == null){
            return R.fail("开通城市不存在");
        }
        dto.setProvinceName(xpOpenCity.getProvinceName());
        dto.setProvinceCode(xpOpenCity.getProvinceCode());
        if(xpOpenCity.getCityCode() .equals(dto.getCityCode())){
            dto.setCityName(xpOpenCity.getCityName());
        }else if(xpOpenCity.getDistrictCode().equals(dto.getCityCode())){
            dto.setCityName(xpOpenCity.getDistrictName());
        }
        xpPasswordFreePolicyService.updateById(dto);
        return R.ok();
    }