mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 01:18:27 +08:00
Revert "Merge pull request #35 from FranisiL/master_dev_lyp"
This reverts commit 60a40708b8c799c3c1bf95d4a1055f2406f37210, reversing changes made to d96247e741cb82a285edda050f516ee7423baf54.
This commit is contained in:
parent
60a40708b8
commit
a555a251b1
@ -312,10 +312,6 @@ subprojects {
|
|||||||
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.38'
|
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.38'
|
||||||
//JULI logging implementation for embedded Tomcat
|
//JULI logging implementation for embedded Tomcat
|
||||||
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-logging-juli', version: '8.5.2'
|
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-logging-juli', version: '8.5.2'
|
||||||
|
|
||||||
//easyExcel
|
|
||||||
compile group: 'com.alibaba', name: 'easyexcel', version: '2.1.6'
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
|||||||
@ -28,7 +28,4 @@ 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";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.domain;
|
package org.maxkey.domain;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
/**
|
/**
|
||||||
* .
|
* .
|
||||||
* @author Crystal.Sea
|
* @author Crystal.Sea
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Table(name = "MXK_USERINFO")
|
@Table(name = "MXK_USERINFO")
|
||||||
public class UserInfo extends JpaBaseDomain {
|
public class UserInfo extends JpaBaseDomain {
|
||||||
@ -329,7 +329,7 @@ public class UserInfo extends JpaBaseDomain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public UserInfo() {
|
public UserInfo() {
|
||||||
super();
|
super();
|
||||||
@ -469,7 +469,7 @@ public class UserInfo extends JpaBaseDomain {
|
|||||||
this.nickName = nickName;
|
this.nickName = nickName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getNameZhSpell() {
|
public String getNameZhSpell() {
|
||||||
return nameZhSpell;
|
return nameZhSpell;
|
||||||
@ -1147,6 +1147,7 @@ public class UserInfo extends JpaBaseDomain {
|
|||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the createdBy
|
* @return the createdBy
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,20 +0,0 @@
|
|||||||
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,31 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
* 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;
|
||||||
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
||||||
import org.maxkey.constants.ConstantsStatus;
|
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;
|
||||||
@ -45,53 +38,47 @@ 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.util.CollectionUtils;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Crystal.Sea
|
* @author Crystal.Sea
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see com.connsec.db.service.BaseService#getMapper()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public UserInfoMapper getMapper() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return (UserInfoMapper) super.getMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.connsec.db.service.BaseService#getMapper()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public UserInfoMapper getMapper() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
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;
|
||||||
@ -99,428 +86,142 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean batchInsert(List<UserInfo> userInfos) {
|
|
||||||
for (UserInfo userInfo : userInfos) {
|
|
||||||
userInfo.setId(userInfo.generateId());
|
|
||||||
passwordEncoder(userInfo);
|
|
||||||
}
|
|
||||||
if (super.batchInsert(userInfos)) {
|
|
||||||
kafkaProvisioningService.send(
|
|
||||||
KafkaIdentityTopic.USERINFO_TOPIC,
|
|
||||||
userInfos,
|
|
||||||
KafkaIdentityAction.CREATE_ACTION);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 boolean delete(UserInfo userInfo) {
|
||||||
|
if( super.delete(userInfo)){
|
||||||
|
kafkaProvisioningService.send(
|
||||||
|
KafkaIdentityTopic.USERINFO_TOPIC,
|
||||||
|
userInfo,
|
||||||
|
KafkaIdentityAction.DELETE_ACTION);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean importing(MultipartFile file) throws IOException {
|
public boolean updateGridList(String gridList) {
|
||||||
if(file ==null){
|
try {
|
||||||
return false;
|
if (gridList != null && !gridList.equals("")) {
|
||||||
}
|
|
||||||
// 解析excel文件中数据
|
|
||||||
List<UserInfo> userInfos = readExcel(file);
|
|
||||||
return batchInsert(userInfos);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static List<UserInfo> readExcel(MultipartFile file) throws IOException {
|
|
||||||
InputStream is = file.getInputStream();
|
|
||||||
Workbook wb;
|
|
||||||
String xls = ".xls";
|
|
||||||
String xlsx = ".xlsx";
|
|
||||||
int columnSize = 46;
|
|
||||||
List<UserInfo> userInfos = Lists.newArrayList();
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (file.getOriginalFilename().toLowerCase().endsWith(xls)) {
|
|
||||||
wb = new HSSFWorkbook(is);
|
|
||||||
} else if (file.getOriginalFilename().toLowerCase().endsWith(xlsx)) {
|
|
||||||
wb = new XSSFWorkbook(is);
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException("maxKey用户导入没有Excel类型");
|
|
||||||
}
|
|
||||||
|
|
||||||
int sheetSize = wb.getNumberOfSheets();
|
|
||||||
//遍历sheet页
|
|
||||||
for (int i = 0; i < sheetSize; i++) {
|
|
||||||
Sheet sheet = wb.getSheetAt(i);
|
|
||||||
|
|
||||||
int rowSize = sheet.getLastRowNum() + 1;
|
|
||||||
//遍历行
|
|
||||||
for (int j = 1; j < rowSize; j++) {
|
|
||||||
Row row = sheet.getRow(j);
|
|
||||||
//略过空行和第一行
|
|
||||||
if (row == null || j == 0) {
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
//其他行是数据行
|
|
||||||
UserInfo userInfo = new UserInfo();
|
|
||||||
userInfo.setCreatedDate(DateUtils.formatDateTime(new Date()));
|
|
||||||
|
|
||||||
int rangeType = -1;
|
|
||||||
for (int k = 0; k < columnSize; k++) {
|
|
||||||
if (k == 0) {
|
|
||||||
// 登录账号
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setUsername(getValue(cell));
|
|
||||||
} else if (k == 1) {
|
|
||||||
// 密码
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setPassword(getValue(cell));
|
|
||||||
} else if (k == 2) {
|
|
||||||
// 员工编码
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setEmployeeNumber(getValue(cell));
|
|
||||||
} else if (k == 3) {
|
|
||||||
// 用户类型
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setUserType(getValue(cell));
|
|
||||||
} else if (k == 4) {
|
|
||||||
// 用户名
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setDisplayName(getValue(cell));
|
|
||||||
} else if (k == 5) {
|
|
||||||
// 姓
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setFamilyName(getValue(cell));
|
|
||||||
} else if (k == 6) {
|
|
||||||
// 名
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setGivenName(getValue(cell));
|
|
||||||
} else if (k == 7) {
|
|
||||||
// 中间名
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setMiddleName(getValue(cell));
|
|
||||||
} else if (k == 8) {
|
|
||||||
// 昵称
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setNickName(getValue(cell));
|
|
||||||
} else if (k == 9) {
|
|
||||||
// 性别
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setGender(Integer.valueOf(getValue(cell)));
|
|
||||||
} else if (k == 10) {
|
|
||||||
// AD域账号
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setWindowsAccount(getValue(cell));
|
|
||||||
} else if (k == 11) {
|
|
||||||
// 出生日期
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setBirthDate(getValue(cell));
|
|
||||||
} else if (k == 12) {
|
|
||||||
// 语言偏好
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setPreferredLanguage(getValue(cell));
|
|
||||||
} else if (k == 13) {
|
|
||||||
// 时区
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setTimeZone(getValue(cell));
|
|
||||||
}else if (k == 14) {
|
|
||||||
// 所属机构
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setOrganization(getValue(cell));
|
|
||||||
}else if (k == 15) {
|
|
||||||
// 分支机构
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setDivision(getValue(cell));
|
|
||||||
}else if (k == 16) {
|
|
||||||
// 部门名称
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setDepartment(getValue(cell));
|
|
||||||
}else if (k == 17) {
|
|
||||||
// 成本中心
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setCostCenter(getValue(cell));
|
|
||||||
}else if (k == 18) {
|
|
||||||
// 职位
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setJobTitle(getValue(cell));
|
|
||||||
}else if (k == 19) {
|
|
||||||
// 级别
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setJobLevel(getValue(cell));
|
|
||||||
}else if (k == 20) {
|
|
||||||
// 上级经理
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setManager(getValue(cell));
|
|
||||||
}else if (k == 21) {
|
|
||||||
// 助理
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setAssistant(getValue(cell));
|
|
||||||
}else if (k == 22) {
|
|
||||||
// 入职时间
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setEntryDate(getValue(cell));
|
|
||||||
}else if (k == 23) {
|
|
||||||
// 离职时间
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setQuitDate(getValue(cell));
|
|
||||||
}else if (k == 24) {
|
|
||||||
// 工作-国家
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setWorkCountry(getValue(cell));
|
|
||||||
}else if (k == 25) {
|
|
||||||
// 工作-省
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setWorkRegion(getValue(cell));
|
|
||||||
}else if (k == 26) {
|
|
||||||
// 工作-城市
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setTimeZone(getValue(cell));
|
|
||||||
}else if (k == 27) {
|
|
||||||
// 工作-地址
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setWorkLocality(getValue(cell));
|
|
||||||
}else if (k == 28) {
|
|
||||||
// 邮编
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setWorkPostalCode(getValue(cell));
|
|
||||||
}else if (k == 29) {
|
|
||||||
// 传真
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setWorkFax(getValue(cell));
|
|
||||||
}else if (k == 30) {
|
|
||||||
// 工作电话
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setWorkPhoneNumber(getValue(cell));
|
|
||||||
}else if (k == 31) {
|
|
||||||
// 工作邮件
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setWorkEmail(getValue(cell));
|
|
||||||
}else if (k == 32) {
|
|
||||||
// 证件类型 todo 现在数据库中存储的是tinyint
|
|
||||||
// Cell cell = row.getCell(k);
|
|
||||||
// userInfo.setIdType(getValue(cell));
|
|
||||||
}else if (k == 33) {
|
|
||||||
// 证件号码
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setIdCardNo(getValue(cell));
|
|
||||||
}else if (k == 34) {
|
|
||||||
// 婚姻状态 todo 现在数据字段类型是 tinyint
|
|
||||||
// Cell cell = row.getCell(k);
|
|
||||||
// userInfo.setMarried(getValue(cell));
|
|
||||||
}else if (k == 35) {
|
|
||||||
// 开始工作时间
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setStartWorkDate(getValue(cell));
|
|
||||||
}else if (k == 36) {
|
|
||||||
// 国家
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setHomeCountry(getValue(cell));
|
|
||||||
}else if (k == 37) {
|
|
||||||
// 省
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setHomeRegion(getValue(cell));
|
|
||||||
}else if (k == 38) {
|
|
||||||
// 城市
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setHomeLocality(getValue(cell));
|
|
||||||
}else if (k == 39) {
|
|
||||||
// 家庭地址
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setHomeStreetAddress(getValue(cell));
|
|
||||||
}else if (k == 40) {
|
|
||||||
// 家庭邮编
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setHomePostalCode(getValue(cell));
|
|
||||||
}else if (k == 41) {
|
|
||||||
// 家庭传真
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setHomeFax(getValue(cell));
|
|
||||||
}else if (k == 42) {
|
|
||||||
// 家庭电话
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setHomePhoneNumber(getValue(cell));
|
|
||||||
}else if (k == 43) {
|
|
||||||
// 家庭邮箱
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setHomeEmail(getValue(cell));
|
|
||||||
}else if (k == 44) {
|
|
||||||
// 个人主页
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setWebSite(getValue(cell));
|
|
||||||
}else if (k == 45) {
|
|
||||||
// 即时通讯
|
|
||||||
Cell cell = row.getCell(k);
|
|
||||||
userInfo.setDefineIm(getValue(cell));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
userInfos.add(userInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 数据去重
|
|
||||||
if(CollectionUtils.isEmpty(userInfos)){
|
|
||||||
userInfos = userInfos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getUsername()))), ArrayList::new));
|
|
||||||
}
|
|
||||||
return userInfos;
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}finally {
|
|
||||||
if (is != null) {
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return userInfos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据数据格式返回数据
|
|
||||||
*
|
|
||||||
* @param cell
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String getValue(Cell cell) {
|
|
||||||
if (cell == null) {
|
|
||||||
return "";
|
|
||||||
} else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
|
|
||||||
return String.valueOf(cell.getBooleanCellValue());
|
|
||||||
} else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
|
|
||||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
|
||||||
return String.valueOf(cell.getStringCellValue().trim());
|
|
||||||
} else {
|
|
||||||
return String.valueOf(cell.getStringCellValue().trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean delete(UserInfo userInfo) {
|
|
||||||
if (super.delete(userInfo)) {
|
|
||||||
kafkaProvisioningService.send(
|
|
||||||
KafkaIdentityTopic.USERINFO_TOPIC,
|
|
||||||
userInfo,
|
|
||||||
KafkaIdentityAction.DELETE_ACTION);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean updateGridList(String gridList) {
|
|
||||||
try {
|
|
||||||
if (gridList != null && !gridList.equals("")) {
|
|
||||||
int intGridList = Integer.parseInt(gridList);
|
int intGridList = Integer.parseInt(gridList);
|
||||||
jdbcTemplate.update(UPDATE_GRIDLIST_SQL, intGridList,
|
jdbcTemplate.update(UPDATE_GRIDLIST_SQL, intGridList,
|
||||||
WebContext.getUserInfo().getId());
|
WebContext.getUserInfo().getId());
|
||||||
WebContext.getUserInfo().setGridList(intGridList);
|
WebContext.getUserInfo().setGridList(intGridList);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
}catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean updateProtectedApps(UserInfo userinfo) {
|
||||||
|
try {
|
||||||
|
if(WebContext.getUserInfo() != null) {
|
||||||
|
userinfo.setModifiedBy(WebContext.getUserInfo().getId());
|
||||||
|
}
|
||||||
|
userinfo.setModifiedDate(DateUtils.getCurrentDateTimeAsString());
|
||||||
|
return getMapper().updateProtectedApps(userinfo) > 0;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserInfo loadByUsername(String username) {
|
||||||
|
return getMapper().loadByUsername(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserInfo loadByAppIdAndUsername(String appId,String username){
|
||||||
|
try {
|
||||||
|
UserInfo userinfo = new UserInfo();
|
||||||
|
userinfo.setUsername(username);
|
||||||
|
return getMapper().loadByAppIdAndUsername(userinfo) ;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean updateProtectedApps(UserInfo userinfo) {
|
public void logisticDeleteAllByCid(String cid){
|
||||||
try {
|
try {
|
||||||
if (WebContext.getUserInfo() != null) {
|
getMapper().logisticDeleteAllByCid(cid);
|
||||||
userinfo.setModifiedBy(WebContext.getUserInfo().getId());
|
} catch(Exception e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
userinfo.setModifiedDate(DateUtils.getCurrentDateTimeAsString());
|
}
|
||||||
return getMapper().updateProtectedApps(userinfo) > 0;
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
public UserInfo passwordEncoder(UserInfo userInfo) {
|
||||||
}
|
//密码不为空,则需要进行加密处理
|
||||||
return false;
|
if(userInfo.getPassword()!=null && !userInfo.getPassword().equals("")) {
|
||||||
}
|
String password = passwordEncoder.encode(userInfo.getPassword());
|
||||||
|
|
||||||
public UserInfo loadByUsername(String username) {
|
|
||||||
return getMapper().loadByUsername(username);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserInfo loadByAppIdAndUsername(String appId, String username) {
|
|
||||||
try {
|
|
||||||
UserInfo userinfo = new UserInfo();
|
|
||||||
userinfo.setUsername(username);
|
|
||||||
return getMapper().loadByAppIdAndUsername(userinfo);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void logisticDeleteAllByCid(String cid) {
|
|
||||||
try {
|
|
||||||
getMapper().logisticDeleteAllByCid(cid);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserInfo passwordEncoder(UserInfo userInfo) {
|
|
||||||
//密码不为空,则需要进行加密处理
|
|
||||||
if (userInfo.getPassword() != null && !userInfo.getPassword().equals("")) {
|
|
||||||
String password = passwordEncoder.encode(userInfo.getPassword());
|
|
||||||
userInfo.setDecipherable(ReciprocalUtils.encode(PasswordReciprocal.getInstance().rawPassword(userInfo.getUsername(), userInfo.getPassword())));
|
userInfo.setDecipherable(ReciprocalUtils.encode(PasswordReciprocal.getInstance().rawPassword(userInfo.getUsername(), userInfo.getPassword())));
|
||||||
_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) {
|
||||||
try {
|
try {
|
||||||
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, "");
|
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, "");
|
||||||
UserInfo userInfo = WebContext.getUserInfo();
|
UserInfo userInfo = WebContext.getUserInfo();
|
||||||
UserInfo changeUserInfo = new UserInfo();
|
UserInfo changeUserInfo = new UserInfo();
|
||||||
changeUserInfo.setUsername(userInfo.getUsername());
|
changeUserInfo.setUsername(userInfo.getUsername());
|
||||||
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());
|
||||||
@ -550,116 +251,113 @@ 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();
|
||||||
changePassword.setId(userInfo.getId());
|
changePassword.setId(userInfo.getId());
|
||||||
changePassword.setUid(userInfo.getId());
|
changePassword.setUid(userInfo.getId());
|
||||||
changePassword.setUsername(userInfo.getUsername());
|
changePassword.setUsername(userInfo.getUsername());
|
||||||
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) {
|
||||||
|
try {
|
||||||
|
if(WebContext.getUserInfo() != null) {
|
||||||
|
userinfo.setModifiedBy(WebContext.getUserInfo().getId());
|
||||||
|
}
|
||||||
|
userinfo.setModifiedDate(DateUtils.getCurrentDateTimeAsString());
|
||||||
|
return getMapper().changeAppLoginPassword(userinfo) > 0;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 锁定用户:islock:1 用户解锁 2 用户锁定
|
||||||
|
* @param userInfo
|
||||||
|
*/
|
||||||
|
public void locked(UserInfo userInfo) {
|
||||||
|
try {
|
||||||
|
if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
|
||||||
|
userInfo.setIsLocked(ConstantsStatus.STOP);
|
||||||
|
getMapper().locked(userInfo);
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean changeAppLoginPassword(UserInfo userinfo) {
|
/**
|
||||||
try {
|
* 用户登录成功后,重置错误密码次数和解锁用户
|
||||||
if (WebContext.getUserInfo() != null) {
|
* @param userInfo
|
||||||
userinfo.setModifiedBy(WebContext.getUserInfo().getId());
|
*/
|
||||||
}
|
public void unlock(UserInfo userInfo) {
|
||||||
userinfo.setModifiedDate(DateUtils.getCurrentDateTimeAsString());
|
try {
|
||||||
return getMapper().changeAppLoginPassword(userinfo) > 0;
|
if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
|
||||||
} catch (Exception e) {
|
userInfo.setIsLocked(ConstantsStatus.START);
|
||||||
e.printStackTrace();
|
userInfo.setBadPasswordCount(0);
|
||||||
}
|
getMapper().unlock(userInfo);
|
||||||
return false;
|
}
|
||||||
}
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
/**
|
}
|
||||||
* 锁定用户:islock:1 用户解锁 2 用户锁定
|
|
||||||
*
|
|
||||||
* @param userInfo
|
|
||||||
*/
|
|
||||||
public void locked(UserInfo userInfo) {
|
|
||||||
try {
|
|
||||||
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
|
|
||||||
userInfo.setIsLocked(ConstantsStatus.STOP);
|
|
||||||
getMapper().locked(userInfo);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户登录成功后,重置错误密码次数和解锁用户
|
|
||||||
*
|
|
||||||
* @param userInfo
|
|
||||||
*/
|
|
||||||
public void unlock(UserInfo userInfo) {
|
|
||||||
try {
|
|
||||||
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
|
|
||||||
userInfo.setIsLocked(ConstantsStatus.START);
|
|
||||||
userInfo.setBadPasswordCount(0);
|
|
||||||
getMapper().unlock(userInfo);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新错误密码次数
|
|
||||||
*
|
|
||||||
* @param userInfo
|
|
||||||
*/
|
|
||||||
public void updateBadPasswordCount(UserInfo userInfo) {
|
|
||||||
try {
|
|
||||||
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
|
|
||||||
int updateBadPWDCount = userInfo.getBadPasswordCount() + 1;
|
|
||||||
userInfo.setBadPasswordCount(updateBadPWDCount);
|
|
||||||
getMapper().updateBadPWDCount(userInfo);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean changeSharedSecret(UserInfo userInfo) {
|
|
||||||
return getMapper().changeSharedSecret(userInfo) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean changePasswordQuestion(UserInfo userInfo) {
|
|
||||||
return getMapper().changePasswordQuestion(userInfo) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean changeAuthnType(UserInfo userInfo) {
|
|
||||||
return getMapper().changeAuthnType(userInfo) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean changeEmail(UserInfo userInfo) {
|
|
||||||
return getMapper().changeEmail(userInfo) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean changeMobile(UserInfo userInfo) {
|
|
||||||
return getMapper().changeMobile(userInfo) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新错误密码次数
|
||||||
|
* @param userInfo
|
||||||
|
*/
|
||||||
|
public void updateBadPasswordCount(UserInfo userInfo) {
|
||||||
|
try {
|
||||||
|
if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
|
||||||
|
int updateBadPWDCount = userInfo.getBadPasswordCount() + 1;
|
||||||
|
userInfo.setBadPasswordCount(updateBadPWDCount);
|
||||||
|
getMapper().updateBadPWDCount(userInfo);
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean changeSharedSecret(UserInfo userInfo){
|
||||||
|
return getMapper().changeSharedSecret(userInfo)>0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean changePasswordQuestion(UserInfo userInfo){
|
||||||
|
return getMapper().changePasswordQuestion(userInfo)>0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean changeAuthnType(UserInfo userInfo){
|
||||||
|
return getMapper().changeAuthnType(userInfo)>0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean changeEmail(UserInfo userInfo){
|
||||||
|
return getMapper().changeEmail(userInfo)>0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean changeMobile(UserInfo userInfo){
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,24 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* 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.web.contorller;
|
package org.maxkey.web.contorller;
|
||||||
|
|
||||||
import java.beans.PropertyEditorSupport;
|
import java.beans.PropertyEditorSupport;
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -52,7 +51,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
|
||||||
@ -64,103 +62,81 @@ import org.springframework.web.servlet.ModelAndView;
|
|||||||
@RequestMapping(value = { "/userinfo" })
|
@RequestMapping(value = { "/userinfo" })
|
||||||
public class UserInfoController {
|
public class UserInfoController {
|
||||||
final static Logger _logger = LoggerFactory.getLogger(UserInfoController.class);
|
final static Logger _logger = LoggerFactory.getLogger(UserInfoController.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("userInfoService")
|
@Qualifier("userInfoService")
|
||||||
private UserInfoService userInfoService;
|
private UserInfoService userInfoService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户列表
|
* 查询用户列表
|
||||||
*
|
* @param user
|
||||||
* @param user
|
* @return
|
||||||
* @return
|
*/
|
||||||
*/
|
@RequestMapping(value={"/grid"})
|
||||||
@RequestMapping(value = {"/grid"})
|
@ResponseBody
|
||||||
@ResponseBody
|
public JpaPageResults<UserInfo> forwardUsersList(@ModelAttribute("userInfo") UserInfo userInfo){
|
||||||
public JpaPageResults<UserInfo> forwardUsersList(@ModelAttribute("userInfo") UserInfo userInfo) {
|
return userInfoService.queryPageResults(userInfo);
|
||||||
return userInfoService.queryPageResults(userInfo);
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@RequestMapping(value={"/forwardAdd"})
|
||||||
@RequestMapping(value = {"/forwardAdd"})
|
public ModelAndView forwardSelectUserType(){
|
||||||
public ModelAndView forwardSelectUserType() {
|
ModelAndView modelAndView=new ModelAndView("/userinfo/userAdd");
|
||||||
ModelAndView modelAndView = new ModelAndView("/userinfo/userAdd");
|
//List<UserType> userTypeList=userTypeService.query(null);
|
||||||
//List<UserType> userTypeList=userTypeService.query(null);
|
//modelAndView.addObject("userTypeList", userTypeList);
|
||||||
//modelAndView.addObject("userTypeList", userTypeList);
|
return modelAndView;
|
||||||
return modelAndView;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = {"/list"})
|
|
||||||
public ModelAndView usersList() {
|
@RequestMapping(value={"/list"})
|
||||||
return new ModelAndView("/userinfo/usersList");
|
public ModelAndView usersList(){
|
||||||
}
|
return new ModelAndView("/userinfo/usersList");
|
||||||
|
}
|
||||||
@RequestMapping(value = {"/select"})
|
|
||||||
public ModelAndView usersSelect() {
|
@RequestMapping(value={"/select"})
|
||||||
ModelAndView modelAndView = new ModelAndView("/userinfo/userinfoSelect");
|
public ModelAndView usersSelect(){
|
||||||
return modelAndView;
|
ModelAndView modelAndView= new ModelAndView("/userinfo/userinfoSelect");
|
||||||
}
|
return modelAndView;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 新增
|
/**
|
||||||
*
|
* 新增
|
||||||
* @param userInfo
|
* @param userInfo
|
||||||
* @param result
|
* @param result
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/add")
|
@RequestMapping(value="/add")
|
||||||
public ModelAndView addUsers(@Valid @ModelAttribute("userInfo") UserInfo userInfo, BindingResult result) {
|
public ModelAndView addUsers(@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
userInfo.setId(userInfo.generateId());
|
userInfo.setId(userInfo.generateId());
|
||||||
//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));
|
||||||
if (userInfoService.insert(userInfo)) {
|
if( userInfoService.insert(userInfo)) {
|
||||||
new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS), userInfo, MessageType.success, OperateType.add, MessageScope.DB);
|
new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),userInfo,MessageType.success,OperateType.add,MessageScope.DB);
|
||||||
}
|
}
|
||||||
|
|
||||||
new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR), MessageType.error);
|
new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR),MessageType.error);
|
||||||
return WebContext.forward("forwardUpdate/" + userInfo.getId());
|
return WebContext.forward("forwardUpdate/"+userInfo.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@RequestMapping(value={"/forwardUpdate/{id}"})
|
||||||
* 用户excel导入
|
public ModelAndView forwardUpdateUsers(@PathVariable("id")String id){
|
||||||
*
|
ModelAndView modelAndView=new ModelAndView("/userinfo/userUpdate");
|
||||||
* @param userInfo
|
UserInfo userInfo=userInfoService.get(id);
|
||||||
* @param result
|
if(userInfo.getPicture()!=null){
|
||||||
* @return
|
WebContext.getSession().setAttribute(userInfo.getId(), userInfo.getPicture());
|
||||||
*/
|
}
|
||||||
/**
|
|
||||||
*
|
modelAndView.addObject("model", userInfo);
|
||||||
* @param file excel文件
|
return modelAndView;
|
||||||
* @return
|
}
|
||||||
*/
|
|
||||||
@RequestMapping(value = "/importing")
|
|
||||||
public Object importing(MultipartFile file) throws IOException {
|
|
||||||
if (userInfoService.importing(file)) {
|
|
||||||
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS), null, MessageType.success, OperateType.add, MessageScope.DB);
|
|
||||||
}else {
|
|
||||||
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR), MessageType.error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = {"/forwardUpdate/{id}"})
|
|
||||||
public ModelAndView forwardUpdateUsers(@PathVariable("id") String id) {
|
|
||||||
ModelAndView modelAndView = new ModelAndView("/userinfo/userUpdate");
|
|
||||||
UserInfo userInfo = userInfoService.get(id);
|
|
||||||
if (userInfo.getPicture() != null) {
|
|
||||||
WebContext.getSession().setAttribute(userInfo.getId(), userInfo.getPicture());
|
|
||||||
}
|
|
||||||
|
|
||||||
modelAndView.addObject("model", userInfo);
|
|
||||||
return modelAndView;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户,根据id
|
* 查询用户,根据id
|
||||||
@ -168,7 +144,7 @@ public class UserInfoController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping(value="/getUsers/{id}")
|
@RequestMapping(value="/getUsers/{id}")
|
||||||
public UserInfo getUserInfo(@PathVariable("id")String id) {
|
public UserInfo getUserInfo(@PathVariable("id")String id) {
|
||||||
_logger.debug(id);
|
_logger.debug(id);
|
||||||
UserInfo userInfo = userInfoService.get(id);
|
UserInfo userInfo = userInfoService.get(id);
|
||||||
@ -181,14 +157,14 @@ public class UserInfoController {
|
|||||||
}
|
}
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping(value = "/randomPassword")
|
@RequestMapping(value = "/randomPassword")
|
||||||
public String randomPassword() {
|
public String randomPassword() {
|
||||||
return userInfoService.randomPassword();
|
return userInfoService.randomPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户
|
* 修改用户
|
||||||
* @param userInfo
|
* @param userInfo
|
||||||
@ -196,5 +172,133 @@ public class UserInfoController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@RequestMapping(value="/update")
|
||||||
|
public ModelAndView updateUsers(@Valid @ModelAttribute("userInfo")UserInfo userInfo,BindingResult result) {
|
||||||
|
_logger.debug(userInfo.toString());
|
||||||
|
if(result.hasErrors()){
|
||||||
|
// new Message(WebContext.getValidErrorText(),result);
|
||||||
|
}
|
||||||
|
_logger.info(userInfo.getExtraAttributeName());
|
||||||
|
_logger.info(userInfo.getExtraAttributeValue());
|
||||||
|
//userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true));
|
||||||
|
//userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false));
|
||||||
|
convertExtraAttribute(userInfo) ;
|
||||||
|
_logger.info(userInfo.getExtraAttribute());
|
||||||
|
if(userInfoService.update(userInfo)) {
|
||||||
|
new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),userInfo,MessageType.success,OperateType.add,MessageScope.DB);
|
||||||
|
|
||||||
|
}
|
||||||
|
new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
|
||||||
|
return WebContext.forward("forwardUpdate/"+userInfo.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除用户
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value="/batchDelete")
|
||||||
|
public Message batchDeleteUsers(@RequestParam("id")String id) {
|
||||||
|
_logger.debug(id);
|
||||||
|
if(userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
|
||||||
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR),MessageType.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户id删除用户
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@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);
|
||||||
|
} else {
|
||||||
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR),MessageType.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void convertExtraAttribute(UserInfo userInfo) {
|
||||||
|
if(userInfo.getExtraAttributeValue()!=null){
|
||||||
|
String []extraAttributeLabel=userInfo.getExtraAttributeName().split(",");
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
String extraAttribute=JsonUtils.object2Json(extraAttributeMap);
|
||||||
|
userInfo.setExtraAttribute(extraAttribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value={"/forwardChangePassword/{id}"})
|
||||||
|
public ModelAndView forwardChangePassword(@PathVariable("id")String id){
|
||||||
|
ModelAndView modelAndView=new ModelAndView("/userinfo/changePassword");
|
||||||
|
UserInfo userInfo=userInfoService.get(id);
|
||||||
|
|
||||||
|
modelAndView.addObject("model", userInfo);
|
||||||
|
return modelAndView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value={"/forwardChangeUserinfoStatus/{id}"})
|
||||||
|
public ModelAndView forwardChangeUserinfoStatus(@PathVariable("id")String id){
|
||||||
|
ModelAndView modelAndView=new ModelAndView("/userinfo/changeUserinfoStatus");
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value="/changeUserinfoStatus")
|
||||||
|
public Message changeUserinfoStatus( @ModelAttribute("userInfo")UserInfo userInfo) {
|
||||||
|
_logger.debug(userInfo.getId());
|
||||||
|
if(userInfoService.update(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
dateFormat.setLenient(false);
|
||||||
|
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user