jiangping
2023-09-06 dd4e6d788efb23509248f2119137014a49452839
提交
已修改9个文件
81 ■■■■ 文件已修改
server/company/src/main/java/com/doumee/api/system/SystemController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/company/src/main/java/com/doumee/config/shiro/ShiroConfig.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/company/src/main/java/com/doumee/config/shiro/ShiroRealm.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/api/system/SystemController.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/shiro/ShiroConfig.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/shiro/ShiroRealm.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/core/utils/Constants.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/system/SystemLoginService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/system/impl/SystemLoginServiceImpl.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/company/src/main/java/com/doumee/api/system/SystemController.java
@@ -6,6 +6,7 @@
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;
@@ -41,7 +42,7 @@
    @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("退出登录")
@@ -51,7 +52,6 @@
        subject.logout();
        return ApiResponse.success(null);
    }
    @Trace(withRequestParameters = false)
    @ApiOperation("修改当前用户密码")
    @PostMapping("/updatePwd")
@@ -60,7 +60,6 @@
        systemUserBiz.updatePwd(dto);
        return ApiResponse.success(null);
    }
    @ApiOperation("获取当前登录的用户信息")
    @GetMapping("/getUserInfo")
    public ApiResponse<LoginUserInfo> getUserInfo () {
server/company/src/main/java/com/doumee/config/shiro/ShiroConfig.java
@@ -94,15 +94,8 @@
        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
server/company/src/main/java/com/doumee/config/shiro/ShiroRealm.java
@@ -77,12 +77,16 @@
        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());
server/platform/src/main/java/com/doumee/api/system/SystemController.java
@@ -6,6 +6,7 @@
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;
@@ -17,6 +18,7 @@
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;
@@ -41,7 +43,7 @@
    @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("退出登录")
server/platform/src/main/java/com/doumee/shiro/ShiroConfig.java
@@ -88,21 +88,14 @@
        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
server/platform/src/main/java/com/doumee/shiro/ShiroRealm.java
@@ -75,13 +75,14 @@
        // 根据用户名查询用户对象
        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());
server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -438,14 +438,7 @@
        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;
@@ -514,29 +507,7 @@
            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);
        }
    }
server/service/src/main/java/com/doumee/service/system/SystemLoginService.java
@@ -16,5 +16,5 @@
     * @author Eva.Caesar Liu
     * @date 2023/03/21 14:49
     */
    String loginByPassword (LoginDTO dto, HttpServletRequest request);
    String loginByPassword (LoginDTO dto,int type, HttpServletRequest request);
}
server/service/src/main/java/com/doumee/service/system/impl/SystemLoginServiceImpl.java
@@ -27,6 +27,8 @@
    @Value("${project.version}")
    private String systemVersion;
    @Value("${captcha_check}")
    private boolean captchaCheck;
    @Autowired
    private CaptchaService captchaService;
@@ -35,7 +37,7 @@
    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());
@@ -48,7 +50,9 @@
        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());