| | |
| | | import com.doumee.core.annotation.trace.Trace; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.system.dto.LoginDTO; |
| | | import com.doumee.dao.system.dto.UpdatePwdDto; |
| | | import com.doumee.service.system.SystemLoginService; |
| | |
| | | @ApiOperation("登录") |
| | | @PostMapping("/login") |
| | | public ApiResponse<String> login (@Validated @RequestBody LoginDTO dto, HttpServletRequest request) { |
| | | return ApiResponse.success(systemLoginService.loginByPassword(dto, request)); |
| | | return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.ONE, request)); |
| | | } |
| | | |
| | | @ApiOperation("退出登录") |
| | |
| | | subject.logout(); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @Trace(withRequestParameters = false) |
| | | @ApiOperation("修改当前用户密码") |
| | | @PostMapping("/updatePwd") |
| | |
| | | systemUserBiz.updatePwd(dto); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("获取当前登录的用户信息") |
| | | @GetMapping("/getUserInfo") |
| | | public ApiResponse<LoginUserInfo> getUserInfo () { |
| | |
| | | map.put("/system/logout", "anon"); |
| | | map.put("/common/captcha", "anon"); |
| | | map.put("/business/areas/*", "anon"); |
| | | map.put("/business/company/register", "anon"); |
| | | map.put("/business/labels/page","anon"); |
| | | map.put("/public/uploadPicture","anon"); |
| | | map.put("/public/uploadLocal","anon"); |
| | | map.put("/business/*/list","anon"); |
| | | map.put("/business/goods/goodsPage","anon"); |
| | | map.put("/business/goods/h5Image","anon"); |
| | | map.put("/business/goods/export","anon"); |
| | | map.put("/business/goods/listForH5","anon"); |
| | | |
| | | |
| | | // - 放行swagger |
| | |
| | | queryDto.setUsername(username); |
| | | queryDto.setDeleted(Boolean.FALSE); |
| | | SystemUser user = systemUserService.findOne(queryDto); |
| | | if(user == null){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,账号或密码不正确!"); |
| | | } |
| | | if(!Constants.equalsInteger(user.getType(),Constants.UserType.COMPANY.getKey()) && !Constants.equalsInteger(user.getType(),Constants.UserType.ZHUBO.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,账号或密码不正确!!"); |
| | | } |
| | | if(!Constants.equalsInteger(user.getStatus(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,账号信息已被禁用,如有疑问请联系系统管理员!"); |
| | | } |
| | | if (user == null) { |
| | | return null; |
| | | } |
| | | |
| | | // 获取登录用户信息 |
| | | List<SystemRole> roles = systemRoleService.findByUserId(user.getId()); |
| | | List<SystemPermission> permissions = systemPermissionService.findByUserId(user.getId()); |
| | |
| | | import com.doumee.core.annotation.trace.Trace; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.system.dto.LoginDTO; |
| | | import com.doumee.dao.system.dto.UpdatePwdDto; |
| | | import com.doumee.service.system.SystemLoginService; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.yaml.snakeyaml.scanner.Constant; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | |
| | | @ApiOperation("登录") |
| | | @PostMapping("/login") |
| | | public ApiResponse<String> login (@Validated @RequestBody LoginDTO dto, HttpServletRequest request) { |
| | | return ApiResponse.success(systemLoginService.loginByPassword(dto, request)); |
| | | return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.ZERO, request)); |
| | | } |
| | | |
| | | @ApiOperation("退出登录") |
| | |
| | | shiroFilterFactoryBean.setSecurityManager(securityManager); |
| | | Map<String, String> map = new LinkedHashMap<>(); |
| | | // 路径拦截配置 |
| | | // 路径拦截配置 |
| | | map.put("/system/dictData/companyUserRules","anon"); |
| | | map.put("/system/login", "anon"); |
| | | map.put("/system/logout", "anon"); |
| | | map.put("/common/captcha", "anon"); |
| | | map.put("/business/areas/*", "anon"); |
| | | map.put("/business/company/register", "anon"); |
| | | map.put("/business/labels/page","anon"); |
| | | map.put("/public/uploadPicture","anon"); |
| | | map.put("/public/uploadLocal","anon"); |
| | | map.put("/business/*/list","anon"); |
| | | map.put("/business/goods/goodsPage","anon"); |
| | | map.put("/business/goods/h5Image","anon"); |
| | | map.put("/business/goods/export","anon"); |
| | | map.put("/business/goods/listForH5","anon"); |
| | | |
| | | |
| | | |
| | | // - 放行swagger |
| | |
| | | // 根据用户名查询用户对象 |
| | | SystemUser queryDto = new SystemUser(); |
| | | queryDto.setUsername(username); |
| | | queryDto.setType(Constants.UserType.SYSTEM.getKey()); |
| | | queryDto.setDeleted(Boolean.FALSE); |
| | | SystemUser user = systemUserService.findOne(queryDto); |
| | | if(user == null){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,账号或密码不正确!"); |
| | | } |
| | | if(!Constants.equalsInteger(user.getStatus(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,账号信息已被禁用,如有疑问请联系系统管理员!"); |
| | | } |
| | | if (user == null) { |
| | | return null; |
| | | } |
| | | // 获取登录用户信息 |
| | | List<SystemRole> roles = systemRoleService.findByUserId(user.getId()); |
| | |
| | | |
| | | SYSTEM(0, "系统用户", "管理员",Arrays.asList(0,1,2,3,4,5,6,7,8,9,10,11)), |
| | | COMPANY(1, "企业用户", "企业",Arrays.asList(-1)), |
| | | SO_ADMIN(2, "服务机构管理员", "服务机构",Arrays.asList(-1)), |
| | | SO_CHILD(3, "服务机构子账号", "服务机构",Arrays.asList(-1)), |
| | | SD_ADMIN(4, "综合服务单位管理员", "综合服务单位",Arrays.asList(0,1,2,3,4,5,6,7,8,9,10,11)), |
| | | SD_CHILD(5, "综合服务单位子账号", "综合服务单位",Arrays.asList(0,1,2,3,4,5,6,7,8,9,10,11)), |
| | | EXPERT(6, "专家", "专家", Arrays.asList(-1)), |
| | | AREA(7, "县区用户", "县区",Arrays.asList(0,1,2,3,4,5,6,7,8,9)), |
| | | SJ(8, "市局用户", "市局",Arrays.asList(0,1,2,3,4,5,6,7,8,9,10,11)), |
| | | SJ_CHILD(9, "市局子账号", "市局子账号",Arrays.asList(0,1,2,3,4,5,6,7,8,9,10,11)), |
| | | ZHUBO(2, "主播", "主播",Arrays.asList(-1)), |
| | | ; |
| | | // 成员变量 |
| | | private String name; |
| | |
| | | return noteinfo; |
| | | } |
| | | |
| | | /** |
| | | * 不需要审批修改信息角色 |
| | | * @return |
| | | */ |
| | | public static List<Integer> getNoCheckUserChange(){ |
| | | return Arrays.asList(SO_ADMIN.key, AREA.key, SJ.key, EXPERT.key, SD_ADMIN.key,SYSTEM.key); |
| | | } |
| | | |
| | | /** |
| | | * 获取子账号类型 |
| | | * @return |
| | | */ |
| | | public static List<Integer> getSonUserType(){ |
| | | return Arrays.asList(SO_CHILD.key, SD_CHILD.key); |
| | | } |
| | | |
| | | /** |
| | | * 获取关联企业的用户类型 |
| | | * @return |
| | | */ |
| | | public static List<Integer> getHasCompanyType(){ |
| | | return Arrays.asList(COMPANY.key, SO_ADMIN.key, SD_ADMIN.key); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | * @author Eva.Caesar Liu |
| | | * @date 2023/03/21 14:49 |
| | | */ |
| | | String loginByPassword (LoginDTO dto, HttpServletRequest request); |
| | | String loginByPassword (LoginDTO dto,int type, HttpServletRequest request); |
| | | } |
| | |
| | | |
| | | @Value("${project.version}") |
| | | private String systemVersion; |
| | | @Value("${captcha_check}") |
| | | private boolean captchaCheck; |
| | | |
| | | @Autowired |
| | | private CaptchaService captchaService; |
| | |
| | | private SystemLoginLogService systemLoginLogService; |
| | | |
| | | @Override |
| | | public String loginByPassword(LoginDTO dto, HttpServletRequest request) { |
| | | public String loginByPassword(LoginDTO dto, int type,HttpServletRequest request) { |
| | | SystemLoginLog loginLog = new SystemLoginLog(); |
| | | loginLog.setLoginUsername(dto.getUsername()); |
| | | loginLog.setLoginTime(new Date()); |
| | |
| | | loginLog.setServerIp(Utils.Server.getIP()); |
| | | // 校验验证码 |
| | | try { |
| | | if(captchaCheck){ |
| | | captchaService.check(dto.getUuid(), dto.getCode()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | loginLog.setReason(e.getMessage().length() > 200 ? (e.getMessage().substring(0, 190) + "...") : e.getMessage()); |