change method

This commit is contained in:
MaxKey
2022-01-03 20:30:39 +08:00
parent a7b8489496
commit 840105f482
22 changed files with 234 additions and 250 deletions
@@ -22,6 +22,7 @@ import java.util.List;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
import org.maxkey.constants.ConstantsStatus;
import org.maxkey.entity.Organizations;
import org.maxkey.entity.UserInfo;
import org.maxkey.entity.UserInfoAdjoint;
@@ -34,44 +35,42 @@ import org.maxkey.entity.UserInfoAdjoint;
public interface UserInfoMapper extends IJpaBaseMapper<UserInfo>{
//login query
public UserInfo findByAppIdAndUsername(UserInfo userInfo);
public UserInfo loadByAppIdAndUsername(UserInfo userInfo);
@Select("select * from mxk_userinfo where username = #{value} and status = " + ConstantsStatus.ACTIVE)
public UserInfo findByUsername(String username);
public int logisticDeleteAllByCid(String cid);
@Select("select * from mxk_userinfo where ( email = #{value} or mobile= #{value} ) and status = " + ConstantsStatus.ACTIVE)
public UserInfo findByEmailMobile(String emailMobile);
public List<Organizations> findDeptsByUserId(String userId);
public UserInfo loadByUsername(String username);
public List<UserInfoAdjoint> findAdjointsByUserId(String userId);
public void locked(UserInfo userInfo);
public void updateLocked(UserInfo userInfo);
public void unlock(UserInfo userInfo);
public void updateLockout(UserInfo userInfo);
public void updateBadPWDCount(UserInfo userInfo);
public int changePassword(UserInfo userInfo);
public int updatePassword(UserInfo userInfo);
public int changeAppLoginPassword(UserInfo userInfo);
public int updateAppLoginPassword(UserInfo userInfo);
public int updateProtectedApps(UserInfo userInfo);
public int updateProtectedApps(UserInfo userInfo);
public int changeSharedSecret(UserInfo userInfo);
public int updateSharedSecret(UserInfo userInfo);
public int changePasswordQuestion(UserInfo userInfo);
public int updatePasswordQuestion(UserInfo userInfo);
public int changeAuthnType(UserInfo userInfo);
public int updateAuthnType(UserInfo userInfo);
public int changeEmail(UserInfo userInfo);
public int updateEmail(UserInfo userInfo);
public int changeMobile(UserInfo userInfo);
public int updateMobile(UserInfo userInfo);
public int updateProfile(UserInfo userInfo);
public int updateProfile(UserInfo userInfo);
public List<Organizations> loadDeptsByUserId(String userId);
public List<UserInfoAdjoint> loadAdjointsByUserId(String userId);
@Select("select * from mxk_userinfo where email = #{value} or mobile= #{value}")
public UserInfo queryUserInfoByEmailMobile(String emailMobile);
@Update("update mxk_userinfo set gridlist = #{gridList} where id = #{id}")
public int updateGridList(UserInfo userInfo) ;
public int updateGridList(UserInfo userInfo) ;
}
@@ -72,7 +72,7 @@ public class AccountsService extends JpaBaseService<Accounts>{
public boolean insert(Accounts account) {
if (super.insert(account)) {
if(kafkaPersistService.getApplicationConfig().isKafkaSupport()) {
UserInfo loadUserInfo = userInfoService.loadUserRelated(account.getUserId());
UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
account.setUserInfo(loadUserInfo);
OrganizationsCast cast = new OrganizationsCast();
cast.setProvider(account.getAppId());
@@ -92,7 +92,7 @@ public class AccountsService extends JpaBaseService<Accounts>{
public boolean update(Accounts account) {
if (super.update(account)) {
if(kafkaPersistService.getApplicationConfig().isKafkaSupport()) {
UserInfo loadUserInfo = userInfoService.loadUserRelated(account.getUserId());
UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
account.setUserInfo(loadUserInfo);
OrganizationsCast cast = new OrganizationsCast();
cast.setProvider(account.getAppId());
@@ -114,7 +114,7 @@ public class AccountsService extends JpaBaseService<Accounts>{
if (super.remove(id)) {
UserInfo loadUserInfo = null;
if(kafkaPersistService.getApplicationConfig().isKafkaSupport()) {
loadUserInfo = userInfoService.loadUserRelated(account.getUserId());
loadUserInfo = userInfoService.findUserRelated(account.getUserId());
account.setUserInfo(loadUserInfo);
kafkaPersistService.send(
KafkaIdentityTopic.ACCOUNT_TOPIC,
@@ -78,7 +78,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
userInfo = passwordEncoder(userInfo);
if (super.insert(userInfo)) {
if(kafkaPersistService.getApplicationConfig().isKafkaSupport()) {
UserInfo loadUserInfo = loadUserRelated(userInfo.getId());
UserInfo loadUserInfo = findUserRelated(userInfo.getId());
kafkaPersistService.send(
KafkaIdentityTopic.USERINFO_TOPIC,
loadUserInfo,
@@ -95,7 +95,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
userInfo = passwordEncoder(userInfo);
if (super.update(userInfo)) {
if(kafkaPersistService.getApplicationConfig().isKafkaSupport()) {
UserInfo loadUserInfo = loadUserRelated(userInfo.getId());
UserInfo loadUserInfo = findUserRelated(userInfo.getId());
accountUpdate(loadUserInfo);
kafkaPersistService.send(
KafkaIdentityTopic.USERINFO_TOPIC,
@@ -112,7 +112,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
public boolean delete(UserInfo userInfo) {
UserInfo loadUserInfo = null;
if(kafkaPersistService.getApplicationConfig().isKafkaSupport()) {
loadUserInfo = loadUserRelated(userInfo.getId());
loadUserInfo = findUserRelated(userInfo.getId());
}
if( super.delete(userInfo)){
@@ -142,10 +142,10 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
}
}
public UserInfo loadUserRelated(String userId) {
public UserInfo findUserRelated(String userId) {
UserInfo loadUserInfo =this.get(userId);
loadUserInfo.setDepts(getMapper().loadDeptsByUserId(userId));
loadUserInfo.setAdjoints(getMapper().loadAdjointsByUserId(userId));
loadUserInfo.setDepts(getMapper().findDeptsByUserId(userId));
loadUserInfo.setAdjoints(getMapper().findAdjointsByUserId(userId));
return loadUserInfo;
}
@@ -176,30 +176,25 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
return false;
}
public UserInfo loadByUsername(String username) {
return getMapper().loadByUsername(username);
public UserInfo findByUsername(String username) {
return getMapper().findByUsername(username);
}
public UserInfo loadByAppIdAndUsername(String appId,String username){
public UserInfo findByEmailMobile(String emailMobile) {
return getMapper().findByEmailMobile(emailMobile);
}
public UserInfo findByAppIdAndUsername(String appId,String username){
try {
UserInfo userinfo = new UserInfo();
userinfo.setUsername(username);
return getMapper().loadByAppIdAndUsername(userinfo) ;
return getMapper().findByAppIdAndUsername(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("")) {
@@ -274,7 +269,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
changeUserInfo = passwordEncoder(changeUserInfo);
if (getMapper().changePassword(changeUserInfo) > 0) {
if (getMapper().updatePassword(changeUserInfo) > 0) {
changePasswordProvisioning(changeUserInfo);
return true;
}
@@ -306,13 +301,13 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
}
}
public boolean changeAppLoginPassword(UserInfo userinfo) {
public boolean updateAppLoginPassword(UserInfo userinfo) {
try {
if(WebContext.getUserInfo() != null) {
userinfo.setModifiedBy(WebContext.getUserInfo().getId());
}
userinfo.setModifiedDate(DateUtils.getCurrentDateTimeAsString());
return getMapper().changeAppLoginPassword(userinfo) > 0;
return getMapper().updateAppLoginPassword(userinfo) > 0;
} catch (Exception e) {
e.printStackTrace();
}
@@ -324,11 +319,11 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
* 锁定用户:islock:1 用户解锁 2 用户锁定
* @param userInfo
*/
public void locked(UserInfo userInfo) {
public void updateLocked(UserInfo userInfo) {
try {
if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
userInfo.setIsLocked(ConstantsStatus.STOP);
getMapper().locked(userInfo);
getMapper().updateLocked(userInfo);
}
} catch(Exception e) {
e.printStackTrace();
@@ -339,12 +334,12 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
* 用户登录成功后,重置错误密码次数和解锁用户
* @param userInfo
*/
public void unlock(UserInfo userInfo) {
public void updateLockout(UserInfo userInfo) {
try {
if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
userInfo.setIsLocked(ConstantsStatus.START);
userInfo.setBadPasswordCount(0);
getMapper().unlock(userInfo);
getMapper().updateLockout(userInfo);
}
} catch(Exception e) {
e.printStackTrace();
@@ -367,34 +362,27 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
}
}
public boolean changeSharedSecret(UserInfo userInfo){
return getMapper().changeSharedSecret(userInfo)>0;
public boolean updateSharedSecret(UserInfo userInfo){
return getMapper().updateSharedSecret(userInfo)>0;
}
public boolean changePasswordQuestion(UserInfo userInfo){
return getMapper().changePasswordQuestion(userInfo)>0;
public boolean updatePasswordQuestion(UserInfo userInfo){
return getMapper().updatePasswordQuestion(userInfo)>0;
}
public boolean changeAuthnType(UserInfo userInfo){
return getMapper().changeAuthnType(userInfo)>0;
public boolean updateAuthnType(UserInfo userInfo){
return getMapper().updateAuthnType(userInfo)>0;
}
public boolean changeEmail(UserInfo userInfo){
return getMapper().changeEmail(userInfo)>0;
public boolean updateEmail(UserInfo userInfo){
return getMapper().updateEmail(userInfo)>0;
}
public boolean changeMobile(UserInfo userInfo){
return getMapper().changeMobile(userInfo)>0;
public boolean updateMobile(UserInfo userInfo){
return getMapper().updateMobile(userInfo)>0;
}
public UserInfo queryUserInfoByEmailMobile(String emailMobile) {
return getMapper().queryUserInfoByEmailMobile(emailMobile);
}
public int updateProfile(UserInfo userInfo){
return getMapper().updateProfile(userInfo);
}
@@ -1,14 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.maxkey.persistence.mapper.UserInfoMapper">
<select id="loadByUsername" parameterType="string" resultType="UserInfo">
select
*
from
mxk_userinfo
where username = #{value}
</select>
<select id="queryPageResults" parameterType="UserInfo" resultType="UserInfo">
select
@@ -70,7 +62,7 @@
order by sortorder,id
</select>
<update id="locked" parameterType="UserInfo" >
<update id="updateLocked" parameterType="UserInfo" >
update mxk_userinfo set
<if test="isLocked != null">
islocked = #{isLocked},
@@ -80,7 +72,7 @@
id = #{id}
</update>
<update id="lockout" parameterType="UserInfo" >
<update id="updateLockout" parameterType="UserInfo" >
update mxk_userinfo set
<if test="isLocked != null">
islocked = #{isLocked},
@@ -92,7 +84,7 @@
id = #{id}
</update>
<update id="changePassword" parameterType="UserInfo" >
<update id="updatePassword" parameterType="UserInfo" >
update mxk_userinfo set
<if test="password != null">
password = #{password},
@@ -104,7 +96,7 @@
id = #{id}
</update>
<update id="changeSharedSecret" parameterType="UserInfo" >
<update id="updateSharedSecret" parameterType="UserInfo" >
update mxk_userinfo set
<if test="sharedSecret != null">
sharedsecret = #{sharedSecret},
@@ -115,7 +107,7 @@
id = #{id}
</update>
<update id="changeAppLoginPassword" parameterType="UserInfo" >
<update id="updateAppLoginPassword" parameterType="UserInfo" >
update mxk_userinfo set
<if test="appLoginPassword != null">
apploginpassword = #{appLoginPassword},
@@ -135,7 +127,7 @@
id = #{id}
</update>
<update id="changePasswordQuestion" parameterType="UserInfo" >
<update id="updatePasswordQuestion" parameterType="UserInfo" >
update mxk_userinfo set
<if test="passwordAnswer != null">
passwordquestion = #{passwordQuestion},
@@ -146,7 +138,7 @@
id = #{id}
</update>
<update id="changeAuthnType" parameterType="UserInfo" >
<update id="updateAuthnType" parameterType="UserInfo" >
update mxk_userinfo set
<if test="authnType != null">
authntype = #{authnType},
@@ -156,7 +148,7 @@
id = #{id}
</update>
<update id="changeEmail" parameterType="UserInfo" >
<update id="updateEmail" parameterType="UserInfo" >
update mxk_userinfo set
<if test="email != null">
email = #{email},
@@ -172,7 +164,7 @@
id = #{id}
</update>
<update id="changeMobile" parameterType="UserInfo" >
<update id="updateMobile" parameterType="UserInfo" >
update mxk_userinfo set
<if test="mobile != null">
mobile = #{mobile},
@@ -184,13 +176,6 @@
where
id = #{id}
</update>
<update id="logisticBatchDelete" parameterType="java.util.List">
update mxk_userinfo set status='2' where id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<update id="updateProfile" parameterType="UserInfo" >
update mxk_userinfo set
@@ -248,7 +233,7 @@
id = #{id}
</update>
<select id="loadDeptsByUserId" parameterType="string" resultType="Organizations">
<select id="findDeptsByUserId" parameterType="string" resultType="Organizations">
select o.* , 1 isPrimary from mxk_organizations o,mxk_userinfo u
where o.instid = #{instId}
and u.instid = #{instId}
@@ -264,7 +249,7 @@
and ua.userid=#{value}
</select>
<select id="loadAdjointsByUserId" parameterType="string" resultType="UserInfoAdjoint">
<select id="findAdjointsByUserId" parameterType="string" resultType="UserInfoAdjoint">
select
*
from mxk_userinfo_adjunct