|
@@ -13,12 +13,14 @@ import com.css.simulation.resource.common.oauth.OauthParameter;
|
|
|
import com.css.simulation.resource.common.utils.AuthUtil;
|
|
|
import com.css.simulation.resource.common.utils.PageUtil;
|
|
|
import com.css.simulation.resource.common.utils.PoUtil;
|
|
|
+import com.css.simulation.resource.configuration.sms.SmsConfiguration;
|
|
|
import com.css.simulation.resource.log.service.LogService;
|
|
|
import com.css.simulation.resource.system.mapper.UserMapper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -27,20 +29,18 @@ import java.util.Map;
|
|
|
@Service
|
|
|
public class UserService {
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
UserMapper userMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
OauthParameter oauthParameter;
|
|
|
-
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
LogService logService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
DictService dictService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
ParameterService parameterService;
|
|
|
+ @Resource
|
|
|
+ SmsConfiguration smsConfiguration;
|
|
|
|
|
|
public UserVO getCurrentUserInfo() {
|
|
|
String userId = AuthUtil.getCurrentUserId();
|
|
@@ -54,22 +54,22 @@ public class UserService {
|
|
|
|
|
|
public PageInfo<UserVO> getUserPageList(UserParam pageParam) {
|
|
|
PageUtil.setPageInfo(pageParam);
|
|
|
- List<UserVO> list = null;
|
|
|
+ List<UserVO> list;
|
|
|
String currentUserRoleCode = AuthUtil.getCurrentUserRoleCode();
|
|
|
- if(DictConstants.ROLE_CODE_SYSADMIN.equals(currentUserRoleCode)){
|
|
|
+ if (DictConstants.ROLE_CODE_SYSADMIN.equals(currentUserRoleCode)) {
|
|
|
list = userMapper.getUserPageLista(pageParam);
|
|
|
- }else if(DictConstants.ROLE_CODE_ADMIN.equals(currentUserRoleCode)){
|
|
|
+ } else if (DictConstants.ROLE_CODE_ADMIN.equals(currentUserRoleCode)) {
|
|
|
list = userMapper.getUserPageListb(pageParam);
|
|
|
- }else if(DictConstants.ROLE_CODE_UESR.equals(currentUserRoleCode)){
|
|
|
+ } else if (DictConstants.ROLE_CODE_UESR.equals(currentUserRoleCode)) {
|
|
|
|
|
|
pageParam.setCreateUserId(AuthUtil.getCurrentUserId());
|
|
|
list = userMapper.getUserPageListc(pageParam);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
Map<String, Map<String, String>> dictMaps = dictService.getDictMapsByTypes(DictConstants.ROLE_CODE);
|
|
|
- list.forEach(po ->{
|
|
|
+ list.forEach(po -> {
|
|
|
po.setRoleCode(dictMaps.get(DictConstants.ROLE_CODE).get(po.getRoleCode()));
|
|
|
});
|
|
|
return new PageInfo<>(list);
|
|
@@ -78,29 +78,29 @@ public class UserService {
|
|
|
public UserPO saveUser(UserPO userPO) throws NoSuchAlgorithmException {
|
|
|
|
|
|
String currentUserRoleCode = AuthUtil.getCurrentUserRoleCode();
|
|
|
- if(DictConstants.ROLE_CODE_SYSADMIN.equals(currentUserRoleCode)){
|
|
|
- if(DictConstants.ROLE_CODE_ADMIN.equals(userPO.getRoleCode())){
|
|
|
+ if (DictConstants.ROLE_CODE_SYSADMIN.equals(currentUserRoleCode)) {
|
|
|
+ if (DictConstants.ROLE_CODE_ADMIN.equals(userPO.getRoleCode())) {
|
|
|
userPO.setRoleCode(DictConstants.ROLE_CODE_ADMIN);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
userPO.setRoleCode(DictConstants.ROLE_CODE_UESR);
|
|
|
}
|
|
|
- }else if(DictConstants.ROLE_CODE_ADMIN.equals(currentUserRoleCode)){
|
|
|
+ } else if (DictConstants.ROLE_CODE_ADMIN.equals(currentUserRoleCode)) {
|
|
|
userPO.setRoleCode(DictConstants.ROLE_CODE_UESR);
|
|
|
- }else if(DictConstants.ROLE_CODE_UESR.equals(currentUserRoleCode)){
|
|
|
+ } else if (DictConstants.ROLE_CODE_UESR.equals(currentUserRoleCode)) {
|
|
|
|
|
|
- if(ObjectUtil.isNull(userPO.getId())){
|
|
|
+ if (ObjectUtil.isNull(userPO.getId())) {
|
|
|
ParameterVO parameter = parameterService.getParameterByUserId();
|
|
|
- if(ObjectUtil.isNull(parameter)){
|
|
|
+ if (ObjectUtil.isNull(parameter)) {
|
|
|
return null;
|
|
|
}
|
|
|
int num = parameter.getNumCreateUser();
|
|
|
int subUserNum = 0;
|
|
|
String userId = AuthUtil.getCurrentUserId();
|
|
|
List<UserPO> subUsers = userMapper.getSubUser(userId);
|
|
|
- if(ObjectUtil.isNotNull(subUsers)){
|
|
|
+ if (ObjectUtil.isNotNull(subUsers)) {
|
|
|
subUserNum = subUsers.size();
|
|
|
}
|
|
|
- if(subUserNum >= num ){
|
|
|
+ if (subUserNum >= num) {
|
|
|
userPO.setId("subUserNum");
|
|
|
return userPO;
|
|
|
}
|
|
@@ -108,52 +108,56 @@ public class UserService {
|
|
|
userPO.setRoleCode(DictConstants.ROLE_CODE_SUBUESR);
|
|
|
|
|
|
userPO.setUseType(AuthUtil.getCurrentUseType());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
List<UserPO> list = userMapper.checkUsername(userPO);
|
|
|
- if(ObjectUtil.isNotNull(list)){
|
|
|
+ if (ObjectUtil.isNotNull(list)) {
|
|
|
userPO.setId("checkUsername");
|
|
|
return userPO;
|
|
|
}
|
|
|
PoUtil.initAddPo(userPO);
|
|
|
String id = userPO.getId();
|
|
|
- if(ObjectUtil.isNull(id)){
|
|
|
+ if (ObjectUtil.isNull(id)) {
|
|
|
userPO.setId(StringUtil.getRandomUUID());
|
|
|
|
|
|
userPO.setPassword(EncryptUtil.getLowerMD5(oauthParameter.getSimulationDefaultPassword()));
|
|
|
userPO.setVisible("1");
|
|
|
userMapper.insert(userPO);
|
|
|
- logService.logUser(LogConstants.SYS_LOG_USER_INSERT,userPO);
|
|
|
- }else{
|
|
|
+ logService.logUser(LogConstants.SYS_LOG_USER_INSERT, userPO);
|
|
|
+ } else {
|
|
|
userMapper.update(userPO);
|
|
|
- logService.logUser(LogConstants.SYS_LOG_USER_UPDATE,userPO);
|
|
|
+ logService.logUser(LogConstants.SYS_LOG_USER_UPDATE, userPO);
|
|
|
}
|
|
|
|
|
|
userPO.setPassword(null);
|
|
|
return userPO;
|
|
|
}
|
|
|
|
|
|
- public void saveDefaultPassword(UserPO userPO) throws NoSuchAlgorithmException {
|
|
|
+ @SneakyThrows
|
|
|
+ public void saveDefaultPassword(UserPO userPO) {
|
|
|
userPO.setPassword(EncryptUtil.getLowerMD5(oauthParameter.getSimulationDefaultPassword()));
|
|
|
PoUtil.initUpdatePo(userPO);
|
|
|
userMapper.saveDefaultPassword(userPO);
|
|
|
- logService.logUser(LogConstants.SYS_LOG_USER_RESET,userPO);
|
|
|
+ logService.logUser(LogConstants.SYS_LOG_USER_RESET, userPO);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public void saveVisible(UserPO userPO) {
|
|
|
PoUtil.initUpdatePo(userPO);
|
|
|
userMapper.saveVisible(userPO);
|
|
|
- if("1".equals(userPO.getVisible())){
|
|
|
- logService.logUser(LogConstants.SYS_LOG_USER_START,userPO);
|
|
|
- }else{
|
|
|
+ if ("1".equals(userPO.getVisible())) {
|
|
|
+ logService.logUser(LogConstants.SYS_LOG_USER_START, userPO);
|
|
|
+ } else {
|
|
|
UserVO userInfo = userMapper.getUserInfo(userPO.getId());
|
|
|
String roleCode = userInfo.getRoleCode();
|
|
|
- if(DictConstants.ROLE_CODE_UESR.equals(roleCode)){
|
|
|
+ if (DictConstants.ROLE_CODE_UESR.equals(roleCode)) {
|
|
|
List<UserPO> subUsers = userMapper.getSubUser(userPO.getId());
|
|
|
- if(ObjectUtil.isNotNull(subUsers)){
|
|
|
- subUsers.forEach(po->{
|
|
|
+ if (ObjectUtil.isNotNull(subUsers)) {
|
|
|
+ subUsers.forEach(po -> {
|
|
|
PoUtil.initUpdatePo(po);
|
|
|
po.setVisible("0");
|
|
|
userMapper.saveVisible(po);
|
|
@@ -161,7 +165,7 @@ public class UserService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- logService.logUser(LogConstants.SYS_LOG_USER_STOP,userPO);
|
|
|
+ logService.logUser(LogConstants.SYS_LOG_USER_STOP, userPO);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -175,7 +179,7 @@ public class UserService {
|
|
|
|
|
|
userVO.setPassword(EncryptUtil.getLowerMD5(userVO.getPassword()));
|
|
|
List<UserVO> list = userMapper.checkPassword(userVO);
|
|
|
- if(ObjectUtil.isNull(list)){
|
|
|
+ if (ObjectUtil.isNull(list)) {
|
|
|
return null;
|
|
|
}
|
|
|
|