mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-15 04:52:09 +08:00
new navMenu
This commit is contained in:
@@ -20,8 +20,12 @@
|
||||
*/
|
||||
package org.maxkey.persistence.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
|
||||
import org.maxkey.entity.Accounts;
|
||||
import org.maxkey.entity.AccountsStrategy;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
|
||||
/**
|
||||
* @author Crystal.sea
|
||||
@@ -30,4 +34,7 @@ import org.maxkey.entity.Accounts;
|
||||
public interface AccountsMapper extends IJpaBaseMapper<Accounts> {
|
||||
|
||||
|
||||
public List<UserInfo> queryUserNotInStrategy(AccountsStrategy strategy);
|
||||
|
||||
public long deleteByStrategy(AccountsStrategy strategy);
|
||||
}
|
||||
|
||||
@@ -17,13 +17,19 @@
|
||||
|
||||
package org.maxkey.persistence.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
||||
import org.maxkey.constants.ConstantsStatus;
|
||||
import org.maxkey.crypto.ReciprocalUtils;
|
||||
import org.maxkey.entity.Accounts;
|
||||
import org.maxkey.entity.AccountsStrategy;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.persistence.kafka.KafkaIdentityAction;
|
||||
import org.maxkey.persistence.kafka.KafkaIdentityTopic;
|
||||
import org.maxkey.persistence.kafka.KafkaPersistService;
|
||||
import org.maxkey.persistence.mapper.AccountsMapper;
|
||||
import org.maxkey.util.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -36,6 +42,9 @@ public class AccountsService extends JpaBaseService<Accounts>{
|
||||
@Autowired
|
||||
UserInfoService userInfoService;
|
||||
|
||||
@Autowired
|
||||
AccountsStrategyService accountsStrategyService;
|
||||
|
||||
public AccountsService() {
|
||||
super(AccountsMapper.class);
|
||||
}
|
||||
@@ -99,5 +108,59 @@ public class AccountsService extends JpaBaseService<Accounts>{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void refreshByStrategy(AccountsStrategy strategy) {
|
||||
if(StringUtils.isNotBlank(strategy.getOrgIdsList())) {
|
||||
strategy.setOrgIdsList("'"+strategy.getOrgIdsList().replace(",", "','")+"'");
|
||||
}
|
||||
List<UserInfo> userList = queryUserNotInStrategy(strategy);
|
||||
for(UserInfo user : userList) {
|
||||
Accounts account = new Accounts();
|
||||
account.setAppId(strategy.getAppId());
|
||||
account.setAppName(strategy.getAppName());
|
||||
|
||||
account.setUserId(user.getId());
|
||||
account.setUsername(user.getUsername());
|
||||
account.setDisplayName(user.getDisplayName());
|
||||
|
||||
if(strategy.getMapping().equalsIgnoreCase("username")) {
|
||||
account.setRelatedUsername(user.getUsername());
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("mobile")) {
|
||||
account.setRelatedUsername(user.getMobile());
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("email")) {
|
||||
account.setRelatedUsername(user.getEmail());
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("employeeNumber")) {
|
||||
account.setRelatedUsername(user.getEmployeeNumber());
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("windowsAccount")) {
|
||||
account.setRelatedUsername(user.getWindowsAccount());
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("idCardNo")) {
|
||||
account.setRelatedUsername(user.getIdCardNo());
|
||||
}else {
|
||||
account.setRelatedUsername(user.getUsername());
|
||||
}
|
||||
account.setRelatedPassword(ReciprocalUtils.encode(userInfoService.randomPassword()));
|
||||
|
||||
account.setCreateType("automatic");
|
||||
account.setStatus(ConstantsStatus.ACTIVE);
|
||||
account.setStrategyId(strategy.getId());
|
||||
|
||||
insert(account);
|
||||
}
|
||||
deleteByStrategy(strategy);
|
||||
}
|
||||
public void refreshAllByStrategy() {
|
||||
for( AccountsStrategy strategy : accountsStrategyService.query(null)) {
|
||||
refreshByStrategy(strategy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<UserInfo> queryUserNotInStrategy(AccountsStrategy strategy){
|
||||
return getMapper().queryUserNotInStrategy(strategy);
|
||||
}
|
||||
|
||||
public long deleteByStrategy(AccountsStrategy strategy) {
|
||||
return getMapper().deleteByStrategy(strategy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
||||
import org.maxkey.constants.ConstantsStatus;
|
||||
import org.maxkey.entity.Groups;
|
||||
import org.maxkey.persistence.mapper.GroupsMapper;
|
||||
import org.maxkey.util.StringUtils;
|
||||
@@ -72,7 +73,7 @@ public class GroupsService extends JpaBaseService<Groups> implements Serializab
|
||||
}
|
||||
|
||||
public void refreshDynamicGroups(Groups dynamicGroup){
|
||||
if(dynamicGroup.getDynamic().equals("1")) {
|
||||
if(dynamicGroup.getDynamic().equals(ConstantsStatus.ACTIVE)) {
|
||||
boolean isDynamicTimeSupport = false;
|
||||
boolean isBetweenEffectiveTime = false;
|
||||
if(StringUtils.isNotBlank(dynamicGroup.getResumeTime())
|
||||
@@ -119,6 +120,14 @@ public class GroupsService extends JpaBaseService<Groups> implements Serializab
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshAllDynamicGroups(){
|
||||
List<Groups> groupsList = queryDynamicGroups(null);
|
||||
for(Groups group : groupsList) {
|
||||
_logger.debug("group " + group);
|
||||
refreshDynamicGroups(group);
|
||||
}
|
||||
}
|
||||
|
||||
public GroupMemberService getGroupMemberService() {
|
||||
return groupMemberService;
|
||||
|
||||
@@ -29,4 +29,40 @@
|
||||
<include refid="where_statement"/>
|
||||
</select>
|
||||
|
||||
<select id="queryUserNotInStrategy" parameterType="AccountsStrategy" resultType="UserInfo">
|
||||
select
|
||||
*
|
||||
from mxk_userinfo u
|
||||
where not exists(
|
||||
select 1 from mxk_accounts ac
|
||||
where ac.appid = #{appId}
|
||||
and ac.userid = u.id
|
||||
and ac.createtype='automatic'
|
||||
)
|
||||
<if test="filters != null and filters != ''">
|
||||
and (${filters})
|
||||
</if>
|
||||
<if test="orgIdsList != null and orgIdsList != ''">
|
||||
and u.departmentid in( ${orgIdsList})
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<delete id="deleteByStrategy" parameterType="AccountsStrategy" >
|
||||
delete from mxk_accounts ac
|
||||
where ac.createtype = 'automatic'
|
||||
and ac.appid = #{appId}
|
||||
and ac.strategyid = #{id}
|
||||
and not exists(
|
||||
select 1
|
||||
from mxk_userinfo u
|
||||
where 1 = 1
|
||||
and u.id=ac.userid
|
||||
<if test="filters != null and filters != ''">
|
||||
and (${filters})
|
||||
</if>
|
||||
<if test="orgIdsList != null and orgIdsList != ''">
|
||||
and u.departmentid in ( ${orgIdsList})
|
||||
</if>
|
||||
)
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user