mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 17:38:32 +08:00
1.添加用户导入controller
This commit is contained in:
parent
6fd8255d87
commit
9b39775eb0
@ -28,4 +28,7 @@ public final class ConstantsOperateMessage {
|
|||||||
public static final String DELETE_SUCCESS = "message.action.delete.success";
|
public static final String DELETE_SUCCESS = "message.action.delete.success";
|
||||||
public static final String DELETE_ERROR = "message.action.delete.error";
|
public static final String DELETE_ERROR = "message.action.delete.error";
|
||||||
|
|
||||||
|
public static final String import_success = "message.action.import.success";
|
||||||
|
public static final String IMPORT_ERROR = "message.action.import.error";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,64 @@
|
|||||||
|
package org.maxkey.domain;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yapeng.li
|
||||||
|
* @date 2019.3.6
|
||||||
|
*/
|
||||||
|
public class ImportResultBaseVO {
|
||||||
|
/**
|
||||||
|
* 资源名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
if(status==0){
|
||||||
|
this.status = "SUCCESS";
|
||||||
|
}else if(status==1){
|
||||||
|
this.status = "FAILURE";
|
||||||
|
}else{
|
||||||
|
this.status = "IGNORE";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesc() {
|
||||||
|
if(StringUtils.isEmpty(desc)){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDesc(String desc) {
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ImportResultBaseVO{" +
|
||||||
|
"name='" + name + '\'' +
|
||||||
|
", status='" + status + '\'' +
|
||||||
|
", desc='" + desc + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
105
maxkey-core/src/main/java/org/maxkey/domain/ImportResultVO.java
Normal file
105
maxkey-core/src/main/java/org/maxkey/domain/ImportResultVO.java
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
package org.maxkey.domain;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yapeng.li
|
||||||
|
* @since 2020/9/21 21:12
|
||||||
|
*/
|
||||||
|
public class ImportResultVO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成功结果
|
||||||
|
*/
|
||||||
|
List<ImportResultBaseVO> success;
|
||||||
|
/**
|
||||||
|
* 失败结果
|
||||||
|
*/
|
||||||
|
List<ImportResultBaseVO> error;
|
||||||
|
/**
|
||||||
|
* 忽略结果
|
||||||
|
*/
|
||||||
|
List<ImportResultBaseVO> ignore;
|
||||||
|
/**
|
||||||
|
* 成功次数
|
||||||
|
*/
|
||||||
|
Integer successCount;
|
||||||
|
/**
|
||||||
|
* 失败次数
|
||||||
|
*/
|
||||||
|
Integer errorCount;
|
||||||
|
/**
|
||||||
|
* 忽略次数
|
||||||
|
*/
|
||||||
|
Integer ignoreCount;
|
||||||
|
|
||||||
|
public List<ImportResultBaseVO> getSuccess() {
|
||||||
|
if(success==null){
|
||||||
|
success = new ArrayList<>();
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuccess(List<ImportResultBaseVO> success) {
|
||||||
|
this.success = success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImportResultBaseVO> getError() {
|
||||||
|
if(error==null){
|
||||||
|
error = new ArrayList<>();
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setError(List<ImportResultBaseVO> error) {
|
||||||
|
this.error = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImportResultBaseVO> getIgnore() {
|
||||||
|
if(ignore==null){
|
||||||
|
ignore = new ArrayList<>();
|
||||||
|
}
|
||||||
|
return ignore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIgnore(List<ImportResultBaseVO> ignore) {
|
||||||
|
this.ignore = ignore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSuccessCount() {
|
||||||
|
return successCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuccessCount(Integer successCount) {
|
||||||
|
this.successCount = successCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getErrorCount() {
|
||||||
|
return errorCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorCount(Integer errorCount) {
|
||||||
|
this.errorCount = errorCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIgnoreCount() {
|
||||||
|
return ignoreCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIgnoreCount(Integer ignoreCount) {
|
||||||
|
this.ignoreCount = ignoreCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ImportResultVO{" +
|
||||||
|
"success=" + success +
|
||||||
|
", error=" + error +
|
||||||
|
", ignore=" + ignore +
|
||||||
|
", successCount=" + successCount +
|
||||||
|
", errorCount=" + errorCount +
|
||||||
|
", ignoreCount=" + ignoreCount +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
20
maxkey-core/src/main/java/org/maxkey/util/ExcelUtils.java
Normal file
20
maxkey-core/src/main/java/org/maxkey/util/ExcelUtils.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package org.maxkey.util;
|
||||||
|
|
||||||
|
import org.maxkey.domain.UserInfo;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yapeng.li
|
||||||
|
* @since 2020/9/21 21:06
|
||||||
|
*/
|
||||||
|
public class ExcelUtils {
|
||||||
|
|
||||||
|
|
||||||
|
public static List<UserInfo> readExcel(InputStream in) throws Exception {
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.persistence.service;
|
package org.maxkey.persistence.service;
|
||||||
|
|
||||||
@ -23,6 +23,7 @@ import org.maxkey.constants.ConstantsStatus;
|
|||||||
import org.maxkey.crypto.ReciprocalUtils;
|
import org.maxkey.crypto.ReciprocalUtils;
|
||||||
import org.maxkey.crypto.password.PasswordReciprocal;
|
import org.maxkey.crypto.password.PasswordReciprocal;
|
||||||
import org.maxkey.domain.ChangePassword;
|
import org.maxkey.domain.ChangePassword;
|
||||||
|
import org.maxkey.domain.ImportResultVO;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
import org.maxkey.identity.kafka.KafkaIdentityAction;
|
import org.maxkey.identity.kafka.KafkaIdentityAction;
|
||||||
import org.maxkey.identity.kafka.KafkaIdentityTopic;
|
import org.maxkey.identity.kafka.KafkaIdentityTopic;
|
||||||
@ -38,6 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,20 +49,20 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class UserInfoService extends JpaBaseService<UserInfo> {
|
public class UserInfoService extends JpaBaseService<UserInfo> {
|
||||||
final static Logger _logger = LoggerFactory.getLogger(UserInfoService.class);
|
final static Logger _logger = LoggerFactory.getLogger(UserInfoService.class);
|
||||||
|
|
||||||
final static String UPDATE_GRIDLIST_SQL = "UPDATE MXK_USERINFO SET GRIDLIST = ? WHERE ID = ?";
|
final static String UPDATE_GRIDLIST_SQL = "UPDATE MXK_USERINFO SET GRIDLIST = ? WHERE ID = ?";
|
||||||
@Autowired
|
@Autowired
|
||||||
private PasswordEncoder passwordEncoder;
|
private PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
PasswordPolicyValidator passwordPolicyValidator;
|
PasswordPolicyValidator passwordPolicyValidator;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
KafkaProvisioningService kafkaProvisioningService;
|
KafkaProvisioningService kafkaProvisioningService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected JdbcTemplate jdbcTemplate;
|
protected JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
public UserInfoService() {
|
public UserInfoService() {
|
||||||
super(UserInfoMapper.class);
|
super(UserInfoMapper.class);
|
||||||
}
|
}
|
||||||
@ -73,12 +75,12 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return (UserInfoMapper)super.getMapper();
|
return (UserInfoMapper)super.getMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean insert(UserInfo userInfo) {
|
public boolean insert(UserInfo userInfo) {
|
||||||
userInfo = passwordEncoder(userInfo);
|
userInfo = passwordEncoder(userInfo);
|
||||||
if (super.insert(userInfo)) {
|
if (super.insert(userInfo)) {
|
||||||
kafkaProvisioningService.send(
|
kafkaProvisioningService.send(
|
||||||
KafkaIdentityTopic.USERINFO_TOPIC,
|
KafkaIdentityTopic.USERINFO_TOPIC,
|
||||||
userInfo,
|
userInfo,
|
||||||
KafkaIdentityAction.CREATE_ACTION);
|
KafkaIdentityAction.CREATE_ACTION);
|
||||||
return true;
|
return true;
|
||||||
@ -86,26 +88,38 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean update(UserInfo userInfo) {
|
public boolean update(UserInfo userInfo) {
|
||||||
userInfo = passwordEncoder(userInfo);
|
userInfo = passwordEncoder(userInfo);
|
||||||
if (super.update(userInfo)) {
|
if (super.update(userInfo)) {
|
||||||
kafkaProvisioningService.send(
|
kafkaProvisioningService.send(
|
||||||
KafkaIdentityTopic.USERINFO_TOPIC,
|
KafkaIdentityTopic.USERINFO_TOPIC,
|
||||||
userInfo,
|
userInfo,
|
||||||
KafkaIdentityAction.UPDATE_ACTION);
|
KafkaIdentityAction.UPDATE_ACTION);
|
||||||
|
|
||||||
changePasswordProvisioning(userInfo);
|
changePasswordProvisioning(userInfo);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ImportResultVO importing(MultipartFile file,Integer type){
|
||||||
|
|
||||||
|
// 校验当前文件格式是不是excel文件
|
||||||
|
|
||||||
|
// 解析excel文件中数据
|
||||||
|
|
||||||
|
// 判断当前类型 0忽略 1覆盖 2终止
|
||||||
|
// 返回导入结果
|
||||||
|
|
||||||
|
return new ImportResultVO();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean delete(UserInfo userInfo) {
|
public boolean delete(UserInfo userInfo) {
|
||||||
if( super.delete(userInfo)){
|
if( super.delete(userInfo)){
|
||||||
kafkaProvisioningService.send(
|
kafkaProvisioningService.send(
|
||||||
KafkaIdentityTopic.USERINFO_TOPIC,
|
KafkaIdentityTopic.USERINFO_TOPIC,
|
||||||
userInfo,
|
userInfo,
|
||||||
KafkaIdentityAction.DELETE_ACTION);
|
KafkaIdentityAction.DELETE_ACTION);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -126,8 +140,8 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean updateProtectedApps(UserInfo userinfo) {
|
public boolean updateProtectedApps(UserInfo userinfo) {
|
||||||
try {
|
try {
|
||||||
if(WebContext.getUserInfo() != null) {
|
if(WebContext.getUserInfo() != null) {
|
||||||
@ -144,7 +158,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
public UserInfo loadByUsername(String username) {
|
public UserInfo loadByUsername(String username) {
|
||||||
return getMapper().loadByUsername(username);
|
return getMapper().loadByUsername(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserInfo loadByAppIdAndUsername(String appId,String username){
|
public UserInfo loadByAppIdAndUsername(String appId,String username){
|
||||||
try {
|
try {
|
||||||
UserInfo userinfo = new UserInfo();
|
UserInfo userinfo = new UserInfo();
|
||||||
@ -155,7 +169,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void logisticDeleteAllByCid(String cid){
|
public void logisticDeleteAllByCid(String cid){
|
||||||
try {
|
try {
|
||||||
@ -164,7 +178,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserInfo passwordEncoder(UserInfo userInfo) {
|
public UserInfo passwordEncoder(UserInfo userInfo) {
|
||||||
//密码不为空,则需要进行加密处理
|
//密码不为空,则需要进行加密处理
|
||||||
if(userInfo.getPassword()!=null && !userInfo.getPassword().equals("")) {
|
if(userInfo.getPassword()!=null && !userInfo.getPassword().equals("")) {
|
||||||
@ -173,13 +187,13 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
_logger.debug("decipherable : "+userInfo.getDecipherable());
|
_logger.debug("decipherable : "+userInfo.getDecipherable());
|
||||||
userInfo.setPassword(password);
|
userInfo.setPassword(password);
|
||||||
userInfo.setPasswordLastSetTime(DateUtils.getCurrentDateTimeAsString());
|
userInfo.setPasswordLastSetTime(DateUtils.getCurrentDateTimeAsString());
|
||||||
|
|
||||||
userInfo.setModifiedDate(DateUtils.getCurrentDateTimeAsString());
|
userInfo.setModifiedDate(DateUtils.getCurrentDateTimeAsString());
|
||||||
}
|
}
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean changePassword(String oldPassword,
|
public boolean changePassword(String oldPassword,
|
||||||
String newPassword,
|
String newPassword,
|
||||||
String confirmPassword) {
|
String confirmPassword) {
|
||||||
@ -191,37 +205,37 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
changeUserInfo.setPassword(newPassword);
|
changeUserInfo.setPassword(newPassword);
|
||||||
changeUserInfo.setId(userInfo.getId());
|
changeUserInfo.setId(userInfo.getId());
|
||||||
changeUserInfo.setDecipherable(userInfo.getDecipherable());
|
changeUserInfo.setDecipherable(userInfo.getDecipherable());
|
||||||
|
|
||||||
if(newPassword.equals(confirmPassword)){
|
if(newPassword.equals(confirmPassword)){
|
||||||
if(oldPassword==null ||
|
if(oldPassword==null ||
|
||||||
passwordEncoder.matches(oldPassword, userInfo.getPassword())){
|
passwordEncoder.matches(oldPassword, userInfo.getPassword())){
|
||||||
if(changePassword(changeUserInfo) ){
|
if(changePassword(changeUserInfo) ){
|
||||||
userInfo.setPassword(changeUserInfo.getPassword());
|
userInfo.setPassword(changeUserInfo.getPassword());
|
||||||
userInfo.setDecipherable(changeUserInfo.getDecipherable());
|
userInfo.setDecipherable(changeUserInfo.getDecipherable());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}else {
|
}else {
|
||||||
if(oldPassword!=null &&
|
if(oldPassword!=null &&
|
||||||
passwordEncoder.matches(newPassword, userInfo.getPassword())) {
|
passwordEncoder.matches(newPassword, userInfo.getPassword())) {
|
||||||
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
|
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
|
||||||
WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_MATCH"));
|
WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_MATCH"));
|
||||||
}else {
|
}else {
|
||||||
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
|
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
|
||||||
WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_NOT_MATCH"));
|
WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_NOT_MATCH"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
|
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
|
||||||
WebContext.getI18nValue("PasswordPolicy.CONFIRMPASSWORD_NOT_MATCH"));
|
WebContext.getI18nValue("PasswordPolicy.CONFIRMPASSWORD_NOT_MATCH"));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean changePassword(UserInfo changeUserInfo) {
|
public boolean changePassword(UserInfo changeUserInfo) {
|
||||||
try {
|
try {
|
||||||
_logger.debug("decipherable old : " + changeUserInfo.getDecipherable());
|
_logger.debug("decipherable old : " + changeUserInfo.getDecipherable());
|
||||||
@ -251,11 +265,11 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String randomPassword() {
|
public String randomPassword() {
|
||||||
return passwordPolicyValidator.generateRandomPassword();
|
return passwordPolicyValidator.generateRandomPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePasswordProvisioning(UserInfo userInfo) {
|
public void changePasswordProvisioning(UserInfo userInfo) {
|
||||||
if(userInfo.getPassword()!=null && !userInfo.getPassword().equals("")) {
|
if(userInfo.getPassword()!=null && !userInfo.getPassword().equals("")) {
|
||||||
ChangePassword changePassword=new ChangePassword();
|
ChangePassword changePassword=new ChangePassword();
|
||||||
@ -265,12 +279,12 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
changePassword.setDecipherable(userInfo.getDecipherable());
|
changePassword.setDecipherable(userInfo.getDecipherable());
|
||||||
changePassword.setPassword(userInfo.getPassword());
|
changePassword.setPassword(userInfo.getPassword());
|
||||||
kafkaProvisioningService.send(
|
kafkaProvisioningService.send(
|
||||||
KafkaIdentityTopic.PASSWORD_TOPIC,
|
KafkaIdentityTopic.PASSWORD_TOPIC,
|
||||||
changePassword,
|
changePassword,
|
||||||
KafkaIdentityAction.PASSWORD_ACTION);
|
KafkaIdentityAction.PASSWORD_ACTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean changeAppLoginPassword(UserInfo userinfo) {
|
public boolean changeAppLoginPassword(UserInfo userinfo) {
|
||||||
try {
|
try {
|
||||||
if(WebContext.getUserInfo() != null) {
|
if(WebContext.getUserInfo() != null) {
|
||||||
@ -283,8 +297,8 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 锁定用户:islock:1 用户解锁 2 用户锁定
|
* 锁定用户:islock:1 用户解锁 2 用户锁定
|
||||||
* @param userInfo
|
* @param userInfo
|
||||||
@ -331,33 +345,33 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean changeSharedSecret(UserInfo userInfo){
|
public boolean changeSharedSecret(UserInfo userInfo){
|
||||||
return getMapper().changeSharedSecret(userInfo)>0;
|
return getMapper().changeSharedSecret(userInfo)>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean changePasswordQuestion(UserInfo userInfo){
|
public boolean changePasswordQuestion(UserInfo userInfo){
|
||||||
return getMapper().changePasswordQuestion(userInfo)>0;
|
return getMapper().changePasswordQuestion(userInfo)>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean changeAuthnType(UserInfo userInfo){
|
public boolean changeAuthnType(UserInfo userInfo){
|
||||||
return getMapper().changeAuthnType(userInfo)>0;
|
return getMapper().changeAuthnType(userInfo)>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean changeEmail(UserInfo userInfo){
|
public boolean changeEmail(UserInfo userInfo){
|
||||||
return getMapper().changeEmail(userInfo)>0;
|
return getMapper().changeEmail(userInfo)>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean changeMobile(UserInfo userInfo){
|
public boolean changeMobile(UserInfo userInfo){
|
||||||
return getMapper().changeMobile(userInfo)>0;
|
return getMapper().changeMobile(userInfo)>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserInfo queryUserInfoByEmailMobile(String emailMobile) {
|
public UserInfo queryUserInfoByEmailMobile(String emailMobile) {
|
||||||
return getMapper().queryUserInfoByEmailMobile(emailMobile);
|
return getMapper().queryUserInfoByEmailMobile(emailMobile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int updateProfile(UserInfo userInfo){
|
public int updateProfile(UserInfo userInfo){
|
||||||
|
|
||||||
return getMapper().updateProfile(userInfo);
|
return getMapper().updateProfile(userInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -172,107 +172,134 @@ public class UserInfoController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RequestMapping(value="/update")
|
@RequestMapping(value = "/update")
|
||||||
public ModelAndView updateUsers(@Valid @ModelAttribute("userInfo")UserInfo userInfo,BindingResult result) {
|
public ModelAndView updateUsers(@Valid @ModelAttribute("userInfo") UserInfo userInfo, BindingResult result) {
|
||||||
_logger.debug(userInfo.toString());
|
_logger.debug(userInfo.toString());
|
||||||
if(result.hasErrors()){
|
if (result.hasErrors()) {
|
||||||
// new Message(WebContext.getValidErrorText(),result);
|
// new Message(WebContext.getValidErrorText(),result);
|
||||||
}
|
}
|
||||||
_logger.info(userInfo.getExtraAttributeName());
|
_logger.info(userInfo.getExtraAttributeName());
|
||||||
_logger.info(userInfo.getExtraAttributeValue());
|
_logger.info(userInfo.getExtraAttributeValue());
|
||||||
//userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true));
|
//userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true));
|
||||||
//userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false));
|
//userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false));
|
||||||
convertExtraAttribute(userInfo) ;
|
convertExtraAttribute(userInfo);
|
||||||
_logger.info(userInfo.getExtraAttribute());
|
_logger.info(userInfo.getExtraAttribute());
|
||||||
if(userInfoService.update(userInfo)) {
|
if (userInfoService.update(userInfo)) {
|
||||||
new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),userInfo,MessageType.success,OperateType.add,MessageScope.DB);
|
new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS), userInfo, MessageType.success, OperateType.add, MessageScope.DB);
|
||||||
|
|
||||||
}
|
}
|
||||||
new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
|
new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR), MessageType.error);
|
||||||
return WebContext.forward("forwardUpdate/"+userInfo.getId());
|
return WebContext.forward("forwardUpdate/" + userInfo.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* 用户excel导入
|
||||||
* 批量删除用户
|
*
|
||||||
* @param id
|
* @param userInfo
|
||||||
* @return
|
* @param result
|
||||||
*/
|
* @return
|
||||||
@ResponseBody
|
*/
|
||||||
@RequestMapping(value="/batchDelete")
|
/**
|
||||||
public Message batchDeleteUsers(@RequestParam("id")String id) {
|
*
|
||||||
_logger.debug(id);
|
* @param file excel文件
|
||||||
if(userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
|
* @param type //重名处理方式 0忽略 1覆盖 2终止
|
||||||
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
|
* @return
|
||||||
|
*/
|
||||||
} else {
|
@RequestMapping(value = "/importing")
|
||||||
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR),MessageType.error);
|
public Object importing(@RequestParam(value = "file") MultipartFile file,@RequestParam Integer type ) {
|
||||||
}
|
// 判断当前上传文件是否存在
|
||||||
}
|
if (file == null || file.getSize() <= 0) {
|
||||||
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.IMPORT_ERROR), MessageType.error);
|
||||||
/**
|
}
|
||||||
* 根据用户id删除用户
|
if (file.getSize() > 1048576 * 256) {
|
||||||
*
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.IMPORT_ERROR), MessageType.error);
|
||||||
* @param id
|
}
|
||||||
* @return
|
_logger.debug(file.getOriginalFilename(),type);
|
||||||
*/
|
return userInfoService.importing(file,type);
|
||||||
@ResponseBody
|
}
|
||||||
@RequestMapping(value="/delete")
|
|
||||||
public Message deleteUsersById(@RequestParam("id") String id) {
|
|
||||||
_logger.debug(id);
|
/**
|
||||||
if(userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
|
* 批量删除用户
|
||||||
//provisioningPrepare.prepare(userInfo, OPERATEACTION.DELETE_ACTION);
|
*
|
||||||
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
|
* @param id
|
||||||
} else {
|
* @return
|
||||||
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR),MessageType.error);
|
*/
|
||||||
}
|
@ResponseBody
|
||||||
}
|
@RequestMapping(value = "/batchDelete")
|
||||||
|
public Message batchDeleteUsers(@RequestParam("id") String id) {
|
||||||
protected void convertExtraAttribute(UserInfo userInfo) {
|
_logger.debug(id);
|
||||||
if(userInfo.getExtraAttributeValue()!=null){
|
if (userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
|
||||||
String []extraAttributeLabel=userInfo.getExtraAttributeName().split(",");
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS), MessageType.success);
|
||||||
String []extraAttributeValue=userInfo.getExtraAttributeValue().split(",");
|
|
||||||
Map<String,String> extraAttributeMap=new HashMap<String,String> ();
|
} else {
|
||||||
for(int i=0;i<extraAttributeLabel.length;i++){
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR), MessageType.error);
|
||||||
extraAttributeMap.put(extraAttributeLabel[i], extraAttributeValue[i]);
|
}
|
||||||
}
|
}
|
||||||
String extraAttribute=JsonUtils.object2Json(extraAttributeMap);
|
|
||||||
userInfo.setExtraAttribute(extraAttribute);
|
/**
|
||||||
}
|
* 根据用户id删除用户
|
||||||
}
|
*
|
||||||
|
* @param id
|
||||||
@RequestMapping(value={"/forwardChangePassword/{id}"})
|
* @return
|
||||||
public ModelAndView forwardChangePassword(@PathVariable("id")String id){
|
*/
|
||||||
ModelAndView modelAndView=new ModelAndView("/userinfo/changePassword");
|
@ResponseBody
|
||||||
UserInfo userInfo=userInfoService.get(id);
|
@RequestMapping(value = "/delete")
|
||||||
|
public Message deleteUsersById(@RequestParam("id") String id) {
|
||||||
modelAndView.addObject("model", userInfo);
|
_logger.debug(id);
|
||||||
return modelAndView;
|
if (userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
|
||||||
}
|
//provisioningPrepare.prepare(userInfo, OPERATEACTION.DELETE_ACTION);
|
||||||
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS), MessageType.success);
|
||||||
@ResponseBody
|
} else {
|
||||||
@RequestMapping(value="/changePassword")
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR), MessageType.error);
|
||||||
public Message changePassword( @ModelAttribute("userInfo")UserInfo userInfo) {
|
}
|
||||||
_logger.debug(userInfo.getId());
|
}
|
||||||
if(userInfoService.changePassword(userInfo)) {
|
|
||||||
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
|
protected void convertExtraAttribute(UserInfo userInfo) {
|
||||||
|
if (userInfo.getExtraAttributeValue() != null) {
|
||||||
} else {
|
String[] extraAttributeLabel = userInfo.getExtraAttributeName().split(",");
|
||||||
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
|
String[] extraAttributeValue = userInfo.getExtraAttributeValue().split(",");
|
||||||
}
|
Map<String, String> extraAttributeMap = new HashMap<String, String>();
|
||||||
}
|
for (int i = 0; i < extraAttributeLabel.length; i++) {
|
||||||
|
extraAttributeMap.put(extraAttributeLabel[i], extraAttributeValue[i]);
|
||||||
@InitBinder
|
}
|
||||||
public void binder(WebDataBinder binder) {
|
String extraAttribute = JsonUtils.object2Json(extraAttributeMap);
|
||||||
binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
|
userInfo.setExtraAttribute(extraAttribute);
|
||||||
@Override
|
}
|
||||||
public void setAsText(String value) {
|
}
|
||||||
if(StringUtils.isNullOrBlank(value)){
|
|
||||||
setValue(null);
|
@RequestMapping(value = {"/forwardChangePassword/{id}"})
|
||||||
}else{
|
public ModelAndView forwardChangePassword(@PathVariable("id") String id) {
|
||||||
setValue(value);
|
ModelAndView modelAndView = new ModelAndView("/userinfo/changePassword");
|
||||||
}
|
UserInfo userInfo = userInfoService.get(id);
|
||||||
}
|
|
||||||
|
modelAndView.addObject("model", userInfo);
|
||||||
|
return modelAndView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value = "/changePassword")
|
||||||
|
public Message changePassword(@ModelAttribute("userInfo") UserInfo userInfo) {
|
||||||
|
_logger.debug(userInfo.getId());
|
||||||
|
if (userInfoService.changePassword(userInfo)) {
|
||||||
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS), MessageType.success);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR), MessageType.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@InitBinder
|
||||||
|
public void binder(WebDataBinder binder) {
|
||||||
|
binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
|
||||||
|
@Override
|
||||||
|
public void setAsText(String value) {
|
||||||
|
if (StringUtils.isNullOrBlank(value)) {
|
||||||
|
setValue(null);
|
||||||
|
} else {
|
||||||
|
setValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user