| | |
| | | package com.xiaopeng.operation.controller; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.DesensitizedUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.xiaopeng.api.feignClient.account.SysGroupMenuClient; |
| | | import com.xiaopeng.api.model.account.SysUser; |
| | | import com.xiaopeng.api.model.operation.XpTargetedService; |
| | | import com.xiaopeng.api.model.operation.XpTargetedServiceVehicle; |
| | | import com.xiaopeng.api.model.operation.XpWhitelist; |
| | | import com.xiaopeng.api.query.operation.XpTargetedServiceQuery; |
| | | import com.xiaopeng.api.vo.account.LoginUser; |
| | | import com.xiaopeng.api.vo.operation.XpTargetedServiceVehicleVo; |
| | | import com.xiaopeng.api.vo.operation.XpTargetedServiceVo; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.utils.bean.BeanUtils; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.common.log.annotation.AdminOperationLog; |
| | | import com.xiaopeng.common.log.enums.AdminBusinessType; |
| | | import com.xiaopeng.common.log.enums.AdminOperationType; |
| | | import com.xiaopeng.common.security.service.TokenService; |
| | | import com.xiaopeng.operation.dto.WhitelistAddDto; |
| | | import com.xiaopeng.operation.dto.WhitelistEditDto; |
| | | import com.xiaopeng.operation.query.WhitelistPageListQuery; |
| | | import com.xiaopeng.operation.service.XpTargetedServiceService; |
| | | import com.xiaopeng.operation.service.XpTargetedServiceVehicleService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | public class XpTargetedServiceController { |
| | | |
| | | @Resource |
| | | XpTargetedServiceService xpTargetedServiceService; |
| | | private XpTargetedServiceService xpTargetedServiceService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private SysGroupMenuClient groupMenuClient; |
| | | @Resource |
| | | private XpTargetedServiceVehicleService xpTargetedServiceVehicleService; |
| | | |
| | | |
| | | @ApiOperation(value = "定向服务分页", tags = {"管理后台-定向服务分页"}) |
| | |
| | | PageInfo<XpTargetedServiceVo> pageList = xpTargetedServiceService.pageList(query); |
| | | return R.ok(pageList); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "定向服务-详情", tags = {"管理后台-定向服务详情"}) |
| | | @GetMapping("/api/v1/targetedService/detail") |
| | | public R<XpTargetedServiceVo> detail(@RequestParam Long id) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (id == null) { |
| | | return R.fail("ID不能为空"); |
| | | } |
| | |
| | | if (vo == null) { |
| | | return R.fail("数据不存在"); |
| | | } |
| | | if(!loginUser.getPhoneDesensitizationExempt()){ |
| | | vo.getWhitelistList().forEach(s->s.setAccount(DesensitizedUtil.mobilePhone(s.getAccount()))); |
| | | } |
| | | |
| | | return R.ok(vo); |
| | | } |
| | | |
| | |
| | | */ |
| | | @PostMapping("/api/v1/targetedService/add") |
| | | @ApiOperation(value = "定向服务-添加", tags = {"管理后台-定向服务添加"}) |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.TARGETED_SERVICE, |
| | | operationType = AdminOperationType.ADD, |
| | | content = "新增定向服务", |
| | | appendRequestData = true |
| | | ) |
| | | public R add(@Validated @RequestBody XpTargetedServiceVo dto) { |
| | | SysUser sysUser = tokenService.getLoginUser().getSysUser(); |
| | | xpTargetedServiceService.add(dto, sysUser); |
| | |
| | | */ |
| | | @PostMapping("/api/v1/targetedService/edit") |
| | | @ApiOperation(value = "定向服务-修改", tags = {"管理后台-定向服务修改"}) |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.TARGETED_SERVICE, |
| | | operationType = AdminOperationType.EDIT, |
| | | content = "编辑定向服务", |
| | | appendRequestData = true |
| | | ) |
| | | public R edit(@Validated @RequestBody XpTargetedServiceVo dto) { |
| | | if(dto.getId() == null){ |
| | | return R.fail("ID不能为空"); |
| | |
| | | */ |
| | | @PostMapping("/api/v1/targetedService/updateStatus") |
| | | @ApiOperation(value = "定向服务-修改状态", tags = {"管理后台-定向服务修改状态"}) |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.TARGETED_SERVICE, |
| | | operationTypeExpression = "#p1 == 1 ? T(com.xiaopeng.common.log.enums.AdminOperationType).ENABLE : T(com.xiaopeng.common.log.enums.AdminOperationType).DISABLE", |
| | | contentExpression = "(#p1 == 1 ? '启用定向服务,id=' : '禁用定向服务,id=') + #p0", |
| | | appendRequestData = false |
| | | ) |
| | | public R updateStatus(@RequestParam Long id, @RequestParam Integer status) { |
| | | if (id == null) { |
| | | return R.fail("ID不能为空"); |
| | |
| | | /** |
| | | * 批量删除 |
| | | */ |
| | | @GetMapping("/api/v1/targetedService/deleteByIds") |
| | | @PostMapping("/api/v1/targetedService/deleteByIds") |
| | | @ApiOperation(value = "定向服务-批量删除", tags = {"管理后台-定向服务批量删除"}) |
| | | public R deleteByIds(String ids) { |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.TARGETED_SERVICE, |
| | | operationType = AdminOperationType.DELETE, |
| | | contentExpression = "'批量删除定向服务,ids=' + #p0.ids", |
| | | appendRequestData = false |
| | | ) |
| | | public R deleteByIds(@RequestBody XpTargetedServiceQuery query ) { |
| | | if(CollUtil.isEmpty(query.getIds())){ |
| | | return R.fail("ID列表不能为空"); |
| | | } |
| | | SysUser sysUser = tokenService.getLoginUser().getSysUser(); |
| | | List<Long> whiteIds = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList()); |
| | | return xpTargetedServiceService.deleteByIds(whiteIds, sysUser); |
| | | return xpTargetedServiceService.deleteByIds(query.getIds(), sysUser); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户ID和城市编码获取 |
| | | * @param appUserId 用户ID |
| | | * @param cityCode 城市编码 |
| | | * @return |
| | | */ |
| | | @GetMapping("/logan/inner/v1/targetedService/findListByUserIdAndCityCode") |
| | | public R<List<XpTargetedServiceVehicleVo>> findListByUserIdAndCityCode(@RequestParam Long appUserId, @RequestParam String cityCode){ |
| | | return R.ok(xpTargetedServiceService.findListByUserIdAndCityCode(appUserId,cityCode)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取定向服务权限 |
| | | * @param appUserId |
| | | * @param cityCode |
| | | * @return |
| | | */ |
| | | @GetMapping("/logan/inner/v1/targetedService/getTargetedServiceWeight") |
| | | public R<Integer> getTargetedServiceWeight(@RequestParam("appUserId") Long appUserId, @RequestParam("cityCode") String cityCode){ |
| | | Integer targetedServiceWeight = xpTargetedServiceService.getTargetedServiceWeight(appUserId, cityCode); |
| | | return R.ok(targetedServiceWeight); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取定向服务所有车辆 |
| | | * @return |
| | | */ |
| | | @GetMapping("/logan/inner/v1/targetedService/getAllTargetedServiceVehicle") |
| | | public R<List<Long>> getAllTargetedServiceVehicle(){ |
| | | List<XpTargetedService> targetedServices = xpTargetedServiceService.list(null); |
| | | List<XpTargetedServiceVehicle> list = xpTargetedServiceVehicleService.list(new LambdaQueryWrapper<XpTargetedServiceVehicle>().in(XpTargetedServiceVehicle::getTargetedServiceId, targetedServices.stream() |
| | | .map(XpTargetedService::getId).collect(Collectors.toList()))); |
| | | return R.ok(list.stream().map(XpTargetedServiceVehicle::getVehicleId).collect(Collectors.toList())); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取定向服务所有车辆 |
| | | * @return |
| | | */ |
| | | @GetMapping("/logan/inner/v1/targetedService/getAllTargetedServiceVehicleByCityCode") |
| | | public R<List<XpTargetedServiceVehicle>> getAllTargetedServiceVehicleByCityCode(@RequestParam("cityCode") String cityCode){ |
| | | List<XpTargetedService> targetedServices = xpTargetedServiceService.list(new LambdaQueryWrapper<XpTargetedService>() |
| | | .eq(XpTargetedService::getCityCode, cityCode).eq(XpTargetedService::getStatus, 1)); |
| | | List<XpTargetedServiceVehicle> list = xpTargetedServiceVehicleService.list(new LambdaQueryWrapper<XpTargetedServiceVehicle>().in(XpTargetedServiceVehicle::getTargetedServiceId, targetedServices.stream() |
| | | .map(XpTargetedService::getId).collect(Collectors.toList()))); |
| | | return R.ok(list); |
| | | } |
| | | } |