From af5e89cb2316de0066cb87918f5aad32c1676ccb Mon Sep 17 00:00:00 2001 From: chen <1251790704@qq.com> Date: Wed, 31 Aug 2022 16:42:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E9=83=A8=E8=BD=AC=E6=8D=A2=E4=B8=BA?= =?UTF-8?q?=E8=87=AA=E5=A2=9Eid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 26 +++ .../common/aop/aspect/DataScopeAspect.java | 4 +- .../iasf/common/aop/aspect/SysLogAspect.java | 4 +- .../huoran/iasf/common/filter/AuthFilter.java | 25 +-- .../shiro/CustomAccessControlFilter.java | 22 +- .../huoran/iasf/common/shiro/ShiroConfig.java | 15 +- .../huoran/iasf/common/utils/EmailUtils.java | 70 +++++++ .../huoran/iasf/common/utils/RandomUtil.java | 64 ++++++ .../huoran/iasf/common/utils/SMSTemplate.java | 34 +++ .../iasf/common/utils/SendSMSUtils.java | 51 +++++ .../iasf/controller/RoleController.java | 4 +- .../iasf/controller/UserController.java | 70 +++---- .../java/com/huoran/iasf/entity/SysDept.java | 8 +- .../com/huoran/iasf/entity/SysPermission.java | 6 +- .../java/com/huoran/iasf/entity/SysRole.java | 8 +- .../huoran/iasf/entity/SysRoleDeptEntity.java | 49 ----- .../huoran/iasf/entity/SysRolePermission.java | 11 +- .../java/com/huoran/iasf/entity/SysUser.java | 17 +- .../com/huoran/iasf/entity/SysUserRole.java | 11 +- .../java/com/huoran/iasf/entity/UserDept.java | 4 +- .../huoran/iasf/mapper/SysRoleDeptMapper.java | 15 -- .../iasf/service/HttpSessionService.java | 24 +-- .../iasf/service/PermissionService.java | 14 +- .../com/huoran/iasf/service/RoleService.java | 6 +- .../huoran/iasf/service/UserRoleService.java | 4 +- .../com/huoran/iasf/service/UserService.java | 37 +--- .../iasf/service/impl/DeptServiceImpl.java | 4 +- .../service/impl/PermissionServiceImpl.java | 24 +-- .../impl/RolePermissionServiceImpl.java | 2 +- .../iasf/service/impl/RoleServiceImpl.java | 12 +- .../service/impl/SysFilesServiceImpl.java | 1 - .../service/impl/SysRoleDeptServiceImpl.java | 14 -- .../service/impl/UserRoleServiceImpl.java | 6 +- .../iasf/service/impl/UserServiceImpl.java | 194 ++++++++++++------ src/main/java/com/huoran/iasf/vo/CheckVo.java | 37 ++++ .../vo/req/RolePermissionOperationReqVO.java | 4 +- .../iasf/vo/req/UpdatePhoneOrEmailReq.java | 30 +++ .../iasf/vo/req/UserRoleOperationReqVO.java | 4 +- .../iasf/vo/resp/PermissionRespNode.java | 2 +- src/main/resources/whiteList.properties | 2 + .../com/company/project/CodeGenerator.java | 6 +- 41 files changed, 615 insertions(+), 330 deletions(-) create mode 100644 src/main/java/com/huoran/iasf/common/utils/EmailUtils.java create mode 100644 src/main/java/com/huoran/iasf/common/utils/RandomUtil.java create mode 100644 src/main/java/com/huoran/iasf/common/utils/SMSTemplate.java create mode 100644 src/main/java/com/huoran/iasf/common/utils/SendSMSUtils.java delete mode 100644 src/main/java/com/huoran/iasf/entity/SysRoleDeptEntity.java delete mode 100644 src/main/java/com/huoran/iasf/mapper/SysRoleDeptMapper.java delete mode 100644 src/main/java/com/huoran/iasf/service/impl/SysRoleDeptServiceImpl.java create mode 100644 src/main/java/com/huoran/iasf/vo/CheckVo.java create mode 100644 src/main/java/com/huoran/iasf/vo/req/UpdatePhoneOrEmailReq.java create mode 100644 src/main/resources/whiteList.properties diff --git a/pom.xml b/pom.xml index cc48dae..63f303b 100644 --- a/pom.xml +++ b/pom.xml @@ -37,8 +37,34 @@ 4.1.3 + + + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + 2.1.0.RELEASE + pom + import + + + + + + + org.apache.commons + commons-email + 1.3.3 + + + + + com.aliyun + aliyun-java-sdk-core + + org.springframework.boot spring-boot-starter-cache diff --git a/src/main/java/com/huoran/iasf/common/aop/aspect/DataScopeAspect.java b/src/main/java/com/huoran/iasf/common/aop/aspect/DataScopeAspect.java index 3264dd2..04e21d6 100644 --- a/src/main/java/com/huoran/iasf/common/aop/aspect/DataScopeAspect.java +++ b/src/main/java/com/huoran/iasf/common/aop/aspect/DataScopeAspect.java @@ -54,7 +54,7 @@ public class DataScopeAspect { protected void handleDataScope(final JoinPoint joinPoint) { //获取当前登陆人 - String id = sessionService.getCurrentUserId(); + Integer id = sessionService.getCurrentUserId(); //获取当前登陆人角色, 如果无角色, 那么不限制 List sysRoles = roleService.getRoleInfoByUserId(id); if (CollectionUtils.isEmpty(sysRoles) || sysRoles.size() == 0) { @@ -86,7 +86,7 @@ public class DataScopeAspect { * @param userId 当前用户id * @return 用户id集合 */ - private List getUserIdsByRoles(List sysRoles, String userId) { + private List getUserIdsByRoles(List sysRoles, Integer userId) { //本人 SysUser sysUser = userService.getById(userId); //本部门 diff --git a/src/main/java/com/huoran/iasf/common/aop/aspect/SysLogAspect.java b/src/main/java/com/huoran/iasf/common/aop/aspect/SysLogAspect.java index c0f8d5c..14d8cbb 100644 --- a/src/main/java/com/huoran/iasf/common/aop/aspect/SysLogAspect.java +++ b/src/main/java/com/huoran/iasf/common/aop/aspect/SysLogAspect.java @@ -104,10 +104,10 @@ public class SysLogAspect { sysLog.setIp(IPUtils.getIpAddr(request)); log.info("Ip{},接口地址{},请求方式{},入参:{}", sysLog.getIp(), request.getRequestURL(), request.getMethod(), sysLog.getParams()); //用户名 - String userId = httpSessionService.getCurrentUserId(); + Integer userId = httpSessionService.getCurrentUserId(); String username = httpSessionService.getCurrentUsername(); sysLog.setUsername(username); - sysLog.setUserId(userId); + sysLog.setUserId(userId.toString()); sysLog.setTime((int) time); log.info(sysLog.toString()); sysLogMapper.insert(sysLog); diff --git a/src/main/java/com/huoran/iasf/common/filter/AuthFilter.java b/src/main/java/com/huoran/iasf/common/filter/AuthFilter.java index 5b3a8a6..af972ed 100644 --- a/src/main/java/com/huoran/iasf/common/filter/AuthFilter.java +++ b/src/main/java/com/huoran/iasf/common/filter/AuthFilter.java @@ -1,4 +1,3 @@ -/* package com.huoran.iasf.common.filter; import com.alibaba.fastjson.JSON; @@ -24,12 +23,13 @@ import static com.huoran.iasf.service.HttpApiSessionService.USER_USERNAME_KEY; @WebFilter(filterName = "authFilter", urlPatterns = "/iasf/*") @Order(1) public class AuthFilter implements Filter { -*/ -/** - * 白名单*//* - + /** + * 白名单 + */ + private static final String[] whiteList = + {"/iasf/sys/user/login", + "/iasf/sys/exportFailure"}; - private static final String[] whiteList = {"/iasf/app/api/login", "/iasf/app/api/open/test"}; @Resource HttpApiSessionService httpApiSessionService; //需要拦截的地址 @@ -55,12 +55,14 @@ public class AuthFilter implements Filter { } //token为空返回 if (StringUtils.isBlank(token)) { + resp.setStatus(401); responseResult(resp, R.fail("token不能为空")); } // 校验并解析token,如果token过期或者篡改,则会返回null Claims claims = httpApiSessionService.checkJWT(token); if (null == claims) { - responseResult(resp, R.fail("登陆失效, 请重新登陆")); + resp.setStatus(401); + responseResult(resp, R.fail("登陆失效,请重新登陆")); } //TODO 校验用户状态等 @@ -72,18 +74,14 @@ public class AuthFilter implements Filter { } -*/ /** * responseResult * @param response - * @param result - *//* - - + * @param result*/ private void responseResult(HttpServletResponse response, R result) { response.setCharacterEncoding("UTF-8"); response.setHeader("Content-type", "application/json;charset=UTF-8"); - response.setStatus(200); + // response.setStatus(200); try { response.getWriter().write(JSON.toJSONString(result)); } catch (IOException ex) { @@ -91,4 +89,3 @@ public class AuthFilter implements Filter { } } } -*/ diff --git a/src/main/java/com/huoran/iasf/common/shiro/CustomAccessControlFilter.java b/src/main/java/com/huoran/iasf/common/shiro/CustomAccessControlFilter.java index 2fc8449..07d07ca 100644 --- a/src/main/java/com/huoran/iasf/common/shiro/CustomAccessControlFilter.java +++ b/src/main/java/com/huoran/iasf/common/shiro/CustomAccessControlFilter.java @@ -59,39 +59,39 @@ public class CustomAccessControlFilter extends AccessControlFilter { UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(token, token); getSubject(servletRequest, servletResponse).login(usernamePasswordToken); } catch (BusinessException exception) { -/* if (HttpContextUtils.isAjaxRequest(request)) { - customResponse(exception.getBaseResponseCode(), exception.getMessage(), servletResponse); - } else if (exception.getMessageCode() == BaseResponseCode.TOKEN_ERROR.getCode()) { + if (HttpContextUtils.isAjaxRequest(request)) { + customResponse(exception.getBaseResponseCode().getCode(), exception.getMessage(), servletResponse); + } else if (exception.getBaseResponseCode().getCode() == BaseResponseCode.TOKEN_ERROR.getCode()) { servletRequest.getRequestDispatcher("/index/login").forward(servletRequest, servletResponse); - } else if (exception.getMessageCode() == BaseResponseCode.UNAUTHORIZED_ERROR.getCode()) { + } else if (exception.getBaseResponseCode().getCode() == BaseResponseCode.UNAUTHORIZED_ERROR.getCode()) { servletRequest.getRequestDispatcher("/index/403").forward(servletRequest, servletResponse); } else { servletRequest.getRequestDispatcher("/index/500").forward(servletRequest, servletResponse); - }*/ + } return false; } catch (AuthenticationException e) { - /*if (HttpContextUtils.isAjaxRequest(request)) { + if (HttpContextUtils.isAjaxRequest(request)) { if (e.getCause() instanceof BusinessException) { BusinessException exception = (BusinessException) e.getCause(); - customResponse(exception.getBaseResponseCode(), exception.getMessage(), servletResponse); + customResponse(exception.getBaseResponseCode().getCode(), exception.getMessage(), servletResponse); } else { customResponse(BaseResponseCode.SYSTEM_BUSY.getCode(), BaseResponseCode.SYSTEM_BUSY.getMsg(), servletResponse); } } else { servletRequest.getRequestDispatcher("/index/403").forward(servletRequest, servletResponse); - }*/ + } return false; } catch (Exception e) { - /*if (HttpContextUtils.isAjaxRequest(request)) { + if (HttpContextUtils.isAjaxRequest(request)) { if (e.getCause() instanceof BusinessException) { BusinessException exception = (BusinessException) e.getCause(); - customResponse(exception.getMessageCode(), exception.getDetailMessage(), servletResponse); + customResponse(exception.getBaseResponseCode().getCode(), exception.getMessage(), servletResponse); } else { customResponse(BaseResponseCode.SYSTEM_BUSY.getCode(), BaseResponseCode.SYSTEM_BUSY.getMsg(), servletResponse); } } else { servletRequest.getRequestDispatcher("/index/500").forward(servletRequest, servletResponse); - }*/ + } return false; } return true; diff --git a/src/main/java/com/huoran/iasf/common/shiro/ShiroConfig.java b/src/main/java/com/huoran/iasf/common/shiro/ShiroConfig.java index 7bce29b..a7f2e4d 100644 --- a/src/main/java/com/huoran/iasf/common/shiro/ShiroConfig.java +++ b/src/main/java/com/huoran/iasf/common/shiro/ShiroConfig.java @@ -24,7 +24,6 @@ import java.util.Map; * @date 2022年7月28日 *//* - @Configuration @EnableConfigurationProperties(FileUploadProperties.class) public class ShiroConfig { @@ -41,7 +40,6 @@ public class ShiroConfig { /** * 创建realm*//* - @Bean public CustomRealm customRealm() { CustomRealm customRealm = new CustomRealm(); @@ -51,7 +49,6 @@ public class ShiroConfig { @Bean public SecurityManager securityManager() { - DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); //关联realm securityManager.setRealm(customRealm()); @@ -73,7 +70,8 @@ public class ShiroConfig { shiroFilterFactoryBean.setFilters(filtersMap); Map filterChainDefinitionMap = new LinkedHashMap<>(); // 配置不会被拦截的链接 顺序判断 - filterChainDefinitionMap.put("/sys/user/login", "anon"); + */ +/*filterChainDefinitionMap.put("/sys/user/login", "anon"); filterChainDefinitionMap.put("/sys/user/token", "anon"); filterChainDefinitionMap.put("/sys/getVerify", "anon"); filterChainDefinitionMap.put("/sys/checkVerify", "anon"); @@ -96,9 +94,12 @@ public class ShiroConfig { filterChainDefinitionMap.put("/layui/**", "anon"); filterChainDefinitionMap.put("/css/**", "anon"); filterChainDefinitionMap.put("/layui-ext/**", "anon"); - filterChainDefinitionMap.put("/app/api/**", "anon"); + filterChainDefinitionMap.put("/app/api/**", "anon");*//* + + filterChainDefinitionMap.put("/sys/getVerify", "anon"); + filterChainDefinitionMap.put("/sys/user/login", "anon"); filterChainDefinitionMap.put("/**", "token,authc"); - shiroFilterFactoryBean.setLoginUrl("/index/login"); + shiroFilterFactoryBean.setLoginUrl("/login"); shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); return shiroFilterFactoryBean; } @@ -110,8 +111,6 @@ public class ShiroConfig { * * @return org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor*//* - - @Bean public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) { AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); diff --git a/src/main/java/com/huoran/iasf/common/utils/EmailUtils.java b/src/main/java/com/huoran/iasf/common/utils/EmailUtils.java new file mode 100644 index 0000000..ac2cf3d --- /dev/null +++ b/src/main/java/com/huoran/iasf/common/utils/EmailUtils.java @@ -0,0 +1,70 @@ +package com.huoran.iasf.common.utils; + +import org.apache.commons.mail.DefaultAuthenticator; +import org.apache.commons.mail.HtmlEmail; + + +public class EmailUtils { + + //服务器地址 + private static final String SERVER_ADDRESS = "smtp.mxhichina.com"; + //邮箱地址 + private static final String EMAILADDRESS = "postmaster@huorantech.cn"; + //发生邮箱密码 + private static final String EMAILPASSWORD = "HR111aaa"; + //发送人姓名 + private static final String EMAILUSERNAME = "DataForward"; + //授权码 + //private static final String AUTHORIZATION_CODE = "smtp.mxhichina.com"; + //邮件标题 + private static final String EMAILHEAD = "粒子研究院"; + //邮件信息(后接验证码)头部信息 + private static final String EMAILMASSAGEHEAD = "尊敬的用户,欢迎使用粒子研究院,您本次的验证码是: "; + //邮件信息(后接验证码)尾部信息 + private static final String EMAILMASSAGETAIL = ",有效时间为5分钟"; + + + //邮箱验证码 + public static boolean sendEmail(String emailaddress,String code){ + try { + HtmlEmail email = new HtmlEmail(); + email.setHostName(SERVER_ADDRESS); + email.setSSLOnConnect(true); //使用ssl加密true + email.setSslSmtpPort("465"); //使用465端口 + email.setCharset("UTF-8"); + email.addTo(emailaddress); + + email.setFrom(EMAILADDRESS, EMAILUSERNAME); +// -- 使用阿里企业邮箱无授权码 +// email.setAuthentication(EMAILADDRESS, AUTHORIZATION_CODE); + + email.setAuthenticator(new DefaultAuthenticator(EMAILADDRESS,EMAILPASSWORD)); + email.setSubject(EMAILHEAD); + email.setMsg( EMAILMASSAGEHEAD + code + EMAILMASSAGETAIL); + + email.send(); + return true; + } + catch(Exception e){ + e.printStackTrace(); + return false; + } + } + + /** + * 描述:是否是邮箱. + * + * @param str 指定的字符串 + * @return 是否是邮箱:是为true,否则false + */ + public static Boolean isEmail(String str) { + Boolean isEmail = false; + String expr = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})$"; + + if (str.matches(expr)) { + isEmail = true; + } + return isEmail; + } + +} \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/common/utils/RandomUtil.java b/src/main/java/com/huoran/iasf/common/utils/RandomUtil.java new file mode 100644 index 0000000..d352428 --- /dev/null +++ b/src/main/java/com/huoran/iasf/common/utils/RandomUtil.java @@ -0,0 +1,64 @@ +package com.huoran.iasf.common.utils; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Random; + +/** + * 获取随机数 + * + * @author cheney + * + */ +public class RandomUtil { + + private static final Random random = new Random(); + + private static final DecimalFormat fourdf = new DecimalFormat("0000"); + + private static final DecimalFormat sixdf = new DecimalFormat("000000"); + + public static String getFourBitRandom() { + return fourdf.format(random.nextInt(10000)); + } + + public static String getSixBitRandom() { + return sixdf.format(random.nextInt(1000000)); + } + + /** + * 给定数组,抽取n个数据 + * @param list + * @param n + * @return + */ + public static ArrayList getRandom(List list, int n) { + + Random random = new Random(); + + HashMap hashMap = new HashMap(); + + // 生成随机数字并存入HashMap + for (int i = 0; i < list.size(); i++) { + + int number = random.nextInt(100) + 1; + + hashMap.put(number, i); + } + + // 从HashMap导入数组 + Object[] robjs = hashMap.values().toArray(); + + ArrayList r = new ArrayList(); + + // 遍历数组并打印数据 + for (int i = 0; i < n; i++) { + r.add(list.get((int) robjs[i])); + System.out.print(list.get((int) robjs[i]) + "\t"); + } + System.out.print("\n"); + return r; + } +} diff --git a/src/main/java/com/huoran/iasf/common/utils/SMSTemplate.java b/src/main/java/com/huoran/iasf/common/utils/SMSTemplate.java new file mode 100644 index 0000000..841e8c0 --- /dev/null +++ b/src/main/java/com/huoran/iasf/common/utils/SMSTemplate.java @@ -0,0 +1,34 @@ +package com.huoran.iasf.common.utils; + +/** + * @Author chen + * @DATE 2021/7/7 14:14 + * @Version 1.0 + */ +public interface SMSTemplate { + + // 短信签名 + String SMS_SIGNATURE = "或然科技"; + + // 找回密码验证码 + String RETRIEVE_PASSWORD_CODE = "SMS_219310031"; + + // 身份验证验证码 + String AUTHENTICATION_CODE = "SMS_221515019"; + + // 登录确认验证码 + String LOGIN_VERIFICATION_CODE = "SMS_204155296"; + + // 登录异常验证码 + String LOGIN_EXCEPTION_CODE = "SMS_204155295"; + + // 用户注册验证码 + String USER_REGISTRATION_CODE = "SMS_204155294"; + + // 修改密码验证码 + String MODIFY_PASSWORD_CODE = "SMS_204155293"; + + // 信息变更验证码 + String INFORMATION_CHANGE_CODE = "SMS_204155292"; + +} diff --git a/src/main/java/com/huoran/iasf/common/utils/SendSMSUtils.java b/src/main/java/com/huoran/iasf/common/utils/SendSMSUtils.java new file mode 100644 index 0000000..a02ccdc --- /dev/null +++ b/src/main/java/com/huoran/iasf/common/utils/SendSMSUtils.java @@ -0,0 +1,51 @@ +package com.huoran.iasf.common.utils; + +import com.alibaba.fastjson.JSONObject; +import com.aliyuncs.CommonRequest; +import com.aliyuncs.CommonResponse; +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.exceptions.ClientException; +import com.aliyuncs.http.MethodType; +import com.aliyuncs.profile.DefaultProfile; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.util.Map; + + +@Slf4j +public class SendSMSUtils { + + public static boolean send(String PhoneNumbers, String templateCode, Map param) { + + if(StringUtils.isEmpty(PhoneNumbers)) { + return false; + } + + DefaultProfile profile = + DefaultProfile.getProfile("default", "LTAI4FzqQHnk4rozqLZ8jCNj", "mveW7B1OyFoKUkHm8WsxmrjHmkJWHq"); + IAcsClient client = new DefaultAcsClient(profile); + + CommonRequest request = new CommonRequest(); + request.setMethod(MethodType.GET); + request.setDomain("dysmsapi.aliyuncs.com"); + request.setVersion("2017-05-25"); + request.setAction("SendSms"); + + request.putQueryParameter("PhoneNumbers", PhoneNumbers); + request.putQueryParameter("SignName", SMSTemplate.SMS_SIGNATURE); + request.putQueryParameter("TemplateCode", templateCode); + request.putQueryParameter("TemplateParam", JSONObject.toJSONString(param)); + + try { + CommonResponse response = client.getCommonResponse(request); + System.out.println(response.getData()); + return response.getHttpResponse().isSuccess(); + } catch (ClientException e) { + e.printStackTrace(); + } + return false; + } + +} diff --git a/src/main/java/com/huoran/iasf/controller/RoleController.java b/src/main/java/com/huoran/iasf/controller/RoleController.java index c61765d..069de97 100644 --- a/src/main/java/com/huoran/iasf/controller/RoleController.java +++ b/src/main/java/com/huoran/iasf/controller/RoleController.java @@ -69,7 +69,7 @@ public class RoleController { @ApiOperation(value = "删除角色接口") @LogAnnotation(title = "角色管理", action = "删除角色") @RequiresPermissions("sys:role:deleted") - public R deleted(@PathVariable("id") String id) { + public R deleted(@PathVariable("id") Integer id) { roleService.deletedRole(id); return R.success(); } @@ -100,7 +100,7 @@ public class RoleController { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq("role_id", id).select("permission_id"); List list = rolePermissionService.list(wrapper); - List permissionList = new ArrayList<>(); + List permissionList = new ArrayList<>(); list.forEach(rolePermission -> { permissionList.add(rolePermission.getPermissionId()); }); diff --git a/src/main/java/com/huoran/iasf/controller/UserController.java b/src/main/java/com/huoran/iasf/controller/UserController.java index 23960ad..c294a85 100644 --- a/src/main/java/com/huoran/iasf/controller/UserController.java +++ b/src/main/java/com/huoran/iasf/controller/UserController.java @@ -6,8 +6,9 @@ import com.huoran.iasf.common.aop.annotation.LogAnnotation; import com.huoran.iasf.common.utils.R; import com.huoran.iasf.entity.SysUser; import com.huoran.iasf.service.HttpSessionService; -import com.huoran.iasf.service.UserRoleService; import com.huoran.iasf.service.UserService; +import com.huoran.iasf.vo.CheckVo; +import com.huoran.iasf.vo.req.UpdatePhoneOrEmailReq; import com.huoran.iasf.vo.req.UserListReq; import com.huoran.iasf.vo.resp.UserListResp; import io.swagger.annotations.Api; @@ -43,8 +44,7 @@ import java.util.Map; public class UserController { @Resource private UserService userService; - @Resource - private UserRoleService userRoleService; + @Resource private HttpSessionService httpSessionService; @@ -61,7 +61,6 @@ public class UserController { return R.success(); }*/ - @PutMapping("/user") @ApiOperation(value = "更新用户信息接口") @LogAnnotation(title = "用户管理", action = "更新用户信息") @@ -74,7 +73,6 @@ public class UserController { return R.success(); } - @GetMapping("/user/{id}") @ApiOperation(value = "查询用户详情接口") @LogAnnotation(title = "用户管理", action = "查询用户详情") @@ -106,7 +104,7 @@ public class UserController { public R checkJobNumber(@RequestParam String jobNumber) { SysUser sysUser = userService.getOne(Wrappers.lambdaQuery().eq(SysUser::getJobNumber, jobNumber)); if (sysUser != null) { - R.fail("工号已存在,请勿重复添加!"); + return R.fail("工号已存在,请勿重复添加!"); } return R.success(); } @@ -116,7 +114,7 @@ public class UserController { public R checkUsername(@RequestParam String userName) { SysUser sysUser = userService.getOne(Wrappers.lambdaQuery().eq(SysUser::getUsername, userName)); if (sysUser != null) { - R.fail("账号已存在,请勿重复添加!"); + return R.fail("账号已存在,请勿重复添加!"); } return R.success(); } @@ -126,7 +124,7 @@ public class UserController { public R checkEmail(@RequestParam String email) { SysUser sysUser = userService.getOne(Wrappers.lambdaQuery().eq(SysUser::getEmail, email)); if (sysUser != null) { - R.fail("邮箱已存在,请勿重复添加!"); + return R.fail("邮箱已存在,请勿重复添加!"); } return R.success(); } @@ -136,7 +134,7 @@ public class UserController { public R checkPhone(@RequestParam String phone) { SysUser sysUser = userService.getOne(Wrappers.lambdaQuery().eq(SysUser::getPhone, phone)); if (sysUser != null) { - R.fail("手机号已存在,请勿重复添加!"); + return R.fail("手机号已存在,请勿重复添加!"); } return R.success(); } @@ -164,7 +162,7 @@ public class UserController { if (StringUtils.isEmpty(vo.getOldPwd()) || StringUtils.isEmpty(vo.getNewPwd())) { return R.fail("旧密码与新密码不能为空"); } - String userId = httpSessionService.getCurrentUserId(); + Integer userId = httpSessionService.getCurrentUserId(); vo.setId(userId); userService.updatePwd(vo); return R.success(); @@ -174,7 +172,7 @@ public class UserController { @ApiOperation(value = "删除用户接口") @LogAnnotation(title = "用户管理", action = "删除用户") @RequiresPermissions("sys:user:deleted") - public R deletedUser(@RequestBody @ApiParam(value = "用户id集合") List userIds) { + public R deletedUser(@RequestBody @ApiParam(value = "用户id集合") List userIds) { //删除用户, 删除redis的绑定的角色跟权限 httpSessionService.abortUserByUserIds(userIds); LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); @@ -183,37 +181,6 @@ public class UserController { return R.success(); } - /*@GetMapping("/user/roles/{userId}") - @ApiOperation(value = "赋予角色-获取所有角色接口") - @LogAnnotation(title = "用户管理", action = "赋予角色-获取所有角色接口") - @RequiresPermissions("sys:user:role:detail") - public R getUserOwnRole(@PathVariable("userId") String userId) { - R result = R.success(); - result.setData(userService.getUserOwnRole(userId)); - return result; - } - - @PutMapping("/user/roles/{userId}") - @ApiOperation(value = "赋予角色-用户赋予角色接口") - @LogAnnotation(title = "用户管理", action = "赋予角色-用户赋予角色接口") - @RequiresPermissions("sys:user:update:role") - public R setUserOwnRole(@PathVariable("userId") String userId, @RequestBody List roleIds) { - - LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); - queryWrapper.eq(SysUserRole::getUserId, userId); - userRoleService.remove(queryWrapper); - if (!CollectionUtils.isEmpty(roleIds)) { - UserRoleOperationReqVO reqVO = new UserRoleOperationReqVO(); - reqVO.setUserId(userId); - reqVO.setRoleIds(roleIds); - userRoleService.addUserRoleInfo(reqVO); - } - //刷新权限 - httpSessionService.refreshUerId(userId); - return R.success(); - }*/ - - @PostMapping("/importStaff") @ApiOperation("批量导入员工") public R importStaff(@RequestParam(name = "file") MultipartFile file, HttpServletRequest request) throws IOException { @@ -229,4 +196,23 @@ public class UserController { public void exportFailureRecord(HttpServletResponse response, @ApiParam(name = "exportCode", value = "importQuestion接口返回的exportCode", required = true) @RequestParam String exportCode) throws Exception { userService.exportFailureRecord(response, exportCode); } + + @ApiOperation(value = "更换手机号或邮箱--发送验证码") + @PostMapping("/sendPhoneOrEmailCode") + public R sendPhoneOrEmailCode(@RequestBody CheckVo checkVo) { + return userService.sendCheckPhoneCode(checkVo); + } + + @ApiOperation(value = "更新手机号或邮箱") + @PostMapping("/updatePhoneOrEmail") + public R updatePhoneOrEmail(@RequestBody UpdatePhoneOrEmailReq updatePhoneOrEmailReq) { + return userService.updatePhoneOrEmail(updatePhoneOrEmailReq); + } + + @ApiOperation(value = "修改用户头像") + @PostMapping("/updateUserAvatars") + public R updateUserAvatars(@RequestParam String userId, MultipartFile file) { + return userService.updateUserAvatars(userId, file); + } + } diff --git a/src/main/java/com/huoran/iasf/entity/SysDept.java b/src/main/java/com/huoran/iasf/entity/SysDept.java index 0ec23c5..a1d6cd7 100644 --- a/src/main/java/com/huoran/iasf/entity/SysDept.java +++ b/src/main/java/com/huoran/iasf/entity/SysDept.java @@ -1,6 +1,7 @@ package com.huoran.iasf.entity; import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModelProperty; @@ -19,8 +20,9 @@ import java.util.Date; */ @Data public class SysDept implements Serializable { - @TableId - private String id; + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; @ApiModelProperty(value = "部门编号(规则:父级关系编码+自己的编码)") private String deptNo; @@ -31,7 +33,7 @@ public class SysDept implements Serializable { @NotBlank(message = "父级不能为空") @ApiModelProperty(value = "父级id") - private String pid; + private Integer pid; @TableField(exist = false) @ApiModelProperty(value = "父级部门名称") diff --git a/src/main/java/com/huoran/iasf/entity/SysPermission.java b/src/main/java/com/huoran/iasf/entity/SysPermission.java index 3fb88a2..103206d 100644 --- a/src/main/java/com/huoran/iasf/entity/SysPermission.java +++ b/src/main/java/com/huoran/iasf/entity/SysPermission.java @@ -1,6 +1,7 @@ package com.huoran.iasf.entity; import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModelProperty; @@ -22,8 +23,9 @@ import java.util.List; @Data public class SysPermission implements Serializable { - @TableId - private String id; + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; @NotBlank(message = "菜单权限名称不能为空") @ApiModelProperty(value = "菜单权限名称") diff --git a/src/main/java/com/huoran/iasf/entity/SysRole.java b/src/main/java/com/huoran/iasf/entity/SysRole.java index b9aa945..2d3271f 100644 --- a/src/main/java/com/huoran/iasf/entity/SysRole.java +++ b/src/main/java/com/huoran/iasf/entity/SysRole.java @@ -1,6 +1,7 @@ package com.huoran.iasf.entity; import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModelProperty; @@ -24,8 +25,9 @@ import java.util.List; @Data @Accessors(chain = true) public class SysRole extends BaseEntity implements Serializable { - @TableId - private String id; + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; @NotBlank(message = "名称不能为空") @ApiModelProperty(value = "角色名称") @@ -54,7 +56,7 @@ public class SysRole extends BaseEntity implements Serializable { @TableField(exist = false) @ApiModelProperty(value = "权限") - private List permissions; + private List permissions; } \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/entity/SysRoleDeptEntity.java b/src/main/java/com/huoran/iasf/entity/SysRoleDeptEntity.java deleted file mode 100644 index daa7d81..0000000 --- a/src/main/java/com/huoran/iasf/entity/SysRoleDeptEntity.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.huoran.iasf.entity; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -/** - * 角色部门 - * - * @author cheney - * @email *****@mail.com - * @date 2020-09-27 17:30:15 - */ -@Data -@TableName("sys_role_dept") -public class SysRoleDeptEntity extends BaseEntity implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - @TableId("id") - private String id; - - /** - * 角色id - */ - @TableField("role_id") - private String roleId; - - /** - * 菜单权限id - */ - @TableField("dept_id") - private String deptId; - - /** - * 创建时间 - */ - @TableField(value = "create_time", fill = FieldFill.INSERT) - private Date createTime; - - -} diff --git a/src/main/java/com/huoran/iasf/entity/SysRolePermission.java b/src/main/java/com/huoran/iasf/entity/SysRolePermission.java index 2c9fe26..f479d85 100644 --- a/src/main/java/com/huoran/iasf/entity/SysRolePermission.java +++ b/src/main/java/com/huoran/iasf/entity/SysRolePermission.java @@ -1,8 +1,10 @@ package com.huoran.iasf.entity; import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; @@ -17,12 +19,13 @@ import java.util.Date; */ @Data public class SysRolePermission implements Serializable { - @TableId - private String id; + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; - private String roleId; + private Integer roleId; - private String permissionId; + private Integer permissionId; @TableField(fill = FieldFill.INSERT) private Date createTime; diff --git a/src/main/java/com/huoran/iasf/entity/SysUser.java b/src/main/java/com/huoran/iasf/entity/SysUser.java index a92e155..bae7a9e 100644 --- a/src/main/java/com/huoran/iasf/entity/SysUser.java +++ b/src/main/java/com/huoran/iasf/entity/SysUser.java @@ -1,6 +1,7 @@ package com.huoran.iasf.entity; import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModelProperty; @@ -22,9 +23,9 @@ import java.util.List; @EqualsAndHashCode(callSuper = true) @Data public class SysUser extends BaseEntity implements Serializable { - @TableId - @ApiModelProperty(value = "用户id") - private String id; + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; @NotBlank(message = "账号不能为空") @ApiModelProperty(value = "账户名称") @@ -73,7 +74,7 @@ public class SysUser extends BaseEntity implements Serializable { private String email; @ApiModelProperty(value = "用户组id") - private String groupId; + private Integer groupId; @TableField(exist = false) @ApiModelProperty(value = "用户组名称") @@ -90,10 +91,10 @@ public class SysUser extends BaseEntity implements Serializable { private Integer deleted; @ApiModelProperty(value = "创建人") - private String createId; + private Integer createId; @ApiModelProperty(value = "更新人") - private String updateId; + private Integer updateId; @ApiModelProperty(value = "创建来源(1.web 2.android 3.ios )") private Integer createWhere; @@ -119,11 +120,11 @@ public class SysUser extends BaseEntity implements Serializable { @TableField(exist = false) @ApiModelProperty(value = "角色id") - private List roleIds; + private List roleIds; @TableField(exist = false) @ApiModelProperty(value = "组织架构id(多个部门id)") - private List deptArchitectureId; + private List deptArchitectureId; @TableField(exist = false) @ApiModelProperty("随机数") diff --git a/src/main/java/com/huoran/iasf/entity/SysUserRole.java b/src/main/java/com/huoran/iasf/entity/SysUserRole.java index 7764975..8bc653f 100644 --- a/src/main/java/com/huoran/iasf/entity/SysUserRole.java +++ b/src/main/java/com/huoran/iasf/entity/SysUserRole.java @@ -1,8 +1,10 @@ package com.huoran.iasf.entity; import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; @@ -17,12 +19,13 @@ import java.util.Date; */ @Data public class SysUserRole implements Serializable { - @TableId - private String id; + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; - private String userId; + private Integer userId; - private String roleId; + private Integer roleId; @TableField(fill = FieldFill.INSERT) private Date createTime; diff --git a/src/main/java/com/huoran/iasf/entity/UserDept.java b/src/main/java/com/huoran/iasf/entity/UserDept.java index 43cd785..2d12239 100644 --- a/src/main/java/com/huoran/iasf/entity/UserDept.java +++ b/src/main/java/com/huoran/iasf/entity/UserDept.java @@ -30,10 +30,10 @@ public class UserDept implements Serializable { private Integer id; @ApiModelProperty(value = "用户员工id") - private String userId; + private Integer userId; @ApiModelProperty(value = "部门id") - private String deptId; + private Integer deptId; @ApiModelProperty(value = "创建时间") @TableField(fill = FieldFill.INSERT) diff --git a/src/main/java/com/huoran/iasf/mapper/SysRoleDeptMapper.java b/src/main/java/com/huoran/iasf/mapper/SysRoleDeptMapper.java deleted file mode 100644 index e55414c..0000000 --- a/src/main/java/com/huoran/iasf/mapper/SysRoleDeptMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.huoran.iasf.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.huoran.iasf.entity.SysRoleDeptEntity; - -/** - * 角色部门 - * - * @author cheney - * @email *****@mail.com - * @date 2020-09-27 17:30:15 - */ -public interface SysRoleDeptMapper extends BaseMapper { - -} diff --git a/src/main/java/com/huoran/iasf/service/HttpSessionService.java b/src/main/java/com/huoran/iasf/service/HttpSessionService.java index def61e7..703b563 100644 --- a/src/main/java/com/huoran/iasf/service/HttpSessionService.java +++ b/src/main/java/com/huoran/iasf/service/HttpSessionService.java @@ -130,9 +130,9 @@ public class HttpSessionService { * * @return UserId */ - public String getCurrentUserId() { + public Integer getCurrentUserId() { if (getCurrentSession() != null) { - return getCurrentSession().getString(Constant.USERID_KEY); + return Integer.parseInt(getCurrentSession().getString(Constant.USERID_KEY)); } else { return null; } @@ -159,16 +159,16 @@ public class HttpSessionService { /** * 使用户的token失效 */ - public void abortUserById(String userId) { + public void abortUserById(Integer userId) { redisService.delKeys(userTokenPrefix + "*#" + userId); } /** * 使多个用户的token失效 */ - public void abortUserByUserIds(List userIds) { + public void abortUserByUserIds(List userIds) { if (CollectionUtils.isNotEmpty(userIds)) { - for (String id : userIds) { + for (Integer id : userIds) { redisService.delKeys(userTokenPrefix + "*#" + id); } @@ -180,7 +180,7 @@ public class HttpSessionService { * * @param userId userId */ - public void refreshUerId(String userId) { + public void refreshUerId(Integer userId) { redisService.delKeys(userTokenPrefix + "*#" + userId); @@ -207,8 +207,8 @@ public class HttpSessionService { * * @param roleId roleId */ - public void refreshRolePermission(String roleId) { - List userIds = userRoleService.getUserIdsByRoleId(roleId); + public void refreshRolePermission(Integer roleId) { + List userIds = userRoleService.getUserIdsByRoleId(roleId); if (!CollectionUtils.isEmpty(userIds)) { userIds.parallelStream().forEach(this::refreshUerId); } @@ -219,8 +219,8 @@ public class HttpSessionService { * * @param permissionId permissionId */ - public void refreshPermission(String permissionId) { - List userIds = permissionService.getUserIdsById(permissionId); + public void refreshPermission(Integer permissionId) { + List userIds = permissionService.getUserIdsById(permissionId); if (!CollectionUtils.isEmpty(userIds)) { userIds.parallelStream().forEach(this::refreshUerId); } @@ -254,11 +254,11 @@ public class HttpSessionService { } - private List getRolesByUserId(String userId) { + private List getRolesByUserId(Integer userId) { return roleService.getRoleNames(userId); } - private Set getPermissionsByUserId(String userId) { + private Set getPermissionsByUserId(Integer userId) { return permissionService.getPermissionsByUserId(userId); } diff --git a/src/main/java/com/huoran/iasf/service/PermissionService.java b/src/main/java/com/huoran/iasf/service/PermissionService.java index aadae58..c176309 100644 --- a/src/main/java/com/huoran/iasf/service/PermissionService.java +++ b/src/main/java/com/huoran/iasf/service/PermissionService.java @@ -22,14 +22,14 @@ public interface PermissionService extends IService { * @param userId userId * @return 权限 */ - List getPermission(String userId); + List getPermission(Integer userId); /** * 删除权限 * * @param permissionId 权限id */ - void deleted(String permissionId); + void deleted(Integer permissionId); /** * 获取所有 @@ -44,7 +44,7 @@ public interface PermissionService extends IService { * @param userId userId * @return Set */ - Set getPermissionsByUserId(String userId); + Set getPermissionsByUserId(Integer userId); /** * 根据userId获取权限树 @@ -52,7 +52,7 @@ public interface PermissionService extends IService { * @param userId * @return List */ - List permissionTreeList(String userId); + List permissionTreeList(Integer userId); /** * 根据权限树 @@ -67,7 +67,7 @@ public interface PermissionService extends IService { * @param permissionId permissionId * @return List */ - List selectAllMenuByTree(String permissionId); + List selectAllMenuByTree(Integer permissionId); /** @@ -76,7 +76,7 @@ public interface PermissionService extends IService { * @param permissionId permissionId * @return List */ - List getUserIdsById(String permissionId); + List getUserIdsById(Integer permissionId); /** * 更新 @@ -85,5 +85,5 @@ public interface PermissionService extends IService { */ void updatePermission(SysPermission vo); - List permissionList(String id); + List permissionList(Integer id); } diff --git a/src/main/java/com/huoran/iasf/service/RoleService.java b/src/main/java/com/huoran/iasf/service/RoleService.java index c291f7b..f9478cc 100644 --- a/src/main/java/com/huoran/iasf/service/RoleService.java +++ b/src/main/java/com/huoran/iasf/service/RoleService.java @@ -33,7 +33,7 @@ public interface RoleService extends IService { * * @param id id */ - void deletedRole(String id); + void deletedRole(Integer id); /** * 根据userId获取绑定的角色 @@ -41,7 +41,7 @@ public interface RoleService extends IService { * @param userId userId * @return List */ - List getRoleInfoByUserId(String userId); + List getRoleInfoByUserId(Integer userId); /** * 根据userId获取绑定的角色名 @@ -49,7 +49,7 @@ public interface RoleService extends IService { * @param userId userId * @return List */ - List getRoleNames(String userId); + List getRoleNames(Integer userId); boolean checkDeptRepeat(SysRole vo); } diff --git a/src/main/java/com/huoran/iasf/service/UserRoleService.java b/src/main/java/com/huoran/iasf/service/UserRoleService.java index 5a8dfca..d0de4d7 100644 --- a/src/main/java/com/huoran/iasf/service/UserRoleService.java +++ b/src/main/java/com/huoran/iasf/service/UserRoleService.java @@ -21,7 +21,7 @@ public interface UserRoleService extends IService { * @param userId userId * @return List */ - List getRoleIdsByUserId(String userId); + List getRoleIdsByUserId(Integer userId); /** * 用户绑定角色 @@ -36,5 +36,5 @@ public interface UserRoleService extends IService { * @param roleId roleId * @return List */ - List getUserIdsByRoleId(String roleId); + List getUserIdsByRoleId(Integer roleId); } diff --git a/src/main/java/com/huoran/iasf/service/UserService.java b/src/main/java/com/huoran/iasf/service/UserService.java index bdb47ad..b187c69 100644 --- a/src/main/java/com/huoran/iasf/service/UserService.java +++ b/src/main/java/com/huoran/iasf/service/UserService.java @@ -3,10 +3,11 @@ package com.huoran.iasf.service; import com.baomidou.mybatisplus.extension.service.IService; import com.huoran.iasf.common.utils.R; import com.huoran.iasf.entity.SysUser; +import com.huoran.iasf.vo.CheckVo; +import com.huoran.iasf.vo.req.UpdatePhoneOrEmailReq; import com.huoran.iasf.vo.req.UserListReq; import com.huoran.iasf.vo.resp.LoginRespVO; import com.huoran.iasf.vo.resp.UserListResp; -import com.huoran.iasf.vo.resp.UserOwnRoleRespVO; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; @@ -24,62 +25,34 @@ public interface UserService extends IService { /** * 注册 - * - * @param vo vo */ void register(SysUser vo); /** * 登陆 - * - * @param vo vo - * @return LoginRespVO */ LoginRespVO login(SysUser vo); /** * 更新用户信息 - * - * @param vo vo */ void updateUserInfo(SysUser vo); /** * 分页 - * - * @return IPage */ R pageInfo(UserListReq userListReq); /** * 添加用户 - * - * @param vo vo */ void addUser(SysUser vo); /** * 修改密码 - * - * @param vo vo */ void updatePwd(SysUser vo); - /** - * 根据userid获取绑定角色 - * - * @param userId userId - * @return UserOwnRoleRespVO - */ - UserOwnRoleRespVO getUserOwnRole(String userId); - - /** - * 修改自己信息 - * - * @param vo vo - */ - void updateUserInfoMy(SysUser vo); - UserListResp detailInfo(String id); R resetPwd(String userId); @@ -87,4 +60,10 @@ public interface UserService extends IService { Map importStaff(MultipartFile file); void exportFailureRecord(HttpServletResponse response, String exportCode) throws IOException; + + R sendCheckPhoneCode(CheckVo checkVo); + + R updatePhoneOrEmail(UpdatePhoneOrEmailReq updatePhoneOrEmailReq); + + R updateUserAvatars(String userId, MultipartFile file); } diff --git a/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java index 42496f2..b7302d5 100644 --- a/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java @@ -67,7 +67,7 @@ public class DeptServiceImpl extends ServiceImpl impleme QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("name", sysDept.getName()); queryWrapper.eq("pid", sysDept.getPid()); - if (StrUtil.isNotEmpty(sysDept.getId())) { + if (StrUtil.isNotEmpty(sysDept.getId().toString())) { queryWrapper.last(" and id != " + sysDept.getId()); } List sysDepts = baseMapper.selectList(queryWrapper); @@ -173,7 +173,7 @@ public class DeptServiceImpl extends ServiceImpl impleme return list; } - private List getChild(String id, List all) { + private List getChild(Integer id, List all) { List list = new ArrayList<>(); for (SysDept sysDept : all) { if (sysDept.getPid().equals(id)) { diff --git a/src/main/java/com/huoran/iasf/service/impl/PermissionServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/PermissionServiceImpl.java index a2c55c7..71d08fc 100644 --- a/src/main/java/com/huoran/iasf/service/impl/PermissionServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/PermissionServiceImpl.java @@ -56,8 +56,8 @@ public class PermissionServiceImpl extends ServiceImpl getPermission(String userId) { - List roleIds = userRoleService.getRoleIdsByUserId(userId); + public List getPermission(Integer userId) { + List roleIds = userRoleService.getRoleIdsByUserId(userId); if (CollectionUtils.isEmpty(roleIds)) { return null; } @@ -77,9 +77,9 @@ public class PermissionServiceImpl extends ServiceImpl userIds = getUserIdsById(permissionId); + List userIds = getUserIdsById(permissionId); SysPermission sysPermission = sysPermissionMapper.selectById(permissionId); if (null == sysPermission) { log.error("传入 的 id:{}不合法", permissionId); @@ -102,7 +102,7 @@ public class PermissionServiceImpl extends ServiceImpl permissionList(String userId) { + public List permissionList(Integer userId) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("user_id",userId); List userRoles = userRoleService.list(queryWrapper); @@ -146,7 +146,7 @@ public class PermissionServiceImpl extends ServiceImpl getPermissionsByUserId(String userId) { + public Set getPermissionsByUserId(Integer userId) { List list = getPermission(userId); Set permissions = new HashSet<>(); @@ -166,7 +166,7 @@ public class PermissionServiceImpl extends ServiceImpl permissionTreeList(String userId) { + public List permissionTreeList(Integer userId) { List list = getPermission(userId); return getTree(list, true); } @@ -200,7 +200,7 @@ public class PermissionServiceImpl extends ServiceImpl getChildAll(String id, List all) { + private List getChildAll(Integer id, List all) { List list = new ArrayList<>(); for (SysPermission sysPermission : all) { @@ -218,7 +218,7 @@ public class PermissionServiceImpl extends ServiceImpl getChildExcBtn(String id, List all) { + private List getChildExcBtn(Integer id, List all) { List list = new ArrayList<>(); for (SysPermission sysPermission : all) { @@ -289,7 +289,7 @@ public class PermissionServiceImpl extends ServiceImpl selectAllMenuByTree(String permissionId) { + public List selectAllMenuByTree(Integer permissionId) { List list = selectAll(); if (!CollectionUtils.isEmpty(list) && !StringUtils.isEmpty(permissionId)) { @@ -303,7 +303,7 @@ public class PermissionServiceImpl extends ServiceImpl result = new ArrayList<>(); //新增顶级目录是为了方便添加一级目录 PermissionRespNode respNode = new PermissionRespNode(); - respNode.setId("0"); + respNode.setId(0); respNode.setName("默认顶级菜单"); // respNode.setSpread(true); respNode.setChildren(getTree(list, true)); @@ -312,7 +312,7 @@ public class PermissionServiceImpl extends ServiceImpl roleIds = rolePermissionService.listObjs(Wrappers.lambdaQuery().select(SysRolePermission::getRoleId).eq(SysRolePermission::getPermissionId, id)); diff --git a/src/main/java/com/huoran/iasf/service/impl/RolePermissionServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/RolePermissionServiceImpl.java index 99697d2..f768982 100644 --- a/src/main/java/com/huoran/iasf/service/impl/RolePermissionServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/RolePermissionServiceImpl.java @@ -23,7 +23,7 @@ public class RolePermissionServiceImpl extends ServiceImpl list = new ArrayList<>(); - for (String permissionId : vo.getPermissionIds()) { + for (Integer permissionId : vo.getPermissionIds()) { SysRolePermission sysRolePermission = new SysRolePermission(); sysRolePermission.setPermissionId(permissionId); sysRolePermission.setRoleId(vo.getRoleId()); diff --git a/src/main/java/com/huoran/iasf/service/impl/RoleServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/RoleServiceImpl.java index be621ca..388e293 100644 --- a/src/main/java/com/huoran/iasf/service/impl/RoleServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/RoleServiceImpl.java @@ -102,9 +102,9 @@ public class RoleServiceImpl extends ServiceImpl impleme @Transactional(rollbackFor = Exception.class) @Override - public void deletedRole(String id) { + public void deletedRole(Integer id) { //获取关联userId - List userIds = userRoleService.getUserIdsByRoleId(id); + List userIds = userRoleService.getUserIdsByRoleId(id); //删除角色 sysRoleMapper.deleteById(id); //删除角色权限关联 @@ -118,9 +118,9 @@ public class RoleServiceImpl extends ServiceImpl impleme } @Override - public List getRoleInfoByUserId(String userId) { + public List getRoleInfoByUserId(Integer userId) { - List roleIds = userRoleService.getRoleIdsByUserId(userId); + List roleIds = userRoleService.getRoleIdsByUserId(userId); if (CollectionUtils.isEmpty(roleIds)) { return null; } @@ -128,7 +128,7 @@ public class RoleServiceImpl extends ServiceImpl impleme } @Override - public List getRoleNames(String userId) { + public List getRoleNames(Integer userId) { List sysRoles = getRoleInfoByUserId(userId); if (CollectionUtils.isEmpty(sysRoles)) { return null; @@ -140,7 +140,7 @@ public class RoleServiceImpl extends ServiceImpl impleme public boolean checkDeptRepeat(SysRole vo) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("name", vo.getName()); - if (StrUtil.isNotEmpty(vo.getId())) { + if (StrUtil.isNotEmpty(vo.getId().toString())) { queryWrapper.last(" and id != " + vo.getId()); } List sysRoles = baseMapper.selectList(queryWrapper); diff --git a/src/main/java/com/huoran/iasf/service/impl/SysFilesServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysFilesServiceImpl.java index 3e620af..6b7a4e3 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysFilesServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysFilesServiceImpl.java @@ -103,7 +103,6 @@ public class SysFilesServiceImpl extends ServiceImpl implements IService { - - -} \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/service/impl/UserRoleServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/UserRoleServiceImpl.java index 8d207e2..dbbbd14 100644 --- a/src/main/java/com/huoran/iasf/service/impl/UserRoleServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/UserRoleServiceImpl.java @@ -28,7 +28,7 @@ public class UserRoleServiceImpl extends ServiceImpl queryWrapper = Wrappers.lambdaQuery().select(SysUserRole::getRoleId).eq(SysUserRole::getUserId, userId); return sysUserRoleMapper.selectObjs(queryWrapper); } @@ -40,7 +40,7 @@ public class UserRoleServiceImpl extends ServiceImpl list = new ArrayList<>(); - for (String roleId : vo.getRoleIds()) { + for (Integer roleId : vo.getRoleIds()) { SysUserRole sysUserRole = new SysUserRole(); sysUserRole.setUserId(vo.getUserId()); sysUserRole.setRoleId(roleId); @@ -52,7 +52,7 @@ public class UserRoleServiceImpl extends ServiceImpllambdaQuery().select(SysUserRole::getUserId).eq(SysUserRole::getRoleId, roleId)); } } diff --git a/src/main/java/com/huoran/iasf/service/impl/UserServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/UserServiceImpl.java index 645993d..83e99c2 100644 --- a/src/main/java/com/huoran/iasf/service/impl/UserServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/UserServiceImpl.java @@ -16,23 +16,19 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.Maps; import com.huoran.iasf.common.exception.BusinessException; import com.huoran.iasf.common.exception.code.BaseResponseCode; -import com.huoran.iasf.common.utils.ExcelImportHelper; -import com.huoran.iasf.common.utils.ExcelStyleUtil; -import com.huoran.iasf.common.utils.PasswordUtils; -import com.huoran.iasf.common.utils.R; +import com.huoran.iasf.common.utils.*; import com.huoran.iasf.entity.*; import com.huoran.iasf.mapper.SysDeptMapper; import com.huoran.iasf.mapper.SysUserMapper; import com.huoran.iasf.mapper.UserDeptMapper; import com.huoran.iasf.mapper.UserGroupMapper; import com.huoran.iasf.service.*; +import com.huoran.iasf.vo.CheckVo; import com.huoran.iasf.vo.ImportUserFailureVo; -import com.huoran.iasf.vo.req.ExcelImpUserReq; -import com.huoran.iasf.vo.req.UserListReq; -import com.huoran.iasf.vo.req.UserRoleOperationReqVO; +import com.huoran.iasf.vo.UEditorResultVO; +import com.huoran.iasf.vo.req.*; import com.huoran.iasf.vo.resp.LoginRespVO; import com.huoran.iasf.vo.resp.UserListResp; -import com.huoran.iasf.vo.resp.UserOwnRoleRespVO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.apache.poi.ss.usermodel.Workbook; @@ -78,6 +74,10 @@ public class UserServiceImpl extends ServiceImpl impleme @Resource private SysDeptMapper sysDeptMapper; + + @Resource + private SysFilesService sysFilesService; + @Resource private HttpSessionService httpSessionService; @@ -92,8 +92,6 @@ public class UserServiceImpl extends ServiceImpl impleme @Value("${spring.redis.allowMultipleLogin}") private Boolean allowMultipleLogin; - @Value("${spring.profiles.active}") - private String env; @Override public void register(SysUser sysUser) { @@ -184,18 +182,27 @@ public class UserServiceImpl extends ServiceImpl impleme httpSessionService.abortUserById(vo.getId()); } - if (!StringUtils.isEmpty(vo.getPassword())) { + if (StringUtils.isNotEmpty(vo.getPassword())) { String newPassword = PasswordUtils.encode(vo.getPassword(), sysUser.getSalt()); vo.setPassword(newPassword); } else { vo.setPassword(null); } + + if (StringUtils.isNotEmpty(vo.getEmail())) { + vo.setEmail(vo.getEmail()); + } + + if (StringUtils.isNotEmpty(vo.getPhone())) { + vo.setEmail(vo.getPhone()); + } + //删除所有部门 userDeptMapper.delete(Wrappers.lambdaQuery().eq(UserDept::getUserId, vo.getId())); //更新部门 if (!CollectionUtils.isEmpty(vo.getDeptArchitectureId())) { - List deptArchitectureId = vo.getDeptArchitectureId(); - for (String deptId : deptArchitectureId) { + List deptArchitectureId = vo.getDeptArchitectureId(); + for (Integer deptId : deptArchitectureId) { UserDept userDept = new UserDept(); userDept.setUserId(vo.getId()); userDept.setDeptId(deptId); @@ -220,25 +227,6 @@ public class UserServiceImpl extends ServiceImpl impleme } - @Override - public void updateUserInfoMy(SysUser vo) { - - - SysUser user = sysUserMapper.selectById(httpSessionService.getCurrentUserId()); - if (null == user) { - throw new BusinessException(BaseResponseCode.DATA_ERROR); - } - if (!StringUtils.isEmpty(vo.getPassword())) { - String newPassword = PasswordUtils.encode(vo.getPassword(), user.getSalt()); - vo.setPassword(newPassword); - } else { - vo.setPassword(null); - } - vo.setUpdateId(httpSessionService.getCurrentUserId()); - sysUserMapper.updateById(vo); - - } - @Override public UserListResp detailInfo(String id) { return baseMapper.detailInfo(id); @@ -277,8 +265,8 @@ public class UserServiceImpl extends ServiceImpl impleme sysUserMapper.insert(vo); if (!CollectionUtils.isEmpty(vo.getDeptArchitectureId())) { - List deptArchitectureId = vo.getDeptArchitectureId(); - for (String deptId : deptArchitectureId) { + List deptArchitectureId = vo.getDeptArchitectureId(); + for (Integer deptId : deptArchitectureId) { UserDept userDept = new UserDept(); userDept.setUserId(vo.getId()); userDept.setDeptId(deptId); @@ -315,16 +303,6 @@ public class UserServiceImpl extends ServiceImpl impleme } - @Override - public UserOwnRoleRespVO getUserOwnRole(String userId) { - List roleIdsByUserId = userRoleService.getRoleIdsByUserId(userId); - List list = roleService.list(); - UserOwnRoleRespVO vo = new UserOwnRoleRespVO(); - vo.setAllRole(list); - vo.setOwnRoles(roleIdsByUserId); - return vo; - } - @Override @Transactional public Map importStaff(MultipartFile file) { @@ -389,7 +367,7 @@ public class UserServiceImpl extends ServiceImpl impleme } //账号id - String usernameId = "0"; + Integer usernameId = 0; vo1.setIndex(ii); //检验姓名 @@ -426,7 +404,7 @@ public class UserServiceImpl extends ServiceImpl impleme } } - List roleIds = new ArrayList<>(); + List roleIds = new ArrayList<>(); //检验角色 if ("".equals(getRoleName)) { @@ -545,7 +523,7 @@ public class UserServiceImpl extends ServiceImpl impleme vo1.setEmail(getEmail); } - ArrayList architectureIds = new ArrayList<>(); + ArrayList architectureIds = new ArrayList<>(); //检验所在部门 if ("".equals(dept)) { ++countNum; @@ -574,9 +552,9 @@ public class UserServiceImpl extends ServiceImpl impleme }else { //保存架构id Object architectureId = hashMap.get("architectureId"); - String id = "0"; + Integer id = 0; if (architectureId!=null){ - id = (String) architectureId; + id = (Integer)architectureId; architectureIds.add(id); } } @@ -598,9 +576,9 @@ public class UserServiceImpl extends ServiceImpl impleme }else { //保存架构id Object architectureId = hashMap.get("architectureId"); - String id = "0"; + Integer id = 0; if (architectureId!=null){ - id = (String) architectureId; + id = (Integer) architectureId; architectureIds.add(id); } } @@ -629,12 +607,12 @@ public class UserServiceImpl extends ServiceImpl impleme vo.setStatus(1); vo.setCreateWhere(1); if (groupId!=0){ - vo.setGroupId(groupId.toString()); + vo.setGroupId(groupId); } sysUserMapper.insert(vo); if (!CollectionUtils.isEmpty(architectureIds)) { - for (String deptId : architectureIds) { + for (Integer deptId : architectureIds) { UserDept userDept = new UserDept(); userDept.setUserId(vo.getId()); userDept.setDeptId(deptId); @@ -653,11 +631,11 @@ public class UserServiceImpl extends ServiceImpl impleme List userDepts = userDeptMapper. selectList(new QueryWrapper().eq("user_id", usernameId)); - ArrayList staffDepartmentIds = new ArrayList<>(); + ArrayList staffDepartmentIds = new ArrayList<>(); for ( UserDept userDept : userDepts) { staffDepartmentIds.add(userDept.getDeptId()); } - for (String architectureId : architectureIds) { + for (Integer architectureId : architectureIds) { if (!staffDepartmentIds.contains(architectureId)){ UserDept userDept = new UserDept(); userDept.setUserId(usernameId); @@ -709,7 +687,7 @@ public class UserServiceImpl extends ServiceImpl impleme * 组织架构判重,返回下一层级的父id * */ - public String checkArchitectureRepeat(String name ,String pid){ + public Integer checkArchitectureRepeat(String name ,Integer pid){ QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("name",name).eq("pid",pid); SysDept sysDept = sysDeptMapper.selectOne(queryWrapper); @@ -741,7 +719,7 @@ public class UserServiceImpl extends ServiceImpl impleme SysDept sysDept = sysDeptMapper.selectOne(queryWrapper1); if (sysDept == null) { //为空表示不存在该部门,一级部门不存在,表示子级部门都能直接新增,达底端返回部门id - String pid = "0"; + Integer pid = 0; for (int j = 0; j < split.length; j++) { SysDept sysDept1 = new SysDept(); sysDept1.setName(split[j]); @@ -757,11 +735,11 @@ public class UserServiceImpl extends ServiceImpl impleme } } } else { - String nextLevelPid = sysDept.getId(); + Integer nextLevelPid = sysDept.getId(); //存在一级部门,循环查询下一层级,存在则继续向下判断,否则进行新增,到达底端返回部门id int pid = 1; for (int j = 1; j < split.length; j++) { - String nextPid = checkArchitectureRepeat(split[j],nextLevelPid); + Integer nextPid = checkArchitectureRepeat(split[j],nextLevelPid); //都存在,最后一次循环返回部门id if (split.length-1==j){ map.put("architectureId",nextPid); @@ -866,4 +844,102 @@ public class UserServiceImpl extends ServiceImpl impleme exportParams.setStyle(ExcelStyleUtil.class); workbook.write(response.getOutputStream()); } + + @Override + public R sendCheckPhoneCode(CheckVo checkVo) { + boolean re = false; + boolean isSend; + String phoneOrEmail = ""; + + String msg = ""; + if (checkVo.getTypes().equals(1)) {//邮箱验证码 + phoneOrEmail = checkVo.getEmail(); + Integer count = baseMapper.selectCount(Wrappers.lambdaQuery().eq(SysUser::getEmail, checkVo.getEmail())); + if (count>0){ + msg = "邮箱已存在!"; + re = true; + } + } else {//手机验证码 + phoneOrEmail = checkVo.getPhone(); + Integer count = baseMapper.selectCount(Wrappers.lambdaQuery().eq(SysUser::getPhone, checkVo.getPhone())); + if (count>0){ + msg = "手机号已存在!"; + re = true; + } + } + + if (re) { + return R.fail(msg); + } + + //先从redis中查询该手机号的验证码是否过期,未过期直接返回发送成功,防重放 + //为了保证该手机号5分钟内在其他场景下内正常使用,存入的key需要与短信模板进行拼接 + String key = org.apache.commons.lang3.StringUtils.join(phoneOrEmail, SMSTemplate.AUTHENTICATION_CODE); + System.out.println(key); + String code = stringRedisTemplate.opsForValue().get(key); + if (!StringUtils.isEmpty(code)) { + return R.success("验证码已发,请勿重复操作!"); + } + code = RandomUtil.getSixBitRandom(); + Map param = new HashMap<>(); + param.put("code", code); + if (checkVo.getTypes().equals(1)) {//邮箱验证码 + isSend = EmailUtils.sendEmail(phoneOrEmail, code); + } else {//手机验证码 + isSend = SendSMSUtils.send(phoneOrEmail, SMSTemplate.AUTHENTICATION_CODE, param); + } + + if (isSend) { + stringRedisTemplate.opsForValue().set(key, code, 5, TimeUnit.MINUTES); + CheckVo checkVo1 = new CheckVo(); + checkVo1.setOpener(key); + return R.success(checkVo1); + } else { + return R.fail("短信发送失败,请稍后重试!"); + } + } + + @Override + public R updatePhoneOrEmail(UpdatePhoneOrEmailReq updatePhoneOrEmailReq) { + String phoneOrEmail = ""; + SysUser user = new SysUser(); + user.setId(updatePhoneOrEmailReq.getUserId()); + if (updatePhoneOrEmailReq.getTypes().equals(1)) {//邮箱验证码 + phoneOrEmail = updatePhoneOrEmailReq.getEmail(); + user.setEmail(updatePhoneOrEmailReq.getEmail()); + } else {//手机验证码 + phoneOrEmail = updatePhoneOrEmailReq.getPhone(); + user.setPhone(updatePhoneOrEmailReq.getPhone()); + } + //从redis中查询该手机号的验证码是否过期 + //为了保证该手机号5分钟内在其他场景下内正常使用,存入的key需要与短信模板进行拼接 + String key = org.apache.commons.lang3.StringUtils.join(phoneOrEmail, SMSTemplate.AUTHENTICATION_CODE); + System.out.println(key); + String code = stringRedisTemplate.opsForValue().get(key); + if (StringUtils.isEmpty(code)) { + return R.fail("验证码已过期!"); + } + if (code.equals(updatePhoneOrEmailReq.getCode())){ + //更新用户手机号 + baseMapper.updateById(user); + return R.success(); + } + return R.fail("验证码错误!"); + } + + @Override + public R updateUserAvatars(String userId, MultipartFile file) { + SysUser sysUser = baseMapper.selectById(userId); + + FileParameters fileParameters = new FileParameters(); + fileParameters.setQuote("个人资料"); + fileParameters.setSite("管理后台"); + fileParameters.setUploader(sysUser.getRealName()); + UEditorResultVO uEditorResultVO = sysFilesService.saveFile(file, fileParameters); + + sysUser.setUserAvatars(uEditorResultVO.getUrl()); + int update = baseMapper.updateById(sysUser); + + return update > 0 ? R.success(uEditorResultVO.getUrl()) : R.fail("更新失败"); + } } diff --git a/src/main/java/com/huoran/iasf/vo/CheckVo.java b/src/main/java/com/huoran/iasf/vo/CheckVo.java new file mode 100644 index 0000000..fe2f9ac --- /dev/null +++ b/src/main/java/com/huoran/iasf/vo/CheckVo.java @@ -0,0 +1,37 @@ +package com.huoran.iasf.vo; + +/** + * @description + * @author: Mr.JK + * @create: 2021-07-05 18:25 + **/ + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + + +@Data +@Accessors(chain = true) +@ApiModel(value = "CheckVo",description = "验证码校验参数") +public class CheckVo implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("用户的邮箱地址") + private String email; + + @ApiModelProperty("用户电话号码") + private String phone; + + @ApiModelProperty("验证码类型(1邮箱验证码,2手机验证码)") + private Integer types; + + @ApiModelProperty(value = "验证key") + private String opener; + +} diff --git a/src/main/java/com/huoran/iasf/vo/req/RolePermissionOperationReqVO.java b/src/main/java/com/huoran/iasf/vo/req/RolePermissionOperationReqVO.java index 7845f6d..7453e9b 100644 --- a/src/main/java/com/huoran/iasf/vo/req/RolePermissionOperationReqVO.java +++ b/src/main/java/com/huoran/iasf/vo/req/RolePermissionOperationReqVO.java @@ -18,8 +18,8 @@ import java.util.List; public class RolePermissionOperationReqVO { @ApiModelProperty(value = "角色id") @NotBlank(message = "角色id不能为空") - private String roleId; + private Integer roleId; @ApiModelProperty(value = "菜单权限集合") @NotEmpty(message = "菜单权限集合不能为空") - private List permissionIds; + private List permissionIds; } diff --git a/src/main/java/com/huoran/iasf/vo/req/UpdatePhoneOrEmailReq.java b/src/main/java/com/huoran/iasf/vo/req/UpdatePhoneOrEmailReq.java new file mode 100644 index 0000000..240f762 --- /dev/null +++ b/src/main/java/com/huoran/iasf/vo/req/UpdatePhoneOrEmailReq.java @@ -0,0 +1,30 @@ +package com.huoran.iasf.vo.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author chen + * @DATE 2022/8/29 15:31 + * @Version 1.0 + */ +@Data +public class UpdatePhoneOrEmailReq { + @ApiModelProperty("用户id") + private Integer userId; + + @ApiModelProperty("用户的邮箱地址") + private String email; + + @ApiModelProperty("用户电话号码") + private String phone; + + @ApiModelProperty("验证码类型(1邮箱验证码,2手机验证码)") + private Integer types; + + @ApiModelProperty("用户输入的验证码") + private String code; + + @ApiModelProperty(value = "验证key") + private String opener; +} diff --git a/src/main/java/com/huoran/iasf/vo/req/UserRoleOperationReqVO.java b/src/main/java/com/huoran/iasf/vo/req/UserRoleOperationReqVO.java index 600d009..06c2446 100644 --- a/src/main/java/com/huoran/iasf/vo/req/UserRoleOperationReqVO.java +++ b/src/main/java/com/huoran/iasf/vo/req/UserRoleOperationReqVO.java @@ -19,9 +19,9 @@ public class UserRoleOperationReqVO { @ApiModelProperty(value = "用户id") @NotBlank(message = "用户id不能为空") - private String userId; + private Integer userId; @ApiModelProperty(value = "角色id集合") @NotEmpty(message = "角色id集合不能为空") - private List roleIds; + private List roleIds; } diff --git a/src/main/java/com/huoran/iasf/vo/resp/PermissionRespNode.java b/src/main/java/com/huoran/iasf/vo/resp/PermissionRespNode.java index 5f3c667..acb72a1 100644 --- a/src/main/java/com/huoran/iasf/vo/resp/PermissionRespNode.java +++ b/src/main/java/com/huoran/iasf/vo/resp/PermissionRespNode.java @@ -15,7 +15,7 @@ import java.util.List; @Data public class PermissionRespNode { @ApiModelProperty(value = "id") - private String id; + private Integer id; @ApiModelProperty(value = "菜单权限名称") private String name; diff --git a/src/main/resources/whiteList.properties b/src/main/resources/whiteList.properties new file mode 100644 index 0000000..0bfd774 --- /dev/null +++ b/src/main/resources/whiteList.properties @@ -0,0 +1,2 @@ +whiteList=/iasf/sys/user/login,\ + /iasf/sys/exportFailure \ No newline at end of file diff --git a/src/test/java/com/company/project/CodeGenerator.java b/src/test/java/com/company/project/CodeGenerator.java index ceba114..6c10d7d 100644 --- a/src/test/java/com/company/project/CodeGenerator.java +++ b/src/test/java/com/company/project/CodeGenerator.java @@ -41,10 +41,10 @@ public class CodeGenerator { // 3、数据源配置 DataSourceConfig dsc = new DataSourceConfig(); - dsc.setUrl("jdbc:mysql://139.9.47.170:3306/iasf?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8"); + dsc.setUrl("jdbc:mysql://127.0.0.1:3306/iasf?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8"); dsc.setDriverName("com.mysql.cj.jdbc.Driver"); dsc.setUsername("root"); - dsc.setPassword("HuoRan@2021"); + dsc.setPassword("123456"); dsc.setDbType(DbType.MYSQL); mpg.setDataSource(dsc); @@ -61,7 +61,7 @@ public class CodeGenerator { // 5、策略配置 StrategyConfig strategy = new StrategyConfig(); - strategy.setInclude("sys_user_dept"); + strategy.setInclude("sys_site"); strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略 strategy.setTablePrefix("sys_"); //生成实体时去掉表前缀