xiaof 4 éve
szülő
commit
e7f9d2447a

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/CommonServiceImpl.java

@@ -162,7 +162,7 @@ public class CommonServiceImpl implements CommonService {
                 List<SysRole> sysRoleList = sysRoleService.list(sysRoleQueryWrapper);
                 long count = 0;
                 if (Objects.nonNull(sysRoleList) && sysRoleList.size() > 0) {
-                    count = sysRoleList.stream().filter(s -> s.getType() == RoleTypeEnum.ADMIN).count();
+                    count = sysRoleList.stream().filter(s -> s.getType() == RoleTypeEnum.ADMIN || s.getType() == RoleTypeEnum.CUSTOMER).count();
                 }
                 QueryWrapper<SysPrivilege> sysPrivilegeQueryWrapper = new QueryWrapper<>();
                 if (count > 0) {//超级系统管理员

+ 4 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/SysRoleServiceImpl.java

@@ -155,8 +155,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
     public List<SysRole> listToUser() {
         Long schoolId = null;
         try {
-            schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
-        } catch (NumberFormatException e) {
+            Object object = ServletUtil.getRequestHeaderSchoolId();
+            schoolId = Long.valueOf(object.toString());
+        } catch (Exception e){
+
         }
         QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
         Long finalSchoolId = schoolId;

+ 9 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/SysUserServiceImpl.java

@@ -20,6 +20,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import sun.misc.BASE64Encoder;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
@@ -101,7 +102,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 throw ExceptionResultEnum.ERROR.exception("用户名已存在");
             }
             SysConfig sysConfig = sysConfigService.getByKey("sys.user.initPassword");
-            user.setPassword(Md5Utils.toMd5Hex(StringUtils.isNoneBlank(sysConfig.getConfigValue()) ? sysConfig.getConfigValue() : "123456"));
+            BASE64Encoder encoder = new BASE64Encoder();
+            user.setPassword(encoder.encode(StringUtils.isNoneBlank(sysConfig.getConfigValue()) ? sysConfig.getConfigValue().getBytes() : "123456".getBytes()));
             user.setId(SystemConstant.getDbUuid());
             user.setCreateId(sysUser1.getId());
             user.setCreateTime(System.currentTimeMillis());
@@ -170,7 +172,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     @Override
     public boolean resetPassword(Long id) {
         SysConfig sysConfig = sysConfigService.getByKey("sys.user.initPassword");
-        String md5Password = Md5Utils.toMd5Hex(StringUtils.isNoneBlank(sysConfig.getConfigValue()) ? sysConfig.getConfigValue() : "123456");
+        BASE64Encoder encoder = new BASE64Encoder();
+        String md5Password = encoder.encode(StringUtils.isNoneBlank(sysConfig.getConfigValue()) ? sysConfig.getConfigValue().getBytes() : "123456".getBytes());
 
         SysUser user = this.getById(id);
         user.setPassword(md5Password);
@@ -266,6 +269,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         return this.list(queryWrapper);
     }
 
+    @Transactional
     @Override
     public boolean saveCustomer(SysUser user) {
         SysUser sysUser1 = (SysUser) ServletUtil.getRequestUser();
@@ -280,7 +284,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 throw ExceptionResultEnum.ERROR.exception("用户名已存在");
             }
             SysConfig sysConfig = sysConfigService.getByKey("sys.user.initPassword");
-            user.setPassword(Md5Utils.toMd5Hex(StringUtils.isNoneBlank(sysConfig.getConfigValue()) ? sysConfig.getConfigValue() : "123456"));
+            BASE64Encoder encoder = new BASE64Encoder();
+            user.setPassword(encoder.encode(StringUtils.isNoneBlank(sysConfig.getConfigValue()) ? sysConfig.getConfigValue().getBytes() : "123456".getBytes()));
             user.setId(SystemConstant.getDbUuid());
             user.setCreateId(sysUser1.getId());
             user.setCreateTime(System.currentTimeMillis());
@@ -312,7 +317,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
             List<SysRolePrivilege> rolePrivileges = sysRolePrivilegeService.listByRoleId(roleId);
             for (SysRolePrivilege rolePrivilege : rolePrivileges) {
                 SysUserRole userRole = new SysUserRole();
-                userRole.setUserId(sysUser.getId());
+                userRole.setUserId(user.getId());
                 userRole.setRoleId(roleId);
                 userRole.setPrivilegeId(rolePrivilege.getPrivilegeId());
                 sysUserRoleService.save(userRole);

+ 4 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/SysController.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.api;
 
+import cn.hutool.core.codec.Base64Encoder;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.annotation.BOOL;
@@ -37,6 +38,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
+import sun.misc.BASE64Encoder;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
@@ -127,7 +129,7 @@ public class SysController {
                 AuthBean authBean = commonService.getUserAuth(o.getId());
                 if (Objects.nonNull(authBean) && Objects.nonNull(authBean.getRoleList()) && authBean.getRoleList().size() > 0) {
                     Set<RoleTypeEnum> roleType = authBean.getRoleList().stream().map(s -> s.getType()).collect(Collectors.toSet());
-                    if (!roleType.contains(RoleTypeEnum.ADMIN)) {
+                    if (!roleType.contains(RoleTypeEnum.ADMIN) && !roleType.contains(RoleTypeEnum.CUSTOMER)) {
                         throw ExceptionResultEnum.ERROR.exception("学校代码为admin只允许超级管理员登录");
                     }
                 }
@@ -333,4 +335,5 @@ public class SysController {
         List<MenuDto> list = sysUserRoleService.listByUserId();
         return ResultUtil.ok(list);
     }
+
 }