xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/constant/I18nKeyConstant.java
@@ -40,4 +40,7 @@ //========== 验证码相关 ========== String SMS_PUSH_FAILED = "sms.push.failed"; //========== 权限组相关 ========== String SYS_GROUP_DELETE_FAIL = "sys.group.delete.fail"; } xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/controller/SysGroupController.java
@@ -11,6 +11,7 @@ import com.xiaopeng.common.core.domain.R; import com.xiaopeng.common.core.web.page.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; @@ -33,38 +34,46 @@ private final ISysGroupService sysGroupService; @ApiOperation("新增权限组") @ApiOperation(value = "新增权限组", tags = {"管理后台-权限组管理"}) @PostMapping("/api/v1/group/add") public R<?> add(@Validated @RequestBody SysGroupAddDTO dto) { sysGroupService.addGroup(dto); return R.ok(); } @ApiOperation("编辑权限组") @ApiOperation(value = "编辑权限组", tags = {"管理后台-权限组管理"}) @PostMapping("/api/v1/group/edit") public R<?> edit(@Validated @RequestBody SysGroupEditDTO dto) { sysGroupService.editGroup(dto); return R.ok(); } @ApiOperation("权限组详情") @ApiOperation(value = "权限组详情", tags = {"管理后台-权限组管理"}) @GetMapping("/api/v1/group/queryById") public R<SysGroupDetailVO> queryById(@ApiParam(value = "权限组id", required = true) @RequestParam Long id) { SysGroupDetailVO detail = sysGroupService.getGroupDetail(id); return R.ok(detail); } @ApiOperation("权限组分页列表") @ApiOperation(value = "权限组分页列表", tags = {"管理后台-权限组管理"}) @PostMapping("/api/v1/group/pageList") public R<PageInfo<SysGroupPageVO>> pageList(@Validated @RequestBody SysGroupPageQuery query) { PageInfo<SysGroupPageVO> pageInfo = sysGroupService.pageList(query); return R.ok(pageInfo); } @ApiOperation("通过权限组id查询绑定账号列表") @ApiOperation(value = "通过权限组id查询绑定账号列表", tags = {"管理后台-权限组管理"}) @PostMapping("/api/v1/group/queryUserPageList") public R<PageInfo<GroupUserVO>> queryUserPageList(@Validated @RequestBody GroupUserPageQuery query) { PageInfo<GroupUserVO> pageInfo = sysGroupService.queryUserPageList(query); return R.ok(pageInfo); } @ApiOperation(value = "删除权限组", tags = {"管理后台-权限组管理"}) @DeleteMapping("/api/v1/group") @ApiImplicitParam(name = "id", value = "权限组ID") public R<?> deleteById(@RequestParam Long id) { sysGroupService.deleteById(id); return R.ok(); } } xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/ISysGroupService.java
@@ -67,4 +67,10 @@ * @return true=唯一,false=不唯一 */ boolean checkGroupNameUnique(String groupName, Long excludeId); /** * 删除权限组 * @param id */ void deleteById(Long id); } xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/SysGroupServiceImpl.java
@@ -15,8 +15,10 @@ import com.xiaopeng.account.model.vo.SysMenuVO; import com.xiaopeng.account.service.ISysGroupMenuService; import com.xiaopeng.account.service.ISysGroupService; import com.xiaopeng.account.service.ISysRoleService; import com.xiaopeng.api.feignClient.operation.SysMenuClient; import com.xiaopeng.api.model.account.SysGroup; import com.xiaopeng.api.model.account.SysRole; import com.xiaopeng.api.model.operation.SysMenu; import com.xiaopeng.common.core.domain.R; import com.xiaopeng.common.core.exception.ServiceException; @@ -50,6 +52,7 @@ private final ISysGroupMenuService groupMenuService; private final SysMenuClient sysMenuClient; private final ISysRoleService sysRoleService; /** * 新增权限组 @@ -298,4 +301,17 @@ } } } /** * 删除权限组 * @param id */ @Override public void deleteById(Long id) { Long count = sysRoleService.lambdaQuery().eq(SysRole::getGroupId, id).count(); if (count > 0) { throw new ServiceException("删除失败,该权限组已关联角色", I18nKeyConstant.SYS_GROUP_DELETE_FAIL); } removeById(id); } } xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/XpOperationsUserServiceImpl.java
@@ -213,6 +213,10 @@ Map<Long, List<SysRole>> map = new HashMap<>(); for (XpOperationsRole xpOperationsRole : xpOperationsRoles) { List<SysRole> sysRoleList = sysRoles.stream().filter(sysRole -> sysRole.getId().equals(xpOperationsRole.getRoleId())).collect(Collectors.toList()); List<SysRole> roleList = map.get(xpOperationsRole.getOperationsUserId()); if(!CollectionUtils.isEmpty(roleList)){ sysRoleList.addAll(roleList); } map.put(xpOperationsRole.getOperationsUserId(), sysRoleList); } // 角色名称匹配 xp-robotaxi-account-boot/src/main/resources/i18n/messages.properties
@@ -30,3 +30,4 @@ group.not.exists=权限组不存在 request.failed=请求失败,请稍后重试! sms.push.failed=短信发送失败,请稍后重试! sys.group.delete.fail=删除失败,该权限组已关联角色 xp-robotaxi-account-boot/src/main/resources/i18n/messages_en_US.properties
@@ -29,4 +29,5 @@ group.name.exists=The group name already exists group.not.exists=Group is not exist request.failed=Request failed. Please try again later! sms.push.failed=SMS sending failed. Please try again later! sms.push.failed=SMS sending failed. Please try again later! sys.group.delete.fail=Deletion failed. This permission group has been associated with a role xp-robotaxi-account-boot/src/main/resources/i18n/messages_zh_CN.properties
@@ -30,3 +30,4 @@ group.not.exists=权限组不存在 request.failed=请求失败,请稍后重试! sms.push.failed=短信发送失败,请稍后重试! sys.group.delete.fail=删除失败,该权限组已关联角色 xp-robotaxi-api/src/main/java/com/xiaopeng/api/vo/account/FleetInfoVO.java
@@ -1,5 +1,7 @@ package com.xiaopeng.api.vo.account; import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; import lombok.Data; import java.io.Serializable; @@ -16,40 +18,48 @@ /** * 车队ID */ @ApiModelProperty(value = "车队ID") private Long fleetId; /** * 车队名称 */ @ApiModelProperty(value = "车队名称") private String fleetName; /** * 省份名称 */ @ApiModelProperty(value = "省份名称") private String provinceName; /** * 城市名称 */ @ApiModelProperty(value = "城市名称") private String cityName; /** * 区县名称 */ @ApiModelProperty(value = "区县名称") private String districtName; /** * 车队队长ID */ @ApiModelProperty(value = "车队队长ID") private Long captainId; /** * 车队队长名称 */ @ApiModelProperty(value = "车队队长名称") private String fleetLeaderName; /** * 车队队长头像 */ @ApiModelProperty(value = "车队队长头像") private String fleetLeaderAvatar; } xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/config/MessageLocalConfig.java
@@ -54,9 +54,9 @@ } @Bean//注册国际化组件 public LocaleResolver localeResolver(){ return new MyLocaleResolver(); } // @Bean//注册国际化组件 // public LocaleResolver localeResolver(){ // return new MyLocaleResolver(); // } } xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/config/MyLocaleResolver.java
@@ -1,80 +1,80 @@ package com.xiaopeng.pushMessage.config; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import org.springframework.util.StringUtils; import org.springframework.web.servlet.LocaleResolver; import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Locale; public class MyLocaleResolver implements LocaleResolver { @Override public Locale resolveLocale(HttpServletRequest request) { //1=中文,2=英文,3=印尼文 //1=Chinese, 2=English, 3=Indonesian. String language = getQueryParams(request, "language"); Locale locale = null; if (StringUtils.isEmpty(language)) { locale = Locale.getDefault(); } //如果请求不为空 //If the request is not empty. if (language.equals("1")) { locale = new Locale("zh", "CN"); } else if (language.equals("2")) { locale = new Locale("en", "US"); } return locale; } @Override public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) { } public String getQueryParams(HttpServletRequest request, String key) { try { String method = request.getMethod(); if("POST".equals(method)){ String parameter = request.getParameter(key); if(!StringUtils.isEmpty(parameter)){ return parameter; } Object attribute = request.getAttribute(key); if(null != attribute){ return attribute.toString(); } StringBuffer sb = new StringBuffer(); ServletInputStream inputStream = request.getInputStream(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); String s; while ((s = bufferedReader.readLine()) != null){ sb.append(s); } bufferedReader.close(); inputStream.close(); JSONObject jsonObject = JSON.parseObject(sb.toString()); return jsonObject.getString(key); }else{ String parameter = request.getParameter(key); if(!StringUtils.isEmpty(parameter)){ return parameter; } Object attribute = request.getAttribute(key); if(null != attribute){ return attribute.toString(); } } }catch (Exception e){ e.printStackTrace(); } return null; } } //package com.xiaopeng.pushMessage.config; // //import com.alibaba.fastjson.JSON; //import com.alibaba.fastjson.JSONObject; //import org.springframework.util.StringUtils; //import org.springframework.web.servlet.LocaleResolver; // //import javax.servlet.ServletInputStream; //import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletResponse; //import java.io.BufferedReader; //import java.io.InputStreamReader; //import java.util.Locale; // //public class MyLocaleResolver implements LocaleResolver { // // @Override // public Locale resolveLocale(HttpServletRequest request) { // //1=中文,2=英文,3=印尼文 // //1=Chinese, 2=English, 3=Indonesian. // String language = getQueryParams(request, "language"); // // Locale locale = null; // if (StringUtils.isEmpty(language)) { // locale = Locale.getDefault(); // } // //如果请求不为空 // //If the request is not empty. // if (language.equals("1")) { // locale = new Locale("zh", "CN"); // } else if (language.equals("2")) { // locale = new Locale("en", "US"); // } // return locale; // } // // @Override // public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) { // } // // // public String getQueryParams(HttpServletRequest request, String key) { // try { // String method = request.getMethod(); // if("POST".equals(method)){ // String parameter = request.getParameter(key); // if(!StringUtils.isEmpty(parameter)){ // return parameter; // } // Object attribute = request.getAttribute(key); // if(null != attribute){ // return attribute.toString(); // } // StringBuffer sb = new StringBuffer(); // ServletInputStream inputStream = request.getInputStream(); // BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); // String s; // while ((s = bufferedReader.readLine()) != null){ // sb.append(s); // } // bufferedReader.close(); // inputStream.close(); // JSONObject jsonObject = JSON.parseObject(sb.toString()); // return jsonObject.getString(key); // }else{ // String parameter = request.getParameter(key); // if(!StringUtils.isEmpty(parameter)){ // return parameter; // } // Object attribute = request.getAttribute(key); // if(null != attribute){ // return attribute.toString(); // } // } // }catch (Exception e){ // e.printStackTrace(); // } // return null; // } //}