|  | @@ -13,10 +13,10 @@ import com.hwrj.cloud.admin.mapper.UmsAdminMapper;
 | 
	
		
			
				|  |  |  import com.hwrj.cloud.admin.mapper.UmsAdminPermissionRelationMapper;
 | 
	
		
			
				|  |  |  import com.hwrj.cloud.admin.mapper.UmsAdminRoleRelationMapper;
 | 
	
		
			
				|  |  |  import com.hwrj.cloud.admin.model.*;
 | 
	
		
			
				|  |  | -import com.hwrj.cloud.common.exception.GlobalException;
 | 
	
		
			
				|  |  | -import com.hwrj.cloud.security.util.JwtTokenUtil;
 | 
	
		
			
				|  |  |  import com.hwrj.cloud.admin.service.UmsAdminCacheService;
 | 
	
		
			
				|  |  |  import com.hwrj.cloud.admin.service.UmsAdminService;
 | 
	
		
			
				|  |  | +import com.hwrj.cloud.common.exception.GlobalException;
 | 
	
		
			
				|  |  | +import com.hwrj.cloud.security.util.JwtTokenUtil;
 | 
	
		
			
				|  |  |  import org.slf4j.Logger;
 | 
	
		
			
				|  |  |  import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  |  import org.springframework.beans.BeanUtils;
 | 
	
	
		
			
				|  | @@ -88,6 +88,14 @@ public class UmsAdminServiceImpl implements UmsAdminService {
 | 
	
		
			
				|  |  |      public UmsAdmin register(UmsAdminParam umsAdminParam) {
 | 
	
		
			
				|  |  |          UmsAdmin umsAdmin = new UmsAdmin();
 | 
	
		
			
				|  |  |          BeanUtils.copyProperties(umsAdminParam, umsAdmin);
 | 
	
		
			
				|  |  | +        String username = umsAdminParam.getUsername();
 | 
	
		
			
				|  |  | +        username = username.toLowerCase();
 | 
	
		
			
				|  |  | +        if(username.equals("admin")){
 | 
	
		
			
				|  |  | +            Long compId = umsAdminParam.getCompId();
 | 
	
		
			
				|  |  | +            if(!StringUtils.isEmpty(compId)){
 | 
	
		
			
				|  |  | +                throw new GlobalException("超级管理员不能绑定供应商!");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          umsAdmin.setCreateTime(new Date());
 | 
	
		
			
				|  |  |          umsAdmin.setStatus(1);
 | 
	
		
			
				|  |  |          //查询是否有相同用户名的用户
 | 
	
	
		
			
				|  | @@ -96,7 +104,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
 | 
	
		
			
				|  |  |          example.createCriteria().andUsernameEqualTo(umsAdmin.getUsername());
 | 
	
		
			
				|  |  |          List<UmsAdmin> umsAdminList = adminMapper.selectByExample(example);
 | 
	
		
			
				|  |  |          if (umsAdminList.size() > 0) {
 | 
	
		
			
				|  |  | -            return null;
 | 
	
		
			
				|  |  | +            throw new GlobalException("该用户已存在!");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //将密码进行加密操作
 | 
	
		
			
				|  |  |          String encodePassword = passwordEncoder.encode(umsAdmin.getPassword());
 | 
	
	
		
			
				|  | @@ -179,7 +187,27 @@ public class UmsAdminServiceImpl implements UmsAdminService {
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public int update(Long id, UmsAdmin admin) {
 | 
	
		
			
				|  |  |          admin.setId(id);
 | 
	
		
			
				|  |  | +        //查询是否有相同用户名的用户
 | 
	
		
			
				|  |  | +        UmsAdminExample example = new UmsAdminExample();
 | 
	
		
			
				|  |  | +        example.createCriteria().andUsernameEqualTo(admin.getUsername());
 | 
	
		
			
				|  |  | +        List<UmsAdmin> umsAdminList = adminMapper.selectByExample(example);
 | 
	
		
			
				|  |  | +        if (umsAdminList.size() > 0) {
 | 
	
		
			
				|  |  | +            for (UmsAdmin umsAdmin : umsAdminList) {
 | 
	
		
			
				|  |  | +                Long reid = umsAdmin.getId();
 | 
	
		
			
				|  |  | +                if(!id.equals(reid)){
 | 
	
		
			
				|  |  | +                    throw new GlobalException("该用户已存在!");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          UmsAdmin rawAdmin = adminMapper.selectByPrimaryKey(id);
 | 
	
		
			
				|  |  | +        String username = rawAdmin.getUsername();
 | 
	
		
			
				|  |  | +        username = username.toLowerCase();
 | 
	
		
			
				|  |  | +        if(username.equals("admin")){
 | 
	
		
			
				|  |  | +            Long compId = admin.getCompId();
 | 
	
		
			
				|  |  | +            if(!StringUtils.isEmpty(compId)){
 | 
	
		
			
				|  |  | +                throw new GlobalException("超级管理员不能绑定供应商!");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          if(rawAdmin.getPassword().equals(admin.getPassword())){
 | 
	
		
			
				|  |  |              //与原加密密码相同的不需要修改
 | 
	
		
			
				|  |  |              admin.setPassword(null);
 |