| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | @Resource |
| | | private XpOpenCityService xpOpenCityService; |
| | | |
| | | /** |
| | | * 分页查询路线规划配置列表 |
| | | */ |
| | |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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(); |
| | | } |
| | |
| | | // 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(); |
| | | } |