| | |
| | | package com.xiaopeng.account.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.xiaopeng.account.mapper.XpOperationsRoleMapper; |
| | | import com.xiaopeng.account.model.dto.EnableDisableDTO; |
| | | import com.xiaopeng.account.model.dto.RePasswordDTO; |
| | |
| | | import com.xiaopeng.account.model.dto.XpOperationsUserDTO; |
| | | import com.xiaopeng.account.model.query.XpOperationsUserPageQuery; |
| | | import com.xiaopeng.account.model.query.XpOperationsUserQuery; |
| | | import com.xiaopeng.account.service.IXpOperationsRoleService; |
| | | import com.xiaopeng.account.service.IXpOperationsUserService; |
| | | import com.xiaopeng.api.dto.account.XpOperationsUserQueryDTO; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetClient; |
| | | import com.xiaopeng.api.model.account.XpOperationsUser; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpFleet; |
| | | import com.xiaopeng.api.vo.account.XpOperationsUserProfileVO; |
| | | import com.xiaopeng.api.vo.account.XpOperationsUserVO; |
| | | import com.xiaopeng.api.vo.account.XpOperationsUserWithRoleVO; |
| | | import com.xiaopeng.common.core.exception.ServiceException; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.common.security.service.TokenService; |
| | | import com.xiaopeng.account.constant.I18nKeyConstant; |
| | | import com.xiaopeng.evi.oss.service.AliOssService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | |
| | | private final TokenService tokenService; |
| | | |
| | | private final XpFleetClient xpFleetClient; |
| | | |
| | | private final AliOssService aliOssService; |
| | | |
| | | @Autowired |
| | | public XpOperationsUserController(IXpOperationsUserService xpOperationsUserService, XpOperationsRoleMapper xpOperationsRoleMapper, TokenService tokenService) { |
| | | public XpOperationsUserController(IXpOperationsUserService xpOperationsUserService, |
| | | XpOperationsRoleMapper xpOperationsRoleMapper, |
| | | TokenService tokenService, |
| | | XpFleetClient xpFleetClient, AliOssService aliOssService) { |
| | | this.xpOperationsUserService = xpOperationsUserService; |
| | | this.xpOperationsRoleMapper = xpOperationsRoleMapper; |
| | | this.tokenService = tokenService; |
| | | this.xpFleetClient = xpFleetClient; |
| | | this.aliOssService = aliOssService; |
| | | } |
| | | |
| | | /** |
| | |
| | | PageInfo<XpOperationsUserVO> pageList = xpOperationsUserService.pageList(query); |
| | | return R.ok(pageList); |
| | | } |
| | | |
| | | @ApiOperation(value = "运维人员管理不分页列表", tags = {"管理后台-运维执行"}) |
| | | @PostMapping("/api/v1/operationsUser/listAll") |
| | | public R<List<XpOperationsUser>> listAll() { |
| | | List<XpOperationsUser> listAll = xpOperationsUserService.list(); |
| | | return R.ok(listAll); |
| | | } |
| | | |
| | | /** |
| | | * 获取所有启用状态的运维用户(内部接口) |
| | | * @return 启用状态的用户列表 |
| | | */ |
| | | @ApiOperation(value = "获取所有启用状态的运维用户", tags = {"内部接口"}) |
| | | @GetMapping("/inner/xpOperationsUser/listAllEnabled") |
| | | public R<List<XpOperationsUser>> listAllEnabled() { |
| | | List<XpOperationsUser> users = xpOperationsUserService.lambdaQuery() |
| | | .eq(XpOperationsUser::getStatus, true) |
| | | .list(); |
| | | return R.ok(users); |
| | | } |
| | | |
| | | @ApiOperation(value = "运维人员管理新增", tags = {"管理后台-运维执行"}) |
| | |
| | | @ApiOperation(value = "运维人员管理删除", tags = {"管理后台-运维执行"}) |
| | | @DeleteMapping("/api/v1/operationsUser/deleteById") |
| | | public R<String> deleteById(@RequestParam Long id) { |
| | | try { |
| | | R<XpFleet> fleetResult = xpFleetClient.getFleetByOperationsUserId(id); |
| | | if (fleetResult == null) { |
| | | throw new ServiceException("请求失败,请稍后重试", I18nKeyConstant.REQUEST_FAILED); |
| | | } |
| | | XpFleet fleet = fleetResult.getData(); |
| | | if (fleet != null && fleet.getId() != null) { |
| | | String fleetName = com.xiaopeng.common.core.utils.StringUtils.isBlank(fleet.getFleetName()) |
| | | ? String.valueOf(fleet.getId()) |
| | | : fleet.getFleetName(); |
| | | throw new ServiceException( |
| | | "删除失败,该人员已关联车队:" + fleetName, |
| | | I18nKeyConstant.OPERATIONS_USER_DELETE_FLEET_BOUND, |
| | | new Object[]{fleetName} |
| | | ); |
| | | } |
| | | } catch (ServiceException e) { |
| | | throw e; |
| | | } catch (Exception e) { |
| | | throw new ServiceException("请求失败,请稍后重试", I18nKeyConstant.REQUEST_FAILED); |
| | | } |
| | | xpOperationsUserService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | |
| | | @GetMapping("/api/v1/operationsUser/detailById") |
| | | public R<XpOperationsUserVO> detailById(@RequestParam Long id) { |
| | | XpOperationsUserVO xpOperationsUserVO = xpOperationsUserService.detailById(id); |
| | | if (xpOperationsUserVO.getAvatar() != null) { |
| | | JSONObject jsonObject = JSONObject.parseObject(xpOperationsUserVO.getAvatar()); |
| | | String downloadUrl = null; |
| | | try { |
| | | String downloadUrl1 = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | downloadUrl = downloadUrl1; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | xpOperationsUserVO.setAvatar(downloadUrl); |
| | | } |
| | | |
| | | return R.ok(xpOperationsUserVO); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "运维人员管理导出列表", tags = {"管理后台-运维执行"}) |
| | | @PostMapping("/api/v1/operationsUser/exportOperationsUser") |
| | | public void exportOperationsUser(@RequestBody XpOperationsUserQuery query, HttpServletResponse response){ |
| | | public void exportOperationsUser(@RequestBody XpOperationsUserQuery query, HttpServletResponse response) { |
| | | xpOperationsUserService.exportOperationsUser(query, response); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "运维人员管理导出模板", tags = {"管理后台-运维执行"}) |
| | | @GetMapping("/api/v1/operationsUser/exportTemplate") |
| | | public void exportTemplate(HttpServletResponse response){ |
| | | public void exportTemplate(HttpServletResponse response) { |
| | | xpOperationsUserService.exportTemplate(response); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "运维人员管理导入数据", tags = {"管理后台-运维执行"}) |
| | | @PostMapping("/api/v1/operationsUser/importOperationsUser") |
| | | public void importOperationsUser(@RequestPart("file") MultipartFile file){ |
| | | public R<String> importOperationsUser(@RequestParam("file") MultipartFile file) { |
| | | xpOperationsUserService.importOperationsUser(file); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 根据手机号模糊查询用户(内部接口) |
| | | * |
| | | * @param phoneNumber 手机号 |
| | | * @return 用户信息列表 |
| | | */ |
| | | @ApiOperation(value = "根据手机号模糊查询用户及角色信息", tags = {"内部接口"}) |
| | | @PostMapping("/inner/xpOperationsUser/getByPhoneNumber") |
| | | public R<List<XpOperationsUser>> getByPhoneNumber(@RequestParam String phoneNumber) { |
| | | List<XpOperationsUser> result = xpOperationsUserService.getByPhoneNumber(phoneNumber); |
| | | return R.ok(result); |
| | | } |
| | | } |