mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-06 08:59:10 +08:00
mybatis-jpa-extra-3.3.2
This commit is contained in:
parent
5b0a366f2f
commit
8c50c6e225
Binary file not shown.
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -18,25 +18,9 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.Access;
|
||||
import org.dromara.maxkey.persistence.mapper.AccessMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class AccessService extends JpaService<Access>{
|
||||
|
||||
public AccessService() {
|
||||
super(AccessMapper.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public AccessMapper getMapper() {
|
||||
return (AccessMapper)super.getMapper();
|
||||
}
|
||||
public interface AccessService extends IJpaService<Access>{
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -19,246 +19,30 @@ package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.dromara.maxkey.entity.Accounts;
|
||||
import org.dromara.maxkey.entity.AccountsStrategy;
|
||||
import org.dromara.maxkey.entity.OrganizationsCast;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.AccountsMapper;
|
||||
import org.dromara.maxkey.provision.ProvisionAct;
|
||||
import org.dromara.maxkey.provision.ProvisionService;
|
||||
import org.dromara.maxkey.provision.ProvisionTopic;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
import net.sourceforge.pinyin4j.PinyinHelper;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
|
||||
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
||||
public interface AccountsService extends IJpaService<Accounts>{
|
||||
|
||||
@Repository
|
||||
public class AccountsService extends JpaService<Accounts>{
|
||||
|
||||
@Autowired
|
||||
ProvisionService provisionService;
|
||||
|
||||
@Autowired
|
||||
UserInfoService userInfoService;
|
||||
|
||||
@Autowired
|
||||
AccountsStrategyService accountsStrategyService;
|
||||
|
||||
@Autowired
|
||||
OrganizationsCastService organizationsCastService;
|
||||
|
||||
public AccountsService() {
|
||||
super(AccountsMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public AccountsMapper getMapper() {
|
||||
return (AccountsMapper)super.getMapper();
|
||||
}
|
||||
public boolean updateStatus(Accounts accounts) ;
|
||||
|
||||
public boolean remove(String id) ;
|
||||
|
||||
public void refreshByStrategy(AccountsStrategy strategy) ;
|
||||
|
||||
public void refreshAllByStrategy() ;
|
||||
|
||||
public List<UserInfo> queryUserNotInStrategy(AccountsStrategy strategy);
|
||||
|
||||
public long deleteByStrategy(AccountsStrategy strategy) ;
|
||||
|
||||
@Override
|
||||
public boolean insert(Accounts account) {
|
||||
if (super.insert(account)) {
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
|
||||
account.setUserInfo(loadUserInfo);
|
||||
OrganizationsCast cast = new OrganizationsCast();
|
||||
cast.setProvider(account.getAppId());
|
||||
cast.setOrgId(loadUserInfo.getDepartmentId());
|
||||
account.setOrgCast(organizationsCastService.query(cast));
|
||||
provisionService.send(
|
||||
ProvisionTopic.ACCOUNT_TOPIC,
|
||||
account,
|
||||
ProvisionAct.CREATE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(Accounts account) {
|
||||
if (super.update(account)) {
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
|
||||
account.setUserInfo(loadUserInfo);
|
||||
OrganizationsCast cast = new OrganizationsCast();
|
||||
cast.setProvider(account.getAppId());
|
||||
cast.setOrgId(loadUserInfo.getDepartmentId());
|
||||
account.setOrgCast(organizationsCastService.query(cast));
|
||||
provisionService.send(
|
||||
ProvisionTopic.ACCOUNT_TOPIC,
|
||||
account,
|
||||
ProvisionAct.UPDATE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public List<Accounts> queryByAppIdAndDate(Accounts account) ;
|
||||
|
||||
public boolean updateStatus(Accounts accounts) {
|
||||
return this.getMapper().updateStatus(accounts) > 0;
|
||||
}
|
||||
public List<Accounts> queryByAppIdAndAccount(String appId,String relatedUsername);
|
||||
|
||||
public boolean remove(String id) {
|
||||
Accounts account = this.get(id);
|
||||
if (super.delete(id)) {
|
||||
UserInfo loadUserInfo = null;
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
loadUserInfo = userInfoService.findUserRelated(account.getUserId());
|
||||
account.setUserInfo(loadUserInfo);
|
||||
provisionService.send(
|
||||
ProvisionTopic.ACCOUNT_TOPIC,
|
||||
account,
|
||||
ProvisionAct.DELETE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
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());
|
||||
account.setRelatedUsername(generateAccount(user,strategy));
|
||||
account.setRelatedPassword(PasswordReciprocal.getInstance().encode(userInfoService.randomPassword()));
|
||||
|
||||
account.setInstId(strategy.getInstId());
|
||||
account.setCreateType("automatic");
|
||||
account.setStatus(ConstsStatus.ACTIVE);
|
||||
account.setStrategyId(strategy.getId());
|
||||
|
||||
insert(account);
|
||||
}
|
||||
deleteByStrategy(strategy);
|
||||
}
|
||||
public void refreshAllByStrategy() {
|
||||
AccountsStrategy queryStrategy = new AccountsStrategy();
|
||||
queryStrategy.setCreateType("automatic");
|
||||
for( AccountsStrategy strategy : accountsStrategyService.query(queryStrategy)) {
|
||||
refreshByStrategy(strategy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<UserInfo> queryUserNotInStrategy(AccountsStrategy strategy){
|
||||
return getMapper().queryUserNotInStrategy(strategy);
|
||||
}
|
||||
|
||||
public long deleteByStrategy(AccountsStrategy strategy) {
|
||||
return getMapper().deleteByStrategy(strategy);
|
||||
}
|
||||
|
||||
|
||||
public List<Accounts> queryByAppIdAndDate(Accounts account) {
|
||||
return getMapper().queryByAppIdAndDate(account);
|
||||
}
|
||||
|
||||
public List<Accounts> queryByAppIdAndAccount(String appId,String relatedUsername){
|
||||
return getMapper().queryByAppIdAndAccount(appId,relatedUsername);
|
||||
}
|
||||
|
||||
|
||||
public String generateAccount(UserInfo userInfo,AccountsStrategy accountsStrategy) {
|
||||
String shortAccount = generateAccount(userInfo,accountsStrategy,true);
|
||||
String account = generateAccount(userInfo,accountsStrategy,false);
|
||||
String accountResult = shortAccount;
|
||||
List<Accounts> accountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),shortAccount +accountsStrategy.getSuffixes());
|
||||
if(!accountsList.isEmpty()) {
|
||||
if(accountsStrategy.getMapping().equalsIgnoreCase("email")) {
|
||||
accountResult = account;
|
||||
accountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),account + accountsStrategy.getSuffixes());
|
||||
}
|
||||
if(!accountsList.isEmpty()) {
|
||||
for(int i =1 ;i < 100 ;i++) {
|
||||
accountResult = account + i;
|
||||
accountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),accountResult + accountsStrategy.getSuffixes());
|
||||
if(accountsList.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(accountsStrategy.getSuffixes())){
|
||||
accountResult = accountResult + accountsStrategy.getSuffixes();
|
||||
}
|
||||
return accountResult;
|
||||
}
|
||||
|
||||
|
||||
private String generateAccount(UserInfo userInfo,AccountsStrategy strategy,boolean isShort) {
|
||||
String account = "";
|
||||
if(strategy.getMapping().equalsIgnoreCase("username")) {
|
||||
account = userInfo.getUsername();
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("mobile")) {
|
||||
account = userInfo.getMobile();
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("email")) {
|
||||
try {
|
||||
if(isShort) {
|
||||
account = getPinYinShortName(userInfo.getDisplayName());
|
||||
}else {
|
||||
account = getPinYinName(userInfo.getDisplayName());
|
||||
}
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("employeeNumber")) {
|
||||
account = userInfo.getEmployeeNumber();
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("windowsAccount")) {
|
||||
account = userInfo.getWindowsAccount();
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("idCardNo")) {
|
||||
account = userInfo.getIdCardNo();
|
||||
}else {
|
||||
account = userInfo.getUsername();
|
||||
}
|
||||
|
||||
return account;
|
||||
}
|
||||
|
||||
public static String getPinYinName(String name) throws BadHanyuPinyinOutputFormatCombination {
|
||||
HanyuPinyinOutputFormat pinyinFormat = new HanyuPinyinOutputFormat();
|
||||
pinyinFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
|
||||
pinyinFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
|
||||
pinyinFormat.setVCharType(HanyuPinyinVCharType.WITH_V);
|
||||
return PinyinHelper.toHanYuPinyinString(name, pinyinFormat, "",false);
|
||||
}
|
||||
|
||||
public static String getPinYinShortName(String name) throws BadHanyuPinyinOutputFormatCombination {
|
||||
char[] strs = name.toCharArray();
|
||||
String pinyinName = "";
|
||||
for(int i=0;i<strs.length;i++) {
|
||||
if(i == 0) {
|
||||
pinyinName += getPinYinName(strs[i]+"");
|
||||
}else {
|
||||
pinyinName += getPinYinName(strs[i]+"").charAt(0);
|
||||
}
|
||||
}
|
||||
return pinyinName;
|
||||
}
|
||||
public String generateAccount(UserInfo userInfo,AccountsStrategy accountsStrategy) ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,104 +17,16 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.AccountsStrategy;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.AccountsStrategyMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class AccountsStrategyService extends JpaService<AccountsStrategy> implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -921086134545225302L;
|
||||
|
||||
static final Logger _logger = LoggerFactory.getLogger(AccountsStrategyService.class);
|
||||
/*
|
||||
@Autowired
|
||||
@Qualifier("groupMemberService")
|
||||
GroupMemberService accountsStrategyService;
|
||||
*/
|
||||
public AccountsStrategyService() {
|
||||
super(AccountsStrategyMapper.class);
|
||||
}
|
||||
public interface AccountsStrategyService extends IJpaService<AccountsStrategy> {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public AccountsStrategyMapper getMapper() {
|
||||
return (AccountsStrategyMapper)super.getMapper();
|
||||
}
|
||||
public List<Roles> queryDynamicGroups(Roles groups);
|
||||
|
||||
|
||||
public List<Roles> queryDynamicGroups(Roles groups){
|
||||
return this.getMapper().queryDynamicGroups(groups);
|
||||
}
|
||||
|
||||
public boolean deleteById(String groupId) {
|
||||
this.delete(groupId);
|
||||
//groupMemberService.deleteByGroupId(groupId);
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
public void refreshDynamicGroups(Groups dynamicGroup){
|
||||
if(dynamicGroup.getDynamic().equals("1")) {
|
||||
boolean isDynamicTimeSupport = false;
|
||||
boolean isBetweenEffectiveTime = false;
|
||||
if(dynamicGroup.getResumeTime()!=null&&dynamicGroup.getResumeTime().equals("")
|
||||
&&dynamicGroup.getSuspendTime()!=null&&dynamicGroup.getSuspendTime().equals("")) {
|
||||
LocalTime currentTime = LocalDateTime.now().toLocalTime();
|
||||
LocalTime resumeTime = LocalTime.parse(dynamicGroup.getResumeTime());
|
||||
LocalTime suspendTime = LocalTime.parse(dynamicGroup.getSuspendTime());
|
||||
|
||||
_logger.info("currentTime: " + currentTime
|
||||
+ " , resumeTime : " + resumeTime
|
||||
+ " , suspendTime: " + suspendTime);
|
||||
isDynamicTimeSupport = true;
|
||||
|
||||
if(resumeTime.isBefore(currentTime) && currentTime.isBefore(suspendTime)) {
|
||||
isBetweenEffectiveTime = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(dynamicGroup.getOrgIdsList()!=null && !dynamicGroup.getOrgIdsList().equals("")) {
|
||||
dynamicGroup.setOrgIdsList("'"+dynamicGroup.getOrgIdsList().replace(",", "','")+"'");
|
||||
}
|
||||
String filters = dynamicGroup.getFilters();
|
||||
if(StringUtils.filtersSQLInjection(filters.toLowerCase())) {
|
||||
_logger.info("filters include SQL Injection Attack Risk.");
|
||||
return;
|
||||
}
|
||||
|
||||
filters = filters.replace("&", " AND ");
|
||||
filters = filters.replace("|", " OR ");
|
||||
|
||||
dynamicGroup.setFilters(filters);
|
||||
|
||||
if(isDynamicTimeSupport) {
|
||||
if(isBetweenEffectiveTime) {
|
||||
groupMemberService.deleteDynamicGroupMember(dynamicGroup);
|
||||
groupMemberService.addDynamicGroupMember(dynamicGroup);
|
||||
}else {
|
||||
groupMemberService.deleteDynamicGroupMember(dynamicGroup);
|
||||
}
|
||||
}else{
|
||||
groupMemberService.deleteDynamicGroupMember(dynamicGroup);
|
||||
groupMemberService.addDynamicGroupMember(dynamicGroup);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean deleteById(String groupId) ;
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -18,22 +18,8 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.AppsAdapters;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsAdaptersMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class AppsAdaptersService extends JpaService<AppsAdapters>{
|
||||
public interface AppsAdaptersService extends IJpaService<AppsAdapters>{
|
||||
|
||||
public AppsAdaptersService() {
|
||||
super(AppsAdaptersMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public AppsAdaptersMapper getMapper() {
|
||||
return (AppsAdaptersMapper)super.getMapper();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,50 +17,10 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.AppsCasDetails;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsCasDetailsMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
public interface AppsCasDetailsService extends IJpaService<AppsCasDetails>{
|
||||
|
||||
@Repository
|
||||
public class AppsCasDetailsService extends JpaService<AppsCasDetails>{
|
||||
|
||||
protected static final Cache<String, AppsCasDetails> detailsCache =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.maximumSize(200000)
|
||||
.build();
|
||||
|
||||
public AppsCasDetailsService() {
|
||||
super(AppsCasDetailsMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public AppsCasDetailsMapper getMapper() {
|
||||
return (AppsCasDetailsMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public AppsCasDetails getAppDetails(String id , boolean cached) {
|
||||
AppsCasDetails details = null;
|
||||
if(cached) {
|
||||
details = detailsCache.getIfPresent(id);
|
||||
if(details == null) {
|
||||
details = getMapper().getAppDetails(id);
|
||||
if(details != null) {
|
||||
detailsCache.put(id, details);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
details = getMapper().getAppDetails(id);
|
||||
}
|
||||
return details;
|
||||
}
|
||||
public AppsCasDetails getAppDetails(String id , boolean cached) ;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,48 +17,10 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.AppsFormBasedDetails;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsFormBasedDetailsMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
public interface AppsFormBasedDetailsService extends IJpaService<AppsFormBasedDetails>{
|
||||
|
||||
@Repository
|
||||
public class AppsFormBasedDetailsService extends JpaService<AppsFormBasedDetails>{
|
||||
|
||||
protected static final Cache<String, AppsFormBasedDetails> detailsCache =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.maximumSize(200000)
|
||||
.build();
|
||||
|
||||
public AppsFormBasedDetailsService() {
|
||||
super(AppsFormBasedDetailsMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public AppsFormBasedDetailsMapper getMapper() {
|
||||
return (AppsFormBasedDetailsMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public AppsFormBasedDetails getAppDetails(String id,boolean cached) {
|
||||
AppsFormBasedDetails details = null;
|
||||
if(cached) {
|
||||
details = detailsCache.getIfPresent(id);
|
||||
if(details == null) {
|
||||
details = getMapper().getAppDetails(id);
|
||||
detailsCache.put(id, details);
|
||||
}
|
||||
}else {
|
||||
details = getMapper().getAppDetails(id);
|
||||
}
|
||||
return details;
|
||||
}
|
||||
public AppsFormBasedDetails getAppDetails(String id,boolean cached) ;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,48 +17,10 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.AppsJwtDetails;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsJwtDetailsMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
public interface AppsJwtDetailsService extends IJpaService<AppsJwtDetails>{
|
||||
|
||||
@Repository
|
||||
public class AppsJwtDetailsService extends JpaService<AppsJwtDetails>{
|
||||
|
||||
protected static final Cache<String, AppsJwtDetails> detailsCache =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.maximumSize(200000)
|
||||
.build();
|
||||
|
||||
public AppsJwtDetailsService() {
|
||||
super(AppsJwtDetailsMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public AppsJwtDetailsMapper getMapper() {
|
||||
return (AppsJwtDetailsMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public AppsJwtDetails getAppDetails(String id , boolean cached) {
|
||||
AppsJwtDetails details = null;
|
||||
if(cached) {
|
||||
details = detailsCache.getIfPresent(id);
|
||||
if(details == null) {
|
||||
details = getMapper().getAppDetails(id);
|
||||
detailsCache.put(id, details);
|
||||
}
|
||||
}else {
|
||||
details = getMapper().getAppDetails(id);
|
||||
}
|
||||
return details;
|
||||
}
|
||||
public AppsJwtDetails getAppDetails(String id , boolean cached) ;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,48 +17,10 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.AppsSAML20Details;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsSaml20DetailsMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
public interface AppsSaml20DetailsService extends IJpaService<AppsSAML20Details>{
|
||||
|
||||
@Repository
|
||||
public class AppsSaml20DetailsService extends JpaService<AppsSAML20Details>{
|
||||
|
||||
protected static final Cache<String, AppsSAML20Details> detailsCache =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.maximumSize(200000)
|
||||
.build();
|
||||
|
||||
public AppsSaml20DetailsService() {
|
||||
super(AppsSaml20DetailsMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public AppsSaml20DetailsMapper getMapper() {
|
||||
return (AppsSaml20DetailsMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public AppsSAML20Details getAppDetails(String id , boolean cached){
|
||||
AppsSAML20Details details = null;
|
||||
if(cached) {
|
||||
details = detailsCache.getIfPresent(id);
|
||||
if(details == null) {
|
||||
details = getMapper().getAppDetails(id);
|
||||
detailsCache.put(id, details);
|
||||
}
|
||||
}else {
|
||||
details = getMapper().getAppDetails(id);
|
||||
}
|
||||
return details;
|
||||
}
|
||||
public AppsSAML20Details getAppDetails(String id , boolean cached);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -18,74 +18,23 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.Apps;
|
||||
import org.dromara.maxkey.entity.apps.UserApps;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
|
||||
@Repository
|
||||
public class AppsService extends JpaService<Apps>{
|
||||
//maxkey-mgt
|
||||
public static final String MGT_APP_ID = "622076759805923328";
|
||||
public interface AppsService extends IJpaService<Apps>{
|
||||
|
||||
public static final String DETAIL_SUFFIX = "_detail";
|
||||
public boolean insertApp(Apps app) ;
|
||||
|
||||
protected static final Cache<String, Apps> detailsCacheStore =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.build();
|
||||
public boolean updateApp(Apps app) ;
|
||||
|
||||
public AppsService() {
|
||||
super(AppsMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public AppsMapper getMapper() {
|
||||
return (AppsMapper)super.getMapper();
|
||||
}
|
||||
public boolean updateExtendAttr(Apps app) ;
|
||||
|
||||
public boolean insertApp(Apps app) {
|
||||
return ((AppsMapper)super.getMapper()).insertApp(app)>0;
|
||||
};
|
||||
public boolean updateApp(Apps app) {
|
||||
return ((AppsMapper)super.getMapper()).updateApp(app)>0;
|
||||
};
|
||||
|
||||
public boolean updateExtendAttr(Apps app) {
|
||||
return ((AppsMapper)super.getMapper()).updateExtendAttr(app)>0;
|
||||
}
|
||||
|
||||
public List<UserApps> queryMyApps(UserApps userApplications){
|
||||
return getMapper().queryMyApps(userApplications);
|
||||
}
|
||||
public List<UserApps> queryMyApps(UserApps userApplications);
|
||||
|
||||
//cache for running
|
||||
public void put(String appId, Apps appDetails) {
|
||||
detailsCacheStore.put(appId + DETAIL_SUFFIX, appDetails);
|
||||
}
|
||||
public void put(String appId, Apps appDetails) ;
|
||||
|
||||
public Apps get(String appId, boolean cached) {
|
||||
appId = appId.equalsIgnoreCase("maxkey_mgt") ? MGT_APP_ID : appId;
|
||||
Apps appDetails = null;
|
||||
if(cached) {
|
||||
appDetails = detailsCacheStore.getIfPresent(appId + DETAIL_SUFFIX);
|
||||
if(appDetails == null) {
|
||||
appDetails = this.get(appId);
|
||||
detailsCacheStore.put(appId, appDetails);
|
||||
}
|
||||
}else {
|
||||
appDetails = this.get(appId);
|
||||
}
|
||||
return appDetails;
|
||||
}
|
||||
public Apps get(String appId, boolean cached);
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,48 +17,10 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.AppsTokenBasedDetails;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsTokenBasedDetailsMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
public interface AppsTokenBasedDetailsService extends IJpaService<AppsTokenBasedDetails>{
|
||||
|
||||
@Repository
|
||||
public class AppsTokenBasedDetailsService extends JpaService<AppsTokenBasedDetails>{
|
||||
|
||||
protected static final Cache<String, AppsTokenBasedDetails> detailsCache =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.maximumSize(200000)
|
||||
.build();
|
||||
|
||||
public AppsTokenBasedDetailsService() {
|
||||
super(AppsTokenBasedDetailsMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public AppsTokenBasedDetailsMapper getMapper() {
|
||||
return (AppsTokenBasedDetailsMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public AppsTokenBasedDetails getAppDetails(String id , boolean cached) {
|
||||
AppsTokenBasedDetails details = null;
|
||||
if(cached) {
|
||||
details = detailsCache.getIfPresent(id);
|
||||
if(details == null) {
|
||||
details = getMapper().getAppDetails(id);
|
||||
detailsCache.put(id, details);
|
||||
}
|
||||
}else {
|
||||
details = getMapper().getAppDetails(id);
|
||||
}
|
||||
return details;
|
||||
}
|
||||
public AppsTokenBasedDetails getAppDetails(String id , boolean cached) ;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -19,25 +19,9 @@ package org.dromara.maxkey.persistence.service;
|
||||
|
||||
|
||||
import org.dromara.maxkey.entity.cnf.CnfEmailSenders;
|
||||
import org.dromara.maxkey.persistence.mapper.CnfEmailSendersMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
public interface CnfEmailSendersService extends IJpaService<CnfEmailSenders>{
|
||||
|
||||
@Repository
|
||||
public class CnfEmailSendersService extends JpaService<CnfEmailSenders>{
|
||||
|
||||
public CnfEmailSendersService() {
|
||||
super(CnfEmailSendersMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public CnfEmailSendersMapper getMapper() {
|
||||
return (CnfEmailSendersMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -18,25 +18,9 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.cnf.CnfLdapContext;
|
||||
import org.dromara.maxkey.persistence.mapper.CnfLdapContextMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
|
||||
@Repository
|
||||
public class CnfLdapContextService extends JpaService<CnfLdapContext>{
|
||||
|
||||
public CnfLdapContextService() {
|
||||
super(CnfLdapContextMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public CnfLdapContextMapper getMapper() {
|
||||
return (CnfLdapContextMapper)super.getMapper();
|
||||
}
|
||||
public interface CnfLdapContextService extends IJpaService<CnfLdapContext>{
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -18,23 +18,8 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.cnf.CnfPasswordPolicy;
|
||||
import org.dromara.maxkey.persistence.mapper.CnfPasswordPolicyMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class CnfPasswordPolicyService extends JpaService<CnfPasswordPolicy>{
|
||||
|
||||
public CnfPasswordPolicyService() {
|
||||
super(CnfPasswordPolicyMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public CnfPasswordPolicyMapper getMapper() {
|
||||
return (CnfPasswordPolicyMapper)super.getMapper();
|
||||
}
|
||||
public interface CnfPasswordPolicyService extends IJpaService<CnfPasswordPolicy>{
|
||||
|
||||
}
|
||||
|
||||
@ -18,25 +18,9 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.cnf.CnfSmsProvider;
|
||||
import org.dromara.maxkey.persistence.mapper.CnfSmsProviderMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
|
||||
@Repository
|
||||
public class CnfSmsProviderService extends JpaService<CnfSmsProvider>{
|
||||
public interface CnfSmsProviderService extends IJpaService<CnfSmsProvider>{
|
||||
|
||||
public CnfSmsProviderService() {
|
||||
super(CnfSmsProviderMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public CnfSmsProviderMapper getMapper() {
|
||||
return (CnfSmsProviderMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -18,25 +18,8 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.Connectors;
|
||||
import org.dromara.maxkey.persistence.mapper.ConnectorsMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class ConnectorsService extends JpaService<Connectors>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(ConnectorsService.class);
|
||||
|
||||
public ConnectorsService() {
|
||||
super(ConnectorsMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public ConnectorsMapper getMapper() {
|
||||
return (ConnectorsMapper)super.getMapper();
|
||||
}
|
||||
public interface ConnectorsService extends IJpaService<Connectors>{
|
||||
|
||||
}
|
||||
|
||||
@ -18,22 +18,8 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.FileUpload;
|
||||
import org.dromara.maxkey.persistence.mapper.FileUploadMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class FileUploadService extends JpaService<FileUpload>{
|
||||
public interface FileUploadService extends IJpaService<FileUpload>{
|
||||
|
||||
public FileUploadService() {
|
||||
super(FileUploadMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public FileUploadMapper getMapper() {
|
||||
return (FileUploadMapper)super.getMapper();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -22,68 +22,19 @@ import java.util.List;
|
||||
import org.dromara.maxkey.entity.idm.GroupMember;
|
||||
import org.dromara.maxkey.entity.idm.Groups;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.GroupMemberMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
import org.dromara.mybatis.jpa.entity.JpaPageResults;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class GroupMemberService extends JpaService<GroupMember>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(GroupMemberService.class);
|
||||
public interface GroupMemberService extends IJpaService<GroupMember>{
|
||||
|
||||
public int addDynamicMember(Groups dynamicGroup) ;
|
||||
|
||||
public GroupMemberService() {
|
||||
super(GroupMemberMapper.class);
|
||||
}
|
||||
public int deleteDynamicMember(Groups dynamicGroup) ;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public GroupMemberMapper getMapper() {
|
||||
return (GroupMemberMapper)super.getMapper();
|
||||
}
|
||||
public int deleteByGroupId(String groupId);
|
||||
|
||||
public int addDynamicMember(Groups dynamicGroup) {
|
||||
return getMapper().addDynamicMember(dynamicGroup);
|
||||
}
|
||||
public List<UserInfo> queryMemberByGroupId(String groupId);
|
||||
|
||||
public int deleteDynamicMember(Groups dynamicGroup) {
|
||||
return getMapper().deleteDynamicMember(dynamicGroup);
|
||||
}
|
||||
|
||||
public int deleteByGroupId(String groupId) {
|
||||
return getMapper().deleteByGroupId(groupId);
|
||||
}
|
||||
|
||||
public List<UserInfo> queryMemberByGroupId(String groupId){
|
||||
return getMapper().queryMemberByGroupId(groupId);
|
||||
}
|
||||
|
||||
|
||||
public JpaPageResults<Groups> noMember(GroupMember entity) {
|
||||
entity.setPageSelectId(entity.generateId());
|
||||
entity.setStartRow(calculateStartRow(entity.getPageNumber() ,entity.getPageSize()));
|
||||
|
||||
entity.setPageable(true);
|
||||
List<Groups> resultslist = null;
|
||||
try {
|
||||
resultslist = getMapper().noMember(entity);
|
||||
} catch (Exception e) {
|
||||
_logger.error("queryPageResults Exception " , e);
|
||||
}
|
||||
entity.setPageable(false);
|
||||
Integer totalPage = resultslist.size();
|
||||
|
||||
Integer totalCount = 0;
|
||||
if(entity.getPageNumber() == 1 && totalPage < entity.getPageSize()) {
|
||||
totalCount = totalPage;
|
||||
}else {
|
||||
totalCount = parseCount(getMapper().fetchCount(entity));
|
||||
}
|
||||
|
||||
return new JpaPageResults<Groups>(entity.getPageNumber(),entity.getPageSize(),totalPage,totalCount,resultslist);
|
||||
}
|
||||
public JpaPageResults<Groups> noMember(GroupMember entity) ;
|
||||
|
||||
}
|
||||
|
||||
@ -17,108 +17,21 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.entity.Institutions;
|
||||
import org.dromara.maxkey.entity.idm.Groups;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.GroupsMapper;
|
||||
import org.dromara.maxkey.util.StrUtils;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class GroupsService extends JpaService<Groups>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(GroupsService.class);
|
||||
public interface GroupsService extends IJpaService<Groups>{
|
||||
|
||||
@Autowired
|
||||
GroupMemberService groupMemberService;
|
||||
|
||||
@Autowired
|
||||
InstitutionsService institutionsService;
|
||||
|
||||
public GroupsService() {
|
||||
super(GroupsMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public GroupsMapper getMapper() {
|
||||
return (GroupsMapper)super.getMapper();
|
||||
}
|
||||
public List<Groups> queryDynamicGroups(Groups groups);
|
||||
|
||||
public boolean deleteById(String groupId) ;
|
||||
|
||||
public List<Groups> queryDynamicGroups(Groups groups){
|
||||
return this.getMapper().queryDynamic(groups);
|
||||
}
|
||||
public List<Groups> queryByUserId(String userId);
|
||||
|
||||
public boolean deleteById(String groupId) {
|
||||
this.delete(groupId);
|
||||
groupMemberService.deleteByGroupId(groupId);
|
||||
return true;
|
||||
}
|
||||
public void refreshDynamicGroups(Groups dynamicGroup);
|
||||
|
||||
public List<Groups> queryByUserId(String userId){
|
||||
return this.getMapper().queryByUserId(userId);
|
||||
}
|
||||
|
||||
public void refreshDynamicGroups(Groups dynamicGroup){
|
||||
if(dynamicGroup.getCategory().equals(Roles.Category.DYNAMIC)) {
|
||||
|
||||
if(StringUtils.isNotBlank(dynamicGroup.getOrgIdsList())) {
|
||||
String []orgIds = dynamicGroup.getOrgIdsList().split(",");
|
||||
StringBuffer orgIdFilters = new StringBuffer();
|
||||
for(String orgId : orgIds) {
|
||||
if(StringUtils.isNotBlank(orgId)) {
|
||||
if(orgIdFilters.length() > 0) {
|
||||
orgIdFilters.append(",");
|
||||
}
|
||||
orgIdFilters.append("'").append(orgId).append("'");
|
||||
}
|
||||
}
|
||||
if(orgIdFilters.length() > 0) {
|
||||
dynamicGroup.setOrgIdsList(orgIdFilters.toString());
|
||||
}
|
||||
}
|
||||
|
||||
String filters = dynamicGroup.getFilters();
|
||||
if(StringUtils.isNotBlank(filters)) {
|
||||
if(StrUtils.filtersSQLInjection(filters.toLowerCase())) {
|
||||
_logger.info("filters include SQL Injection Attack Risk.");
|
||||
return;
|
||||
}
|
||||
//replace & with AND, | with OR
|
||||
filters = filters.replace("&", " AND ").replace("|", " OR ");
|
||||
|
||||
dynamicGroup.setFilters(filters);
|
||||
}
|
||||
|
||||
groupMemberService.deleteDynamicMember(dynamicGroup);
|
||||
groupMemberService.addDynamicMember(dynamicGroup);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshAllDynamicGroups(){
|
||||
List<Institutions> instList =
|
||||
institutionsService.find("where status = ? ", new Object[]{ConstsStatus.ACTIVE}, new int[]{Types.INTEGER});
|
||||
for(Institutions inst : instList) {
|
||||
Groups group = new Groups();
|
||||
group.setInstId(inst.getId());
|
||||
List<Groups> groupsList = queryDynamicGroups(group);
|
||||
for(Groups g : groupsList) {
|
||||
_logger.debug("role {}" , g);
|
||||
refreshDynamicGroups(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void refreshAllDynamicGroups();
|
||||
|
||||
}
|
||||
|
||||
@ -18,22 +18,8 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.history.HistoryConnector;
|
||||
import org.dromara.maxkey.persistence.mapper.HistoryConnectorMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class HistoryConnectorService extends JpaService<HistoryConnector>{
|
||||
public interface HistoryConnectorService extends IJpaService<HistoryConnector>{
|
||||
|
||||
public HistoryConnectorService() {
|
||||
super(HistoryConnectorMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public HistoryConnectorMapper getMapper() {
|
||||
return (HistoryConnectorMapper)super.getMapper();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -18,47 +18,8 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.history.HistoryLoginApps;
|
||||
import org.dromara.maxkey.persistence.mapper.HistoryLoginAppsMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class HistoryLoginAppsService extends JpaService<HistoryLoginApps>{
|
||||
public interface HistoryLoginAppsService extends IJpaService<HistoryLoginApps>{
|
||||
|
||||
public HistoryLoginAppsService() {
|
||||
super(HistoryLoginAppsMapper.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HistoryLoginAppsMapper getMapper() {
|
||||
return (HistoryLoginAppsMapper)super.getMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insert(HistoryLoginApps loginAppsHistory){
|
||||
//new Thread insert login app history
|
||||
new Thread(new HistoryLoginAppsRunnable(getMapper(),loginAppsHistory)).start();
|
||||
return true;
|
||||
}
|
||||
|
||||
public class HistoryLoginAppsRunnable implements Runnable{
|
||||
|
||||
HistoryLoginAppsMapper historyLoginAppsMapper;
|
||||
|
||||
HistoryLoginApps loginAppsHistory;
|
||||
|
||||
public HistoryLoginAppsRunnable(HistoryLoginAppsMapper historyLoginAppsMapper,
|
||||
HistoryLoginApps loginAppsHistory) {
|
||||
super();
|
||||
this.historyLoginAppsMapper = historyLoginAppsMapper;
|
||||
this.loginAppsHistory = loginAppsHistory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
historyLoginAppsMapper.insert(loginAppsHistory);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,27 +18,10 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.history.HistoryLogin;
|
||||
import org.dromara.maxkey.persistence.mapper.HistoryLoginMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
import org.dromara.mybatis.jpa.entity.JpaPageResults;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class HistoryLoginService extends JpaService<HistoryLogin>{
|
||||
public interface HistoryLoginService extends IJpaService<HistoryLogin>{
|
||||
|
||||
public HistoryLoginService() {
|
||||
super(HistoryLoginMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public HistoryLoginMapper getMapper() {
|
||||
return (HistoryLoginMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public JpaPageResults<HistoryLogin> queryOnlineSession(HistoryLogin historyLogin) {
|
||||
return this.fetchPageResults("queryOnlineSession",historyLogin);
|
||||
}
|
||||
public JpaPageResults<HistoryLogin> queryOnlineSession(HistoryLogin historyLogin);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -18,22 +18,8 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.history.HistorySynchronizer;
|
||||
import org.dromara.maxkey.persistence.mapper.HistorySynchronizerMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class HistorySynchronizerService extends JpaService<HistorySynchronizer>{
|
||||
public interface HistorySynchronizerService extends IJpaService<HistorySynchronizer>{
|
||||
|
||||
public HistorySynchronizerService() {
|
||||
super(HistorySynchronizerMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public HistorySynchronizerMapper getMapper() {
|
||||
return (HistorySynchronizerMapper)super.getMapper();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,193 +17,14 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.Accounts;
|
||||
import org.dromara.maxkey.entity.ChangePassword;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.dromara.maxkey.entity.Access;
|
||||
import org.dromara.maxkey.entity.SocialsProvider;
|
||||
import org.dromara.maxkey.entity.Synchronizers;
|
||||
import org.dromara.maxkey.entity.history.HistorySystemLogs;
|
||||
import org.dromara.maxkey.entity.idm.Organizations;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.entity.permissions.Permission;
|
||||
import org.dromara.maxkey.entity.permissions.Resources;
|
||||
import org.dromara.maxkey.entity.permissions.RoleMember;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.HistorySystemLogsMapper;
|
||||
import org.dromara.maxkey.util.JsonUtils;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class HistorySystemLogsService extends JpaService<HistorySystemLogs>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(HistorySystemLogsService.class);
|
||||
public interface HistorySystemLogsService extends IJpaService<HistorySystemLogs>{
|
||||
|
||||
public HistorySystemLogsService() {
|
||||
super(HistorySystemLogsMapper.class);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HistorySystemLogsMapper getMapper() {
|
||||
return (HistorySystemLogsMapper)super.getMapper();
|
||||
}
|
||||
public void insert(String topic,Object entity,String action,String result,UserInfo operator) ;
|
||||
|
||||
public void insert(String topic,Object entity,String action,String result,UserInfo operator) {
|
||||
String message = "";
|
||||
if(entity != null) {
|
||||
if(entity instanceof UserInfo userInfo) {
|
||||
message = buildMsg(userInfo);
|
||||
}else if(entity instanceof Organizations organization) {
|
||||
message = buildMsg(organization);
|
||||
}else if(entity instanceof ChangePassword changePassword) {
|
||||
message = buildMsg(changePassword);
|
||||
}else if(entity instanceof Accounts account) {
|
||||
message = buildMsg(account);
|
||||
}else if(entity instanceof Roles role) {
|
||||
message = buildMsg(role);
|
||||
}else if(entity instanceof RoleMember roleMember) {
|
||||
message = buildMsg(roleMember);
|
||||
}else if(entity instanceof Access access) {
|
||||
message = buildMsg(access);
|
||||
}else if(entity instanceof Resources resource) {
|
||||
message = buildMsg(resource);
|
||||
}else if(entity instanceof Synchronizers synchronizer) {
|
||||
message = buildMsg(synchronizer);
|
||||
}else if(entity instanceof SocialsProvider socialsProvider) {
|
||||
message = buildMsg(socialsProvider);
|
||||
}else if(entity instanceof Permission permission) {
|
||||
message = buildMsg(permission);
|
||||
}else if(entity instanceof String) {
|
||||
message = entity.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
insert(topic,message,action,result,operator, entity);
|
||||
}
|
||||
|
||||
public void insert(String topic,String message,String action,String result,UserInfo operator,Object entity) {
|
||||
HistorySystemLogs systemLog = new HistorySystemLogs();
|
||||
systemLog.setId(systemLog.generateId());
|
||||
systemLog.setTopic(topic);
|
||||
systemLog.setMessage(message);
|
||||
systemLog.setMessageAction(action);
|
||||
systemLog.setMessageResult(result);
|
||||
systemLog.setUserId(operator.getId());
|
||||
systemLog.setUsername(operator.getUsername());
|
||||
systemLog.setDisplayName(operator.getDisplayName());
|
||||
systemLog.setInstId(operator.getInstId());
|
||||
systemLog.setJsonCotent(JsonUtils.gsonToString(entity));
|
||||
systemLog.setExecuteTime(new Date());
|
||||
_logger.trace("System Log {}" ,systemLog);
|
||||
getMapper().insert(systemLog);
|
||||
}
|
||||
|
||||
public String buildMsg(UserInfo userInfo) {
|
||||
return new StringBuilder()
|
||||
.append(userInfo.getDisplayName())
|
||||
.append("[")
|
||||
.append(userInfo.getUsername())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(Organizations org) {
|
||||
return new StringBuilder()
|
||||
.append(org.getOrgName())
|
||||
.append("[")
|
||||
.append(org.getOrgCode())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(Accounts account) {
|
||||
return new StringBuilder()
|
||||
.append(account.getRelatedUsername())
|
||||
.append("[")
|
||||
.append(account.getDisplayName()).append(",")
|
||||
.append(account.getUsername()).append(",")
|
||||
.append(account.getAppName())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(ChangePassword changePassword) {
|
||||
return new StringBuilder()
|
||||
.append(changePassword.getDisplayName())
|
||||
.append("[")
|
||||
.append(changePassword.getUsername())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(Roles g) {
|
||||
return new StringBuilder()
|
||||
.append(g.getRoleName())
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(RoleMember rm) {
|
||||
return new StringBuilder()
|
||||
.append(rm.getRoleName())
|
||||
.append("[")
|
||||
.append(rm.getUsername()).append(",")
|
||||
.append(rm.getDisplayName())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(Access permission) {
|
||||
return new StringBuilder()
|
||||
.append(permission.getGroupName())
|
||||
.append("[")
|
||||
.append(permission.getAppName())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(Permission privilege) {
|
||||
return new StringBuilder()
|
||||
.append(privilege.getGroupId())
|
||||
.append("[")
|
||||
.append(privilege.getResourceId())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
|
||||
public String buildMsg(Resources r) {
|
||||
return new StringBuilder()
|
||||
.append(r.getResourceName())
|
||||
.append("[")
|
||||
.append(r.getResourceType())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
|
||||
public String buildMsg(Synchronizers s) {
|
||||
return new StringBuilder()
|
||||
.append(s.getName())
|
||||
.append("[")
|
||||
.append(s.getSourceType()).append(",")
|
||||
.append(s.getScheduler()).append(",")
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(SocialsProvider s) {
|
||||
return new StringBuilder()
|
||||
.append(s.getProviderName())
|
||||
.append("[")
|
||||
.append(s.getProvider())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
public void insert(String topic,String message,String action,String result,UserInfo operator,Object entity) ;
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -18,28 +18,10 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.Institutions;
|
||||
import org.dromara.maxkey.persistence.mapper.InstitutionsMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
public interface InstitutionsService extends IJpaService<Institutions>{
|
||||
|
||||
@Repository
|
||||
public class InstitutionsService extends JpaService<Institutions>{
|
||||
|
||||
public InstitutionsService() {
|
||||
super(InstitutionsMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public InstitutionsMapper getMapper() {
|
||||
return (InstitutionsMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public Institutions findByDomain(String domain) {
|
||||
return getMapper().findByDomain(domain);
|
||||
}
|
||||
public Institutions findByDomain(String domain) ;
|
||||
|
||||
}
|
||||
|
||||
@ -18,33 +18,10 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.OrganizationsCast;
|
||||
import org.dromara.maxkey.persistence.mapper.OrganizationsCastMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
public interface OrganizationsCastService extends IJpaService<OrganizationsCast>{
|
||||
|
||||
@Repository
|
||||
public class OrganizationsCastService extends JpaService<OrganizationsCast>{
|
||||
|
||||
static final Logger _logger = LoggerFactory.getLogger(OrganizationsCastService.class);
|
||||
|
||||
|
||||
public OrganizationsCastService() {
|
||||
super(OrganizationsCastMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public OrganizationsCastMapper getMapper() {
|
||||
return (OrganizationsCastMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public boolean updateCast(OrganizationsCast organizationsCast) {
|
||||
return getMapper().updateCast(organizationsCast) > 0;
|
||||
}
|
||||
public boolean updateCast(OrganizationsCast organizationsCast) ;
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,172 +17,20 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.dromara.maxkey.entity.idm.Organizations;
|
||||
import org.dromara.maxkey.persistence.mapper.OrganizationsMapper;
|
||||
import org.dromara.maxkey.provision.ProvisionAct;
|
||||
import org.dromara.maxkey.provision.ProvisionService;
|
||||
import org.dromara.maxkey.provision.ProvisionTopic;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
|
||||
@Repository
|
||||
public class OrganizationsService extends JpaService<Organizations>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(OrganizationsService.class);
|
||||
|
||||
@Autowired
|
||||
ProvisionService provisionService;
|
||||
|
||||
public OrganizationsService() {
|
||||
super(OrganizationsMapper.class);
|
||||
}
|
||||
public interface OrganizationsService extends IJpaService<Organizations>{
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public OrganizationsMapper getMapper() {
|
||||
return (OrganizationsMapper)super.getMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insert(Organizations organization) {
|
||||
if(super.insert(organization)){
|
||||
provisionService.send(
|
||||
ProvisionTopic.ORG_TOPIC, organization, ProvisionAct.CREATE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void saveOrUpdate(Organizations organization) ;
|
||||
|
||||
@Override
|
||||
public boolean update(Organizations organization) {
|
||||
if(super.update(organization)){
|
||||
provisionService.send(
|
||||
ProvisionTopic.ORG_TOPIC, organization, ProvisionAct.UPDATE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void saveOrUpdate(Organizations organization) {
|
||||
Organizations loadOrg =findOne(" id = ? and instid = ?",
|
||||
new Object[] { organization.getId(), organization.getInstId() },
|
||||
new int[] { Types.VARCHAR, Types.VARCHAR });
|
||||
if( loadOrg == null) {
|
||||
insert(organization);
|
||||
}else {
|
||||
organization.setId(organization.getId());
|
||||
update(organization);
|
||||
}
|
||||
}
|
||||
public List<Organizations> queryOrgs(Organizations organization){
|
||||
return getMapper().queryOrgs(organization);
|
||||
}
|
||||
public List<Organizations> queryOrgs(Organizations organization);
|
||||
|
||||
public boolean delete(Organizations organization) {
|
||||
if(super.delete(organization.getId())){
|
||||
provisionService.send(
|
||||
ProvisionTopic.ORG_TOPIC, organization, ProvisionAct.DELETE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean delete(Organizations organization) ;
|
||||
|
||||
public void reorgNamePath(String instId) ;
|
||||
|
||||
public void reorgNamePath(String instId) {
|
||||
_logger.debug("instId {}", instId);
|
||||
if (StringUtils.isBlank(instId)) {
|
||||
instId = "1";
|
||||
}
|
||||
|
||||
HashMap<String, Organizations> reorgOrgMap = new HashMap<>();
|
||||
List<Organizations> orgList = find(" where instid ='" + instId + "'");
|
||||
List<Organizations> originOrgList = new ArrayList<>();
|
||||
Organizations rootOrg = null;
|
||||
for (Organizations org : orgList) {
|
||||
reorgOrgMap.put(org.getId(), org);
|
||||
if (isRootOrg(org)) {
|
||||
rootOrg = org;
|
||||
}
|
||||
Organizations cloneOrg = new Organizations();
|
||||
BeanUtils.copyProperties(org, cloneOrg);
|
||||
originOrgList.add(cloneOrg);
|
||||
}
|
||||
try {
|
||||
reorg(reorgOrgMap, orgList, rootOrg);
|
||||
_logger.debug("reorged .");
|
||||
long reorgCount = 0;
|
||||
for (Organizations originOrg : originOrgList) {
|
||||
Organizations reorgOrg = reorgOrgMap.get(originOrg.getId());
|
||||
_logger.trace("reorged Organization {}", reorgOrg);
|
||||
if (originOrg.getNamePath() == null || !originOrg.getNamePath().equals(reorgOrg.getNamePath())) {
|
||||
_logger.debug("update reorgCount {} , Organization {}", ++reorgCount, reorgOrg);
|
||||
getMapper().updateNamePath(reorgOrg);
|
||||
}
|
||||
}
|
||||
_logger.debug("reorg finished .");
|
||||
} catch (Exception e) {
|
||||
_logger.error("reorgNamePath Exception ", e);
|
||||
}
|
||||
}
|
||||
|
||||
boolean isRootOrg(Organizations rootOrg) {
|
||||
if (rootOrg.getParentId() == null || rootOrg.getParentId().equalsIgnoreCase("-1")
|
||||
|| rootOrg.getParentId().equalsIgnoreCase(rootOrg.getId())
|
||||
|| rootOrg.getParentId().equalsIgnoreCase(rootOrg.getInstId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void reorg(HashMap<String, Organizations> orgMap, List<Organizations> orgList, Organizations rootOrg) {
|
||||
if (isRootOrg(rootOrg)) {
|
||||
rootOrg.setCodePath("/" + rootOrg.getId() + "/");
|
||||
rootOrg.setNamePath("/" + rootOrg.getOrgName() + "/");
|
||||
} else {
|
||||
Organizations parent = orgMap.get(rootOrg.getParentId());
|
||||
rootOrg.setCodePath(parent.getCodePath() + rootOrg.getId() + "/");
|
||||
rootOrg.setNamePath(parent.getNamePath() + rootOrg.getOrgName() + "/");
|
||||
}
|
||||
rootOrg.setReorgNamePath(true);
|
||||
|
||||
for (Organizations org : orgList) {
|
||||
if (org.isReorgNamePath())
|
||||
continue;
|
||||
if (org.getParentId().equalsIgnoreCase(rootOrg.getId())) {
|
||||
reorg(orgMap, orgList, org);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 根据数据格式返回数据
|
||||
*
|
||||
* @param cell
|
||||
* @return
|
||||
*/
|
||||
public static String getValue(Cell cell) {
|
||||
if (cell == null) {
|
||||
return "";
|
||||
} else if (cell.getCellType() == CellType.BOOLEAN) {
|
||||
return String.valueOf(cell.getBooleanCellValue());
|
||||
} else if (cell.getCellType() == CellType.NUMERIC) {
|
||||
cell.setBlank();
|
||||
return String.valueOf(cell.getStringCellValue().trim());
|
||||
} else {
|
||||
return String.valueOf(cell.getStringCellValue().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,36 +21,14 @@ package org.dromara.maxkey.persistence.service;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.permissions.PermissionRole;
|
||||
import org.dromara.maxkey.persistence.mapper.PermissionRoleMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class PermissionRoleService extends JpaService<PermissionRole>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(PermissionRoleService.class);
|
||||
|
||||
|
||||
public PermissionRoleService() {
|
||||
super(PermissionRoleMapper.class);
|
||||
}
|
||||
public interface PermissionRoleService extends IJpaService<PermissionRole>{
|
||||
|
||||
@Override
|
||||
public PermissionRoleMapper getMapper() {
|
||||
return (PermissionRoleMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public boolean insertPermissionRoles(List<PermissionRole> permissionRolesList) {
|
||||
return getMapper().insertPermissionRoles(permissionRolesList)>0;
|
||||
}
|
||||
public boolean insertPermissionRoles(List<PermissionRole> permissionRolesList);
|
||||
|
||||
public boolean deletePermissionRoles(List<PermissionRole> permissionRolesList) {
|
||||
return getMapper().deletePermissionRoles(permissionRolesList)>=0;
|
||||
}
|
||||
public boolean deletePermissionRoles(List<PermissionRole> permissionRolesList) ;
|
||||
|
||||
public List<PermissionRole> queryPermissionRoles(PermissionRole permissionRole){
|
||||
return getMapper().queryPermissionRoles(permissionRole);
|
||||
}
|
||||
public List<PermissionRole> queryPermissionRoles(PermissionRole permissionRole);
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -20,39 +20,14 @@ package org.dromara.maxkey.persistence.service;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.permissions.Permission;
|
||||
import org.dromara.maxkey.persistence.mapper.PermissionMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class PermissionService extends JpaService<Permission>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(PermissionService.class);
|
||||
|
||||
|
||||
public PermissionService() {
|
||||
super(PermissionMapper.class);
|
||||
}
|
||||
public interface PermissionService extends IJpaService<Permission>{
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public PermissionMapper getMapper() {
|
||||
return (PermissionMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public boolean insertGroupPrivileges(List<Permission> rolePermissionsList) {
|
||||
return getMapper().insertGroupPrivileges(rolePermissionsList)>0;
|
||||
};
|
||||
public boolean insertGroupPrivileges(List<Permission> rolePermissionsList) ;
|
||||
|
||||
public boolean deleteGroupPrivileges(List<Permission> rolePermissionsList) {
|
||||
return getMapper().deleteGroupPrivileges(rolePermissionsList)>=0;
|
||||
}
|
||||
public boolean deleteGroupPrivileges(List<Permission> rolePermissionsList);
|
||||
|
||||
public List<Permission> queryGroupPrivileges(Permission rolePermissions){
|
||||
return getMapper().queryGroupPrivileges(rolePermissions);
|
||||
}
|
||||
public List<Permission> queryGroupPrivileges(Permission rolePermissions);
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,33 +17,12 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.Register;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.RegisterMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class RegisterService extends JpaService<Register>{
|
||||
public interface RegisterService extends IJpaService<Register>{
|
||||
|
||||
public RegisterService() {
|
||||
super(RegisterMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public RegisterMapper getMapper() {
|
||||
return (RegisterMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
public UserInfo findByEmail(String email){
|
||||
List<UserInfo> listUserInfo=getMapper().findByEmail(email);
|
||||
return listUserInfo.size()>0?listUserInfo.get(0):null;
|
||||
}
|
||||
public UserInfo findByEmail(String email);
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -20,59 +20,26 @@ package org.dromara.maxkey.persistence.service;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.dromara.maxkey.persistence.mapper.ReportMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
import org.dromara.mybatis.jpa.entity.JpaEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class ReportService extends JpaService<JpaEntity>{
|
||||
public interface ReportService extends IJpaService<JpaEntity>{
|
||||
|
||||
public Integer analysisDay(HashMap<String,Object> reportParameter) {
|
||||
return getMapper().analysisDay(reportParameter);
|
||||
};
|
||||
public Integer analysisDay(HashMap<String,Object> reportParameter) ;
|
||||
|
||||
public Integer analysisNewUsers(HashMap<String,Object> reportParameter) {
|
||||
return getMapper().analysisNewUsers(reportParameter);
|
||||
};
|
||||
public Integer analysisNewUsers(HashMap<String,Object> reportParameter) ;
|
||||
|
||||
public Integer analysisOnlineUsers(HashMap<String,Object> reportParameter) {
|
||||
return getMapper().analysisOnlineUsers(reportParameter);
|
||||
};
|
||||
public Integer analysisOnlineUsers(HashMap<String,Object> reportParameter) ;
|
||||
|
||||
public Integer analysisActiveUsers(HashMap<String,Object> reportParameter) {
|
||||
return getMapper().analysisActiveUsers(reportParameter);
|
||||
};
|
||||
public Integer analysisActiveUsers(HashMap<String,Object> reportParameter);
|
||||
|
||||
public List<Map<String,Object>> analysisDayHour(HashMap<String,Object> reportParameter){
|
||||
return getMapper().analysisDayHour(reportParameter);
|
||||
}
|
||||
public List<Map<String,Object>> analysisDayHour(HashMap<String,Object> reportParameter);
|
||||
|
||||
public List<Map<String,Object>> analysisMonth(HashMap<String,Object> reportParameter){
|
||||
return getMapper().analysisMonth(reportParameter);
|
||||
}
|
||||
public List<Map<String,Object>> analysisMonth(HashMap<String,Object> reportParameter);
|
||||
|
||||
|
||||
public List<Map<String,Object>> analysisBrowser(HashMap<String,Object> reportParameter){
|
||||
return getMapper().analysisBrowser(reportParameter);
|
||||
}
|
||||
public List<Map<String,Object>> analysisBrowser(HashMap<String,Object> reportParameter);
|
||||
|
||||
public List<Map<String,Object>> analysisApp(HashMap<String,Object> reportParameter){
|
||||
return getMapper().analysisApp(reportParameter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ReportService() {
|
||||
super(ReportMapper.class);
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public ReportMapper getMapper() {
|
||||
return (ReportMapper)super.getMapper();
|
||||
}
|
||||
public List<Map<String,Object>> analysisApp(HashMap<String,Object> reportParameter);
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -20,26 +20,9 @@ package org.dromara.maxkey.persistence.service;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.permissions.Resources;
|
||||
import org.dromara.maxkey.persistence.mapper.ResourcesMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class ResourcesService extends JpaService<Resources>{
|
||||
public interface ResourcesService extends IJpaService<Resources>{
|
||||
|
||||
public ResourcesService() {
|
||||
super(ResourcesMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public ResourcesMapper getMapper() {
|
||||
return (ResourcesMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public List<Resources> queryResourcesTree(Resources resource){
|
||||
return getMapper().fetchPageResults(resource);
|
||||
}
|
||||
public List<Resources> queryResourcesTree(Resources resource);
|
||||
}
|
||||
|
||||
@ -23,65 +23,20 @@ import java.util.List;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.entity.permissions.RoleMember;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.RoleMemberMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
import org.dromara.mybatis.jpa.entity.JpaPageResults;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class RoleMemberService extends JpaService<RoleMember>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(RoleMemberService.class);
|
||||
|
||||
public RoleMemberService() {
|
||||
super(RoleMemberMapper.class);
|
||||
}
|
||||
public interface RoleMemberService extends IJpaService<RoleMember>{
|
||||
|
||||
@Override
|
||||
public RoleMemberMapper getMapper() {
|
||||
return (RoleMemberMapper)super.getMapper();
|
||||
}
|
||||
public int addDynamicRoleMember(Roles dynamicGroup);
|
||||
|
||||
public int addDynamicRoleMember(Roles dynamicGroup) {
|
||||
return getMapper().addDynamicRoleMember(dynamicGroup);
|
||||
}
|
||||
public int deleteDynamicRoleMember(Roles dynamicGroup) ;
|
||||
|
||||
public int deleteDynamicRoleMember(Roles dynamicGroup) {
|
||||
return getMapper().deleteDynamicRoleMember(dynamicGroup);
|
||||
}
|
||||
public int deleteByRoleId(String groupId) ;
|
||||
|
||||
public int deleteByRoleId(String groupId) {
|
||||
return getMapper().deleteByRoleId(groupId);
|
||||
}
|
||||
|
||||
public List<UserInfo> queryMemberByRoleId(String groupId){
|
||||
return getMapper().queryMemberByRoleId(groupId);
|
||||
}
|
||||
public List<UserInfo> queryMemberByRoleId(String groupId);
|
||||
|
||||
|
||||
public JpaPageResults<Roles> rolesNoMember(RoleMember entity) {
|
||||
entity.setPageSelectId(entity.generateId());
|
||||
entity.setStartRow(calculateStartRow(entity.getPageNumber() ,entity.getPageSize()));
|
||||
|
||||
entity.setPageable(true);
|
||||
List<Roles> resultslist = null;
|
||||
try {
|
||||
resultslist = getMapper().rolesNoMember(entity);
|
||||
} catch (Exception e) {
|
||||
_logger.error("fetchPageResults Exception " , e);
|
||||
}
|
||||
entity.setPageable(false);
|
||||
Integer totalPage = resultslist.size();
|
||||
|
||||
Integer totalCount = 0;
|
||||
if(entity.getPageNumber() == 1 && totalPage < entity.getPageSize()) {
|
||||
totalCount = totalPage;
|
||||
}else {
|
||||
totalCount = parseCount(getMapper().fetchCount(entity));
|
||||
}
|
||||
|
||||
return new JpaPageResults<Roles>(entity.getPageNumber(),entity.getPageSize(),totalPage,totalCount,resultslist);
|
||||
}
|
||||
public JpaPageResults<Roles> rolesNoMember(RoleMember entity) ;
|
||||
|
||||
}
|
||||
|
||||
@ -19,106 +19,21 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.entity.Institutions;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.RolesMapper;
|
||||
import org.dromara.maxkey.util.StrUtils;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class RolesService extends JpaService<Roles> {
|
||||
static final Logger _logger = LoggerFactory.getLogger(RolesService.class);
|
||||
|
||||
@Autowired
|
||||
RoleMemberService roleMemberService;
|
||||
|
||||
@Autowired
|
||||
InstitutionsService institutionsService;
|
||||
|
||||
public RolesService() {
|
||||
super(RolesMapper.class);
|
||||
}
|
||||
public interface RolesService extends IJpaService<Roles> {
|
||||
|
||||
@Override
|
||||
public RolesMapper getMapper() {
|
||||
return (RolesMapper)super.getMapper();
|
||||
}
|
||||
public List<Roles> queryDynamicRoles(Roles groups);
|
||||
|
||||
public boolean deleteById(String groupId);
|
||||
|
||||
public List<Roles> queryDynamicRoles(Roles groups){
|
||||
return this.getMapper().queryDynamicRoles(groups);
|
||||
}
|
||||
public List<Roles> queryRolesByUserId(String userId);
|
||||
|
||||
public boolean deleteById(String groupId) {
|
||||
this.delete(groupId);
|
||||
roleMemberService.deleteByRoleId(groupId);
|
||||
return true;
|
||||
}
|
||||
public void refreshDynamicRoles(Roles dynamicRole);
|
||||
|
||||
public List<Roles> queryRolesByUserId(String userId){
|
||||
return this.getMapper().queryRolesByUserId(userId);
|
||||
}
|
||||
|
||||
public void refreshDynamicRoles(Roles dynamicRole){
|
||||
if(dynamicRole.getCategory().equals(Roles.Category.DYNAMIC)) {
|
||||
|
||||
if(StringUtils.isNotBlank(dynamicRole.getOrgIdsList())) {
|
||||
String []orgIds = dynamicRole.getOrgIdsList().split(",");
|
||||
StringBuffer orgIdFilters = new StringBuffer();
|
||||
for(String orgId : orgIds) {
|
||||
if(StringUtils.isNotBlank(orgId)) {
|
||||
if(orgIdFilters.length() > 0) {
|
||||
orgIdFilters.append(",");
|
||||
}
|
||||
orgIdFilters.append("'").append(orgId).append("'");
|
||||
}
|
||||
}
|
||||
if(orgIdFilters.length() > 0) {
|
||||
dynamicRole.setOrgIdsList(orgIdFilters.toString());
|
||||
}
|
||||
}
|
||||
|
||||
String filters = dynamicRole.getFilters();
|
||||
_logger.debug("filters {}" , filters);
|
||||
if(StringUtils.isNotBlank(filters)) {
|
||||
if(StrUtils.filtersSQLInjection(filters.toLowerCase())) {
|
||||
_logger.info("filters include SQL Injection Attack Risk.");
|
||||
return;
|
||||
}
|
||||
//replace & with AND, | with OR
|
||||
filters = filters.replace("&", " AND ").replace("\\|", " OR ");
|
||||
|
||||
_logger.debug("set filters {}" , filters);
|
||||
dynamicRole.setFilters(filters);
|
||||
}
|
||||
|
||||
roleMemberService.deleteDynamicRoleMember(dynamicRole);
|
||||
roleMemberService.addDynamicRoleMember(dynamicRole);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshAllDynamicRoles(){
|
||||
List<Institutions> instList =
|
||||
institutionsService.find("where status = ? ", new Object[]{ConstsStatus.ACTIVE}, new int[]{Types.INTEGER});
|
||||
for(Institutions inst : instList) {
|
||||
Roles role = new Roles();
|
||||
role.setInstId(inst.getId());
|
||||
List<Roles> rolesList = queryDynamicRoles(role);
|
||||
for(Roles r : rolesList) {
|
||||
_logger.debug("role {}" , r);
|
||||
refreshDynamicRoles(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void refreshAllDynamicRoles();
|
||||
|
||||
}
|
||||
|
||||
@ -21,29 +21,11 @@ import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.SocialsAssociate;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.SocialsAssociateMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
|
||||
@Repository
|
||||
public class SocialsAssociatesService extends JpaService<SocialsAssociate>{
|
||||
|
||||
public SocialsAssociatesService() {
|
||||
super(SocialsAssociateMapper.class);
|
||||
}
|
||||
public interface SocialsAssociatesService extends IJpaService<SocialsAssociate>{
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public SocialsAssociateMapper getMapper() {
|
||||
return (SocialsAssociateMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
public List<SocialsAssociate> queryByUser(UserInfo user) {
|
||||
return getMapper().queryByUser(user);
|
||||
}
|
||||
public List<SocialsAssociate> queryByUser(UserInfo user);
|
||||
|
||||
}
|
||||
|
||||
@ -18,28 +18,8 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.SocialsProvider;
|
||||
import org.dromara.maxkey.persistence.mapper.SocialsProviderMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class SocialsProviderService extends JpaService<SocialsProvider>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(SocialsProviderService.class);
|
||||
|
||||
|
||||
public SocialsProviderService() {
|
||||
super(SocialsProviderMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public SocialsProviderMapper getMapper() {
|
||||
return (SocialsProviderMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public interface SocialsProviderService extends IJpaService<SocialsProvider>{
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,61 +17,19 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.SynchroRelated;
|
||||
import org.dromara.maxkey.entity.Synchronizers;
|
||||
import org.dromara.maxkey.entity.idm.Organizations;
|
||||
import org.dromara.maxkey.persistence.mapper.SynchroRelatedMapper;
|
||||
import org.dromara.maxkey.util.DateUtils;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
@Repository
|
||||
public class SynchroRelatedService extends JpaService<SynchroRelated>{
|
||||
public interface SynchroRelatedService extends IJpaService<SynchroRelated>{
|
||||
|
||||
public SynchroRelatedService() {
|
||||
super(SynchroRelatedMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public SynchroRelatedMapper getMapper() {
|
||||
return (SynchroRelatedMapper)super.getMapper();
|
||||
}
|
||||
public int updateSyncTime(SynchroRelated synchroRelated);
|
||||
|
||||
public int updateSyncTime(SynchroRelated synchroRelated) {
|
||||
return getMapper().updateSyncTime(synchroRelated);
|
||||
}
|
||||
public List<SynchroRelated> findOrgs(Synchronizers synchronizer) ;
|
||||
|
||||
public List<SynchroRelated> findOrgs(Synchronizers synchronizer) {
|
||||
return find(
|
||||
"instid = ? and syncid = ? and objecttype = ? ",
|
||||
new Object[] { synchronizer.getInstId() ,synchronizer.getId(),Organizations.CLASS_TYPE},
|
||||
new int[] { Types.VARCHAR,Types.VARCHAR,Types.VARCHAR}
|
||||
);
|
||||
}
|
||||
public SynchroRelated findByOriginId(Synchronizers synchronizer,String originId,String classType) ;
|
||||
|
||||
public SynchroRelated findByOriginId(Synchronizers synchronizer,String originId,String classType) {
|
||||
return findOne("instid = ? and syncId = ? and originid = ? and objecttype = ? ",
|
||||
new Object[] { synchronizer.getInstId(),synchronizer.getId(),originId,classType },
|
||||
new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,Types.VARCHAR});
|
||||
}
|
||||
|
||||
public void updateSynchroRelated(Synchronizers synchronizer,SynchroRelated synchroRelated,String classType) {
|
||||
SynchroRelated loadSynchroRelated =
|
||||
findByOriginId(
|
||||
synchronizer,synchroRelated.getOriginId(),classType );
|
||||
if(loadSynchroRelated == null) {
|
||||
insert(synchroRelated);
|
||||
}else {
|
||||
synchroRelated.setId(loadSynchroRelated.getId());
|
||||
synchroRelated.setSyncTime(DateUtils.formatDateTime(new Date()));
|
||||
updateSyncTime(synchroRelated);
|
||||
}
|
||||
}
|
||||
public void updateSynchroRelated(Synchronizers synchronizer,SynchroRelated synchroRelated,String classType) ;
|
||||
}
|
||||
|
||||
@ -18,30 +18,8 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.Synchronizers;
|
||||
import org.dromara.maxkey.persistence.mapper.SynchronizersMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class SynchronizersService extends JpaService<Synchronizers>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(SynchronizersService.class);
|
||||
|
||||
public SynchronizersService() {
|
||||
super(SynchronizersMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public SynchronizersMapper getMapper() {
|
||||
return (SynchronizersMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
public interface SynchronizersService extends IJpaService<Synchronizers>{
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -18,242 +18,42 @@
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.dromara.maxkey.entity.Accounts;
|
||||
import org.dromara.maxkey.entity.ChangePassword;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.UserInfoMapper;
|
||||
import org.dromara.maxkey.persistence.repository.PasswordPolicyValidator;
|
||||
import org.dromara.maxkey.provision.ProvisionAct;
|
||||
import org.dromara.maxkey.provision.ProvisionService;
|
||||
import org.dromara.maxkey.provision.ProvisionTopic;
|
||||
import org.dromara.maxkey.web.WebContext;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
|
||||
/**
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
@Repository
|
||||
public class UserInfoService extends JpaService<UserInfo> {
|
||||
static final Logger _logger = LoggerFactory.getLogger(UserInfoService.class);
|
||||
public interface UserInfoService extends IJpaService<UserInfo> {
|
||||
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
public boolean insert(UserInfo userInfo,boolean passwordEncoder) ;
|
||||
|
||||
@Autowired
|
||||
PasswordPolicyValidator passwordPolicyValidator;
|
||||
|
||||
@Autowired
|
||||
ProvisionService provisionService;
|
||||
|
||||
AccountsService accountsService;
|
||||
|
||||
public UserInfoService() {
|
||||
super(UserInfoMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public UserInfoMapper getMapper() {
|
||||
return (UserInfoMapper)super.getMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insert(UserInfo userInfo) {
|
||||
this.passwordEncoder(userInfo);
|
||||
if (super.insert(userInfo)) {
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
UserInfo loadUserInfo = findUserRelated(userInfo.getId());
|
||||
provisionService.send(
|
||||
ProvisionTopic.USERINFO_TOPIC,
|
||||
loadUserInfo,
|
||||
ProvisionAct.CREATE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean insert(UserInfo userInfo,boolean passwordEncoder) {
|
||||
if(passwordEncoder) {
|
||||
this.passwordEncoder(userInfo);
|
||||
}
|
||||
if (super.insert(userInfo)) {
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
UserInfo loadUserInfo = findUserRelated(userInfo.getId());
|
||||
provisionService.send(
|
||||
ProvisionTopic.USERINFO_TOPIC,
|
||||
loadUserInfo,
|
||||
ProvisionAct.CREATE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(UserInfo userInfo) {
|
||||
ChangePassword changePassword = this.passwordEncoder(userInfo);
|
||||
if (super.update(userInfo)) {
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
UserInfo loadUserInfo = findUserRelated(userInfo.getId());
|
||||
accountUpdate(loadUserInfo);
|
||||
provisionService.send(
|
||||
ProvisionTopic.USERINFO_TOPIC,
|
||||
loadUserInfo,
|
||||
ProvisionAct.UPDATE);
|
||||
}
|
||||
if(userInfo.getPassword() != null) {
|
||||
changePasswordProvisioning(changePassword);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean delete(UserInfo userInfo) {
|
||||
UserInfo loadUserInfo = null;
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
loadUserInfo = findUserRelated(userInfo.getId());
|
||||
}
|
||||
|
||||
if( super.delete(userInfo.getId())){
|
||||
provisionService.send(
|
||||
ProvisionTopic.USERINFO_TOPIC,
|
||||
loadUserInfo,
|
||||
ProvisionAct.DELETE);
|
||||
accountUpdate(loadUserInfo);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean delete(UserInfo userInfo) ;
|
||||
|
||||
//更新账号状态
|
||||
public void accountUpdate(UserInfo userInfo) {
|
||||
if(userInfo.getStatus() != ConstsStatus.ACTIVE) {
|
||||
if(accountsService==null) {
|
||||
accountsService =
|
||||
WebContext.getBean("accountsService",AccountsService.class);
|
||||
}
|
||||
Accounts queryAcount =new Accounts();
|
||||
queryAcount.setUserId(userInfo.getId());
|
||||
for (Accounts acount : accountsService.query(queryAcount)) {
|
||||
acount.setStatus(ConstsStatus.INACTIVE);
|
||||
accountsService.update(acount);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void accountUpdate(UserInfo userInfo) ;
|
||||
|
||||
public UserInfo findUserRelated(String userId) {
|
||||
UserInfo loadUserInfo =this.get(userId);
|
||||
loadUserInfo.setDepts(getMapper().findDeptsByUserId(userId));
|
||||
return loadUserInfo;
|
||||
}
|
||||
public UserInfo findUserRelated(String userId) ;
|
||||
|
||||
public boolean updateGridList(String gridList,UserInfo userInfo) {
|
||||
try {
|
||||
if (gridList != null && !gridList.equals("")) {
|
||||
userInfo.setGridList(Integer.parseInt(gridList));
|
||||
getMapper().updateGridList(userInfo);
|
||||
}
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean updateGridList(String gridList,UserInfo userInfo);
|
||||
|
||||
|
||||
public void saveOrUpdate(UserInfo userInfo) {
|
||||
UserInfo loadUserInfo = findOne(" username = ? and instid = ?",
|
||||
new Object[] { userInfo.getUsername(),userInfo.getInstId() },
|
||||
new int[] { Types.VARCHAR,Types.VARCHAR});
|
||||
if(loadUserInfo == null) {
|
||||
insert(userInfo);
|
||||
}else {
|
||||
userInfo.setId(loadUserInfo.getId());
|
||||
userInfo.setPassword(null);
|
||||
update(userInfo);
|
||||
}
|
||||
}
|
||||
public void saveOrUpdate(UserInfo userInfo) ;
|
||||
|
||||
public boolean updateProtectedApps(UserInfo userinfo) {
|
||||
try {
|
||||
userinfo.setModifiedDate(new Date());
|
||||
return getMapper().updateProtectedApps(userinfo) > 0;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean updateProtectedApps(UserInfo userinfo) ;
|
||||
|
||||
public UserInfo findByUsername(String username) {
|
||||
return getMapper().findByUsername(username);
|
||||
}
|
||||
public UserInfo findByUsername(String username) ;
|
||||
|
||||
public UserInfo findByEmailMobile(String emailMobile) {
|
||||
return getMapper().findByEmailMobile(emailMobile);
|
||||
}
|
||||
public UserInfo findByEmailMobile(String emailMobile) ;
|
||||
|
||||
public UserInfo findByAppIdAndUsername(String appId,String username){
|
||||
try {
|
||||
UserInfo userinfo = new UserInfo();
|
||||
userinfo.setUsername(username);
|
||||
return getMapper().findByAppIdAndUsername(userinfo) ;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public UserInfo findByAppIdAndUsername(String appId,String username);
|
||||
|
||||
public ChangePassword passwordEncoder(UserInfo userInfo) {
|
||||
ChangePassword changePassword = null;
|
||||
if(StringUtils.isNotBlank(userInfo.getPassword())) {
|
||||
changePassword = new ChangePassword(userInfo);
|
||||
passwordEncoder(changePassword);
|
||||
userInfo.setPassword(changePassword.getPassword());
|
||||
userInfo.setDecipherable(changePassword.getDecipherable());
|
||||
userInfo.setPasswordLastSetTime(changePassword.getPasswordLastSetTime());
|
||||
}else {
|
||||
userInfo.setPassword(null);
|
||||
userInfo.setDecipherable(null);
|
||||
}
|
||||
return changePassword;
|
||||
}
|
||||
public ChangePassword passwordEncoder(UserInfo userInfo) ;
|
||||
|
||||
public ChangePassword passwordEncoder(ChangePassword changePassword) {
|
||||
//密码不为空,则需要进行加密处理
|
||||
if(StringUtils.isNotBlank(changePassword.getPassword())) {
|
||||
String password = passwordEncoder.encode(changePassword.getPassword());
|
||||
changePassword.setDecipherable(PasswordReciprocal.getInstance().encode(changePassword.getPassword()));
|
||||
_logger.debug("decipherable : {}",changePassword.getDecipherable());
|
||||
changePassword.setPassword(password);
|
||||
changePassword.setPasswordLastSetTime(new Date());
|
||||
|
||||
}else {
|
||||
changePassword.setPassword(null);
|
||||
changePassword.setDecipherable(null);
|
||||
}
|
||||
return changePassword;
|
||||
}
|
||||
public ChangePassword passwordEncoder(ChangePassword changePassword) ;
|
||||
|
||||
/**
|
||||
* 认证密码修改
|
||||
@ -263,37 +63,7 @@ public class UserInfoService extends JpaService<UserInfo> {
|
||||
* @param passwordSetType
|
||||
* @return
|
||||
*/
|
||||
public boolean changePassword( ChangePassword changePassword) {
|
||||
try {
|
||||
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, "");
|
||||
UserInfo userInfo = this.findByUsername(changePassword.getUsername());
|
||||
if(changePassword.getPassword().equals(changePassword.getConfirmPassword())){
|
||||
if(StringUtils.isNotBlank(changePassword.getOldPassword()) &&
|
||||
passwordEncoder.matches(changePassword.getOldPassword(), userInfo.getPassword())){
|
||||
if(changePassword(changePassword,true) ){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}else {
|
||||
if(StringUtils.isNotBlank(changePassword.getOldPassword())&&
|
||||
passwordEncoder.matches(changePassword.getPassword(), userInfo.getPassword())) {
|
||||
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
|
||||
WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_MATCH"));
|
||||
}else {
|
||||
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
|
||||
WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_NOT_MATCH"));
|
||||
}
|
||||
}
|
||||
}else {
|
||||
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
|
||||
WebContext.getI18nValue("PasswordPolicy.CONFIRMPASSWORD_NOT_MATCH"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public boolean changePassword( ChangePassword changePassword) ;
|
||||
|
||||
/**
|
||||
* 后台密码修改
|
||||
@ -301,130 +71,47 @@ public class UserInfoService extends JpaService<UserInfo> {
|
||||
* @param passwordPolicy
|
||||
* @return
|
||||
*/
|
||||
public boolean changePassword(ChangePassword changePassword,boolean passwordPolicy) {
|
||||
try {
|
||||
_logger.debug("decipherable old : {}" , changePassword.getDecipherable());
|
||||
_logger.debug("decipherable new : {}" , PasswordReciprocal.getInstance().encode(changePassword.getDecipherable()));
|
||||
|
||||
if (passwordPolicy && !passwordPolicyValidator.validator(changePassword)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
changePassword = passwordEncoder(changePassword);
|
||||
|
||||
if (getMapper().changePassword(changePassword) > 0) {
|
||||
changePasswordProvisioning(changePassword);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public boolean changePassword(ChangePassword changePassword,boolean passwordPolicy) ;
|
||||
|
||||
public String randomPassword() {
|
||||
return passwordPolicyValidator.generateRandomPassword();
|
||||
}
|
||||
public String randomPassword() ;
|
||||
|
||||
public void changePasswordProvisioning(ChangePassword changePassworded) {
|
||||
if(changePassworded !=null && StringUtils.isNotBlank(changePassworded.getPassword())) {
|
||||
UserInfo loadUserInfo = findByUsername(changePassworded.getUsername());
|
||||
ChangePassword changePassword = new ChangePassword(loadUserInfo);
|
||||
provisionService.send(ProvisionTopic.PASSWORD_TOPIC, changePassword, ProvisionAct.PASSWORD);
|
||||
}
|
||||
}
|
||||
public void changePasswordProvisioning(ChangePassword changePassworded) ;
|
||||
|
||||
public boolean updateAppLoginPassword(UserInfo userinfo) {
|
||||
try {
|
||||
userinfo.setModifiedDate(new Date());
|
||||
return getMapper().updateAppLoginPassword(userinfo) > 0;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean updateAppLoginPassword(UserInfo userinfo) ;
|
||||
|
||||
|
||||
/**
|
||||
* 锁定用户:islock:1 用户解锁 2 用户锁定
|
||||
* @param userInfo
|
||||
*/
|
||||
public void updateLocked(UserInfo userInfo) {
|
||||
try {
|
||||
if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
|
||||
userInfo.setIsLocked(ConstsStatus.LOCK);
|
||||
getMapper().updateLocked(userInfo);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void updateLocked(UserInfo userInfo) ;
|
||||
|
||||
/**
|
||||
* 用户登录成功后,重置错误密码次数和解锁用户
|
||||
* @param userInfo
|
||||
*/
|
||||
public void updateLockout(UserInfo userInfo) {
|
||||
try {
|
||||
if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
|
||||
userInfo.setIsLocked(ConstsStatus.START);
|
||||
userInfo.setBadPasswordCount(0);
|
||||
getMapper().updateLockout(userInfo);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void updateLockout(UserInfo userInfo) ;
|
||||
|
||||
/**
|
||||
* 更新错误密码次数
|
||||
* @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 void updateBadPasswordCount(UserInfo userInfo) ;
|
||||
|
||||
public boolean updateSharedSecret(UserInfo userInfo){
|
||||
return getMapper().updateSharedSecret(userInfo)>0;
|
||||
}
|
||||
public boolean updateSharedSecret(UserInfo userInfo);
|
||||
|
||||
public boolean updatePasswordQuestion(UserInfo userInfo){
|
||||
return getMapper().updatePasswordQuestion(userInfo)>0;
|
||||
}
|
||||
public boolean updatePasswordQuestion(UserInfo userInfo);
|
||||
|
||||
public boolean updateAuthnType(UserInfo userInfo){
|
||||
return getMapper().updateAuthnType(userInfo)>0;
|
||||
}
|
||||
public boolean updateAuthnType(UserInfo userInfo);
|
||||
|
||||
public boolean updateEmail(UserInfo userInfo){
|
||||
return getMapper().updateEmail(userInfo)>0;
|
||||
}
|
||||
public boolean updateEmail(UserInfo userInfo);
|
||||
|
||||
public boolean updateMobile(UserInfo userInfo){
|
||||
return getMapper().updateMobile(userInfo)>0;
|
||||
}
|
||||
public boolean updateMobile(UserInfo userInfo);
|
||||
|
||||
public int updateProfile(UserInfo userInfo){
|
||||
return getMapper().updateProfile(userInfo);
|
||||
}
|
||||
public int updateProfile(UserInfo userInfo);
|
||||
|
||||
public boolean updateStatus(UserInfo userInfo) {
|
||||
return getMapper().updateStatus(userInfo) > 0;
|
||||
}
|
||||
public boolean updateStatus(UserInfo userInfo);
|
||||
|
||||
public void setPasswordPolicyValidator(PasswordPolicyValidator passwordPolicyValidator) {
|
||||
this.passwordPolicyValidator = passwordPolicyValidator;
|
||||
}
|
||||
public void setPasswordPolicyValidator(PasswordPolicyValidator passwordPolicyValidator);
|
||||
|
||||
}
|
||||
|
||||
@ -15,8 +15,14 @@
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Mysql DAO Mapper XML Configuration.
|
||||
*/
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.Access;
|
||||
import org.dromara.maxkey.persistence.mapper.AccessMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class AccessServiceImpl extends JpaServiceImpl<AccessMapper,Access>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,255 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.dromara.maxkey.entity.Accounts;
|
||||
import org.dromara.maxkey.entity.AccountsStrategy;
|
||||
import org.dromara.maxkey.entity.OrganizationsCast;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.AccountsMapper;
|
||||
import org.dromara.maxkey.persistence.service.AccountsStrategyService;
|
||||
import org.dromara.maxkey.persistence.service.OrganizationsCastService;
|
||||
import org.dromara.maxkey.persistence.service.UserInfoService;
|
||||
import org.dromara.maxkey.provision.ProvisionAct;
|
||||
import org.dromara.maxkey.provision.ProvisionService;
|
||||
import org.dromara.maxkey.provision.ProvisionTopic;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import net.sourceforge.pinyin4j.PinyinHelper;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
|
||||
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
||||
|
||||
@Repository
|
||||
public class AccountsServiceImpl extends JpaServiceImpl<AccountsMapper,Accounts>{
|
||||
|
||||
@Autowired
|
||||
ProvisionService provisionService;
|
||||
|
||||
@Autowired
|
||||
UserInfoService userInfoService;
|
||||
|
||||
@Autowired
|
||||
AccountsStrategyService accountsStrategyService;
|
||||
|
||||
@Autowired
|
||||
OrganizationsCastService organizationsCastService;
|
||||
|
||||
@Override
|
||||
public boolean insert(Accounts account) {
|
||||
if (super.insert(account)) {
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
|
||||
account.setUserInfo(loadUserInfo);
|
||||
OrganizationsCast cast = new OrganizationsCast();
|
||||
cast.setProvider(account.getAppId());
|
||||
cast.setOrgId(loadUserInfo.getDepartmentId());
|
||||
account.setOrgCast(organizationsCastService.query(cast));
|
||||
provisionService.send(
|
||||
ProvisionTopic.ACCOUNT_TOPIC,
|
||||
account,
|
||||
ProvisionAct.CREATE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(Accounts account) {
|
||||
if (super.update(account)) {
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
|
||||
account.setUserInfo(loadUserInfo);
|
||||
OrganizationsCast cast = new OrganizationsCast();
|
||||
cast.setProvider(account.getAppId());
|
||||
cast.setOrgId(loadUserInfo.getDepartmentId());
|
||||
account.setOrgCast(organizationsCastService.query(cast));
|
||||
provisionService.send(
|
||||
ProvisionTopic.ACCOUNT_TOPIC,
|
||||
account,
|
||||
ProvisionAct.UPDATE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateStatus(Accounts accounts) {
|
||||
return this.getMapper().updateStatus(accounts) > 0;
|
||||
}
|
||||
|
||||
public boolean remove(String id) {
|
||||
Accounts account = this.get(id);
|
||||
if (super.delete(id)) {
|
||||
UserInfo loadUserInfo = null;
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
loadUserInfo = userInfoService.findUserRelated(account.getUserId());
|
||||
account.setUserInfo(loadUserInfo);
|
||||
provisionService.send(
|
||||
ProvisionTopic.ACCOUNT_TOPIC,
|
||||
account,
|
||||
ProvisionAct.DELETE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
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());
|
||||
account.setRelatedUsername(generateAccount(user,strategy));
|
||||
account.setRelatedPassword(PasswordReciprocal.getInstance().encode(userInfoService.randomPassword()));
|
||||
|
||||
account.setInstId(strategy.getInstId());
|
||||
account.setCreateType("automatic");
|
||||
account.setStatus(ConstsStatus.ACTIVE);
|
||||
account.setStrategyId(strategy.getId());
|
||||
|
||||
insert(account);
|
||||
}
|
||||
deleteByStrategy(strategy);
|
||||
}
|
||||
public void refreshAllByStrategy() {
|
||||
AccountsStrategy queryStrategy = new AccountsStrategy();
|
||||
queryStrategy.setCreateType("automatic");
|
||||
for( AccountsStrategy strategy : accountsStrategyService.query(queryStrategy)) {
|
||||
refreshByStrategy(strategy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<UserInfo> queryUserNotInStrategy(AccountsStrategy strategy){
|
||||
return getMapper().queryUserNotInStrategy(strategy);
|
||||
}
|
||||
|
||||
public long deleteByStrategy(AccountsStrategy strategy) {
|
||||
return getMapper().deleteByStrategy(strategy);
|
||||
}
|
||||
|
||||
|
||||
public List<Accounts> queryByAppIdAndDate(Accounts account) {
|
||||
return getMapper().queryByAppIdAndDate(account);
|
||||
}
|
||||
|
||||
public List<Accounts> queryByAppIdAndAccount(String appId,String relatedUsername){
|
||||
return getMapper().queryByAppIdAndAccount(appId,relatedUsername);
|
||||
}
|
||||
|
||||
|
||||
public String generateAccount(UserInfo userInfo,AccountsStrategy accountsStrategy) {
|
||||
String shortAccount = generateAccount(userInfo,accountsStrategy,true);
|
||||
String account = generateAccount(userInfo,accountsStrategy,false);
|
||||
String accountResult = shortAccount;
|
||||
List<Accounts> accountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),shortAccount +accountsStrategy.getSuffixes());
|
||||
if(!accountsList.isEmpty()) {
|
||||
if(accountsStrategy.getMapping().equalsIgnoreCase("email")) {
|
||||
accountResult = account;
|
||||
accountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),account + accountsStrategy.getSuffixes());
|
||||
}
|
||||
if(!accountsList.isEmpty()) {
|
||||
for(int i =1 ;i < 100 ;i++) {
|
||||
accountResult = account + i;
|
||||
accountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),accountResult + accountsStrategy.getSuffixes());
|
||||
if(accountsList.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(accountsStrategy.getSuffixes())){
|
||||
accountResult = accountResult + accountsStrategy.getSuffixes();
|
||||
}
|
||||
return accountResult;
|
||||
}
|
||||
|
||||
|
||||
private String generateAccount(UserInfo userInfo,AccountsStrategy strategy,boolean isShort) {
|
||||
String account = "";
|
||||
if(strategy.getMapping().equalsIgnoreCase("username")) {
|
||||
account = userInfo.getUsername();
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("mobile")) {
|
||||
account = userInfo.getMobile();
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("email")) {
|
||||
try {
|
||||
if(isShort) {
|
||||
account = getPinYinShortName(userInfo.getDisplayName());
|
||||
}else {
|
||||
account = getPinYinName(userInfo.getDisplayName());
|
||||
}
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("employeeNumber")) {
|
||||
account = userInfo.getEmployeeNumber();
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("windowsAccount")) {
|
||||
account = userInfo.getWindowsAccount();
|
||||
}else if(strategy.getMapping().equalsIgnoreCase("idCardNo")) {
|
||||
account = userInfo.getIdCardNo();
|
||||
}else {
|
||||
account = userInfo.getUsername();
|
||||
}
|
||||
|
||||
return account;
|
||||
}
|
||||
|
||||
public static String getPinYinName(String name) throws BadHanyuPinyinOutputFormatCombination {
|
||||
HanyuPinyinOutputFormat pinyinFormat = new HanyuPinyinOutputFormat();
|
||||
pinyinFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
|
||||
pinyinFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
|
||||
pinyinFormat.setVCharType(HanyuPinyinVCharType.WITH_V);
|
||||
return PinyinHelper.toHanYuPinyinString(name, pinyinFormat, "",false);
|
||||
}
|
||||
|
||||
public static String getPinYinShortName(String name) throws BadHanyuPinyinOutputFormatCombination {
|
||||
char[] strs = name.toCharArray();
|
||||
String pinyinName = "";
|
||||
for(int i=0;i<strs.length;i++) {
|
||||
if(i == 0) {
|
||||
pinyinName += getPinYinName(strs[i]+"");
|
||||
}else {
|
||||
pinyinName += getPinYinName(strs[i]+"").charAt(0);
|
||||
}
|
||||
}
|
||||
return pinyinName;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.AccountsStrategy;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.AccountsStrategyMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class AccountsStrategyServiceImpl extends JpaServiceImpl<AccountsStrategyMapper,AccountsStrategy> {
|
||||
static final Logger _logger = LoggerFactory.getLogger(AccountsStrategyServiceImpl.class);
|
||||
|
||||
|
||||
|
||||
public List<Roles> queryDynamicGroups(Roles groups){
|
||||
return this.getMapper().queryDynamicGroups(groups);
|
||||
}
|
||||
|
||||
public boolean deleteById(String groupId) {
|
||||
this.delete(groupId);
|
||||
//groupMemberService.deleteByGroupId(groupId);
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
public void refreshDynamicGroups(Groups dynamicGroup){
|
||||
if(dynamicGroup.getDynamic().equals("1")) {
|
||||
boolean isDynamicTimeSupport = false;
|
||||
boolean isBetweenEffectiveTime = false;
|
||||
if(dynamicGroup.getResumeTime()!=null&&dynamicGroup.getResumeTime().equals("")
|
||||
&&dynamicGroup.getSuspendTime()!=null&&dynamicGroup.getSuspendTime().equals("")) {
|
||||
LocalTime currentTime = LocalDateTime.now().toLocalTime();
|
||||
LocalTime resumeTime = LocalTime.parse(dynamicGroup.getResumeTime());
|
||||
LocalTime suspendTime = LocalTime.parse(dynamicGroup.getSuspendTime());
|
||||
|
||||
_logger.info("currentTime: " + currentTime
|
||||
+ " , resumeTime : " + resumeTime
|
||||
+ " , suspendTime: " + suspendTime);
|
||||
isDynamicTimeSupport = true;
|
||||
|
||||
if(resumeTime.isBefore(currentTime) && currentTime.isBefore(suspendTime)) {
|
||||
isBetweenEffectiveTime = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(dynamicGroup.getOrgIdsList()!=null && !dynamicGroup.getOrgIdsList().equals("")) {
|
||||
dynamicGroup.setOrgIdsList("'"+dynamicGroup.getOrgIdsList().replace(",", "','")+"'");
|
||||
}
|
||||
String filters = dynamicGroup.getFilters();
|
||||
if(StringUtils.filtersSQLInjection(filters.toLowerCase())) {
|
||||
_logger.info("filters include SQL Injection Attack Risk.");
|
||||
return;
|
||||
}
|
||||
|
||||
filters = filters.replace("&", " AND ");
|
||||
filters = filters.replace("|", " OR ");
|
||||
|
||||
dynamicGroup.setFilters(filters);
|
||||
|
||||
if(isDynamicTimeSupport) {
|
||||
if(isBetweenEffectiveTime) {
|
||||
groupMemberService.deleteDynamicGroupMember(dynamicGroup);
|
||||
groupMemberService.addDynamicGroupMember(dynamicGroup);
|
||||
}else {
|
||||
groupMemberService.deleteDynamicGroupMember(dynamicGroup);
|
||||
}
|
||||
}else{
|
||||
groupMemberService.deleteDynamicGroupMember(dynamicGroup);
|
||||
groupMemberService.addDynamicGroupMember(dynamicGroup);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.AppsAdapters;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsAdaptersMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class AppsAdaptersServiceImpl extends JpaServiceImpl<AppsAdaptersMapper,AppsAdapters>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.AppsCasDetails;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsCasDetailsMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
|
||||
@Repository
|
||||
public class AppsCasDetailsServiceImpl extends JpaServiceImpl<AppsCasDetailsMapper,AppsCasDetails>{
|
||||
|
||||
protected static final Cache<String, AppsCasDetails> detailsCache =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.maximumSize(200000)
|
||||
.build();
|
||||
|
||||
public AppsCasDetails getAppDetails(String id , boolean cached) {
|
||||
AppsCasDetails details = null;
|
||||
if(cached) {
|
||||
details = detailsCache.getIfPresent(id);
|
||||
if(details == null) {
|
||||
details = getMapper().getAppDetails(id);
|
||||
if(details != null) {
|
||||
detailsCache.put(id, details);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
details = getMapper().getAppDetails(id);
|
||||
}
|
||||
return details;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.AppsFormBasedDetails;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsFormBasedDetailsMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
|
||||
@Repository
|
||||
public class AppsFormBasedDetailsServiceImpl extends JpaServiceImpl<AppsFormBasedDetailsMapper,AppsFormBasedDetails>{
|
||||
|
||||
protected static final Cache<String, AppsFormBasedDetails> detailsCache =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.maximumSize(200000)
|
||||
.build();
|
||||
|
||||
public AppsFormBasedDetails getAppDetails(String id,boolean cached) {
|
||||
AppsFormBasedDetails details = null;
|
||||
if(cached) {
|
||||
details = detailsCache.getIfPresent(id);
|
||||
if(details == null) {
|
||||
details = getMapper().getAppDetails(id);
|
||||
detailsCache.put(id, details);
|
||||
}
|
||||
}else {
|
||||
details = getMapper().getAppDetails(id);
|
||||
}
|
||||
return details;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.AppsJwtDetails;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsJwtDetailsMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
|
||||
@Repository
|
||||
public class AppsJwtDetailsServiceImpl extends JpaServiceImpl<AppsJwtDetailsMapper,AppsJwtDetails>{
|
||||
|
||||
protected static final Cache<String, AppsJwtDetails> detailsCache =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.maximumSize(200000)
|
||||
.build();
|
||||
|
||||
|
||||
public AppsJwtDetails getAppDetails(String id , boolean cached) {
|
||||
AppsJwtDetails details = null;
|
||||
if(cached) {
|
||||
details = detailsCache.getIfPresent(id);
|
||||
if(details == null) {
|
||||
details = getMapper().getAppDetails(id);
|
||||
detailsCache.put(id, details);
|
||||
}
|
||||
}else {
|
||||
details = getMapper().getAppDetails(id);
|
||||
}
|
||||
return details;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.AppsSAML20Details;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsSaml20DetailsMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
|
||||
@Repository
|
||||
public class AppsSaml20DetailsServiceImpl extends JpaServiceImpl<AppsSaml20DetailsMapper,AppsSAML20Details>{
|
||||
|
||||
protected static final Cache<String, AppsSAML20Details> detailsCache =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.maximumSize(200000)
|
||||
.build();
|
||||
|
||||
public AppsSAML20Details getAppDetails(String id , boolean cached){
|
||||
AppsSAML20Details details = null;
|
||||
if(cached) {
|
||||
details = detailsCache.getIfPresent(id);
|
||||
if(details == null) {
|
||||
details = getMapper().getAppDetails(id);
|
||||
detailsCache.put(id, details);
|
||||
}
|
||||
}else {
|
||||
details = getMapper().getAppDetails(id);
|
||||
}
|
||||
return details;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.Apps;
|
||||
import org.dromara.maxkey.entity.apps.UserApps;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
|
||||
@Repository
|
||||
public class AppsServiceImpl extends JpaServiceImpl<AppsMapper,Apps>{
|
||||
//maxkey-mgt
|
||||
public static final String MGT_APP_ID = "622076759805923328";
|
||||
|
||||
public static final String DETAIL_SUFFIX = "_detail";
|
||||
|
||||
protected static final Cache<String, Apps> detailsCacheStore =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.build();
|
||||
|
||||
public boolean insertApp(Apps app) {
|
||||
return ((AppsMapper)super.getMapper()).insertApp(app)>0;
|
||||
};
|
||||
public boolean updateApp(Apps app) {
|
||||
return ((AppsMapper)super.getMapper()).updateApp(app)>0;
|
||||
};
|
||||
|
||||
public boolean updateExtendAttr(Apps app) {
|
||||
return ((AppsMapper)super.getMapper()).updateExtendAttr(app)>0;
|
||||
}
|
||||
|
||||
public List<UserApps> queryMyApps(UserApps userApplications){
|
||||
return getMapper().queryMyApps(userApplications);
|
||||
}
|
||||
|
||||
//cache for running
|
||||
public void put(String appId, Apps appDetails) {
|
||||
detailsCacheStore.put(appId + DETAIL_SUFFIX, appDetails);
|
||||
}
|
||||
|
||||
public Apps get(String appId, boolean cached) {
|
||||
appId = appId.equalsIgnoreCase("maxkey_mgt") ? MGT_APP_ID : appId;
|
||||
Apps appDetails = null;
|
||||
if(cached) {
|
||||
appDetails = detailsCacheStore.getIfPresent(appId + DETAIL_SUFFIX);
|
||||
if(appDetails == null) {
|
||||
appDetails = this.get(appId);
|
||||
detailsCacheStore.put(appId, appDetails);
|
||||
}
|
||||
}else {
|
||||
appDetails = this.get(appId);
|
||||
}
|
||||
return appDetails;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.dromara.maxkey.entity.apps.AppsTokenBasedDetails;
|
||||
import org.dromara.maxkey.persistence.mapper.AppsTokenBasedDetailsMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
|
||||
@Repository
|
||||
public class AppsTokenBasedDetailsServiceImpl extends JpaServiceImpl<AppsTokenBasedDetailsMapper,AppsTokenBasedDetails>{
|
||||
|
||||
protected static final Cache<String, AppsTokenBasedDetails> detailsCache =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.maximumSize(200000)
|
||||
.build();
|
||||
|
||||
public AppsTokenBasedDetails getAppDetails(String id , boolean cached) {
|
||||
AppsTokenBasedDetails details = null;
|
||||
if(cached) {
|
||||
details = detailsCache.getIfPresent(id);
|
||||
if(details == null) {
|
||||
details = getMapper().getAppDetails(id);
|
||||
detailsCache.put(id, details);
|
||||
}
|
||||
}else {
|
||||
details = getMapper().getAppDetails(id);
|
||||
}
|
||||
return details;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
|
||||
import org.dromara.maxkey.entity.cnf.CnfEmailSenders;
|
||||
import org.dromara.maxkey.persistence.mapper.CnfEmailSendersMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Repository
|
||||
public class CnfEmailSendersServiceImpl extends JpaServiceImpl<CnfEmailSendersMapper,CnfEmailSenders>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.cnf.CnfLdapContext;
|
||||
import org.dromara.maxkey.persistence.mapper.CnfLdapContextMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Repository
|
||||
public class CnfLdapContextServiceImpl extends JpaServiceImpl<CnfLdapContextMapper,CnfLdapContext>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.cnf.CnfPasswordPolicy;
|
||||
import org.dromara.maxkey.persistence.mapper.CnfPasswordPolicyMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class CnfPasswordPolicyServiceImpl extends JpaServiceImpl<CnfPasswordPolicyMapper,CnfPasswordPolicy>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.cnf.CnfSmsProvider;
|
||||
import org.dromara.maxkey.persistence.mapper.CnfSmsProviderMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Repository
|
||||
public class CnfSmsProviderServiceImpl extends JpaServiceImpl<CnfSmsProviderMapper,CnfSmsProvider>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.Connectors;
|
||||
import org.dromara.maxkey.persistence.mapper.ConnectorsMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class ConnectorsServiceImpl extends JpaServiceImpl<ConnectorsMapper,Connectors>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.FileUpload;
|
||||
import org.dromara.maxkey.persistence.mapper.FileUploadMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class FileUploadServiceImpl extends JpaServiceImpl<FileUploadMapper,FileUpload>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.idm.GroupMember;
|
||||
import org.dromara.maxkey.entity.idm.Groups;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.GroupMemberMapper;
|
||||
import org.dromara.mybatis.jpa.entity.JpaPageResults;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class GroupMemberServiceImpl extends JpaServiceImpl<GroupMemberMapper,GroupMember>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(GroupMemberServiceImpl.class);
|
||||
|
||||
public int addDynamicMember(Groups dynamicGroup) {
|
||||
return getMapper().addDynamicMember(dynamicGroup);
|
||||
}
|
||||
|
||||
public int deleteDynamicMember(Groups dynamicGroup) {
|
||||
return getMapper().deleteDynamicMember(dynamicGroup);
|
||||
}
|
||||
|
||||
public int deleteByGroupId(String groupId) {
|
||||
return getMapper().deleteByGroupId(groupId);
|
||||
}
|
||||
|
||||
public List<UserInfo> queryMemberByGroupId(String groupId){
|
||||
return getMapper().queryMemberByGroupId(groupId);
|
||||
}
|
||||
|
||||
|
||||
public JpaPageResults<Groups> noMember(GroupMember entity) {
|
||||
entity.setPageSelectId(entity.generateId());
|
||||
entity.setStartRow(calculateStartRow(entity.getPageNumber() ,entity.getPageSize()));
|
||||
|
||||
entity.setPageable(true);
|
||||
List<Groups> resultslist = null;
|
||||
try {
|
||||
resultslist = getMapper().noMember(entity);
|
||||
} catch (Exception e) {
|
||||
_logger.error("queryPageResults Exception " , e);
|
||||
}
|
||||
entity.setPageable(false);
|
||||
Integer totalPage = resultslist.size();
|
||||
|
||||
Integer totalCount = 0;
|
||||
if(entity.getPageNumber() == 1 && totalPage < entity.getPageSize()) {
|
||||
totalCount = totalPage;
|
||||
}else {
|
||||
totalCount = parseCount(getMapper().fetchCount(entity));
|
||||
}
|
||||
|
||||
return new JpaPageResults<Groups>(entity.getPageNumber(),entity.getPageSize(),totalPage,totalCount,resultslist);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.entity.Institutions;
|
||||
import org.dromara.maxkey.entity.idm.Groups;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.GroupsMapper;
|
||||
import org.dromara.maxkey.util.StrUtils;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class GroupsServiceImpl extends JpaServiceImpl<GroupsMapper,Groups>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(GroupsServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
GroupMemberServiceImpl groupMemberService;
|
||||
|
||||
@Autowired
|
||||
InstitutionsServiceImpl institutionsService;
|
||||
|
||||
public List<Groups> queryDynamicGroups(Groups groups){
|
||||
return this.getMapper().queryDynamic(groups);
|
||||
}
|
||||
|
||||
public boolean deleteById(String groupId) {
|
||||
this.delete(groupId);
|
||||
groupMemberService.deleteByGroupId(groupId);
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<Groups> queryByUserId(String userId){
|
||||
return this.getMapper().queryByUserId(userId);
|
||||
}
|
||||
|
||||
public void refreshDynamicGroups(Groups dynamicGroup){
|
||||
if(dynamicGroup.getCategory().equals(Roles.Category.DYNAMIC)) {
|
||||
|
||||
if(StringUtils.isNotBlank(dynamicGroup.getOrgIdsList())) {
|
||||
String []orgIds = dynamicGroup.getOrgIdsList().split(",");
|
||||
StringBuffer orgIdFilters = new StringBuffer();
|
||||
for(String orgId : orgIds) {
|
||||
if(StringUtils.isNotBlank(orgId)) {
|
||||
if(orgIdFilters.length() > 0) {
|
||||
orgIdFilters.append(",");
|
||||
}
|
||||
orgIdFilters.append("'").append(orgId).append("'");
|
||||
}
|
||||
}
|
||||
if(orgIdFilters.length() > 0) {
|
||||
dynamicGroup.setOrgIdsList(orgIdFilters.toString());
|
||||
}
|
||||
}
|
||||
|
||||
String filters = dynamicGroup.getFilters();
|
||||
if(StringUtils.isNotBlank(filters)) {
|
||||
if(StrUtils.filtersSQLInjection(filters.toLowerCase())) {
|
||||
_logger.info("filters include SQL Injection Attack Risk.");
|
||||
return;
|
||||
}
|
||||
//replace & with AND, | with OR
|
||||
filters = filters.replace("&", " AND ").replace("|", " OR ");
|
||||
|
||||
dynamicGroup.setFilters(filters);
|
||||
}
|
||||
|
||||
groupMemberService.deleteDynamicMember(dynamicGroup);
|
||||
groupMemberService.addDynamicMember(dynamicGroup);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshAllDynamicGroups(){
|
||||
List<Institutions> instList =
|
||||
institutionsService.find("where status = ? ", new Object[]{ConstsStatus.ACTIVE}, new int[]{Types.INTEGER});
|
||||
for(Institutions inst : instList) {
|
||||
Groups group = new Groups();
|
||||
group.setInstId(inst.getId());
|
||||
List<Groups> groupsList = queryDynamicGroups(group);
|
||||
for(Groups g : groupsList) {
|
||||
_logger.debug("role {}" , g);
|
||||
refreshDynamicGroups(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.history.HistoryConnector;
|
||||
import org.dromara.maxkey.persistence.mapper.HistoryConnectorMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class HistoryConnectorServiceImpl extends JpaServiceImpl<HistoryConnectorMapper,HistoryConnector>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.history.HistoryLoginApps;
|
||||
import org.dromara.maxkey.persistence.mapper.HistoryLoginAppsMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class HistoryLoginAppsServiceImpl extends JpaServiceImpl<HistoryLoginAppsMapper,HistoryLoginApps>{
|
||||
|
||||
@Override
|
||||
public boolean insert(HistoryLoginApps loginAppsHistory){
|
||||
//new Thread insert login app history
|
||||
new Thread(new HistoryLoginAppsRunnable(getMapper(),loginAppsHistory)).start();
|
||||
return true;
|
||||
}
|
||||
|
||||
public class HistoryLoginAppsRunnable implements Runnable{
|
||||
|
||||
HistoryLoginAppsMapper historyLoginAppsMapper;
|
||||
|
||||
HistoryLoginApps loginAppsHistory;
|
||||
|
||||
public HistoryLoginAppsRunnable(HistoryLoginAppsMapper historyLoginAppsMapper,
|
||||
HistoryLoginApps loginAppsHistory) {
|
||||
super();
|
||||
this.historyLoginAppsMapper = historyLoginAppsMapper;
|
||||
this.loginAppsHistory = loginAppsHistory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
historyLoginAppsMapper.insert(loginAppsHistory);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.history.HistoryLogin;
|
||||
import org.dromara.maxkey.persistence.mapper.HistoryLoginMapper;
|
||||
import org.dromara.mybatis.jpa.entity.JpaPageResults;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class HistoryLoginServiceImpl extends JpaServiceImpl<HistoryLoginMapper,HistoryLogin>{
|
||||
|
||||
public JpaPageResults<HistoryLogin> queryOnlineSession(HistoryLogin historyLogin) {
|
||||
return this.fetchPageResults("queryOnlineSession",historyLogin);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.history.HistorySynchronizer;
|
||||
import org.dromara.maxkey.persistence.mapper.HistorySynchronizerMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class HistorySynchronizerServiceImpl extends JpaServiceImpl<HistorySynchronizerMapper,HistorySynchronizer>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.Accounts;
|
||||
import org.dromara.maxkey.entity.ChangePassword;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.dromara.maxkey.entity.Access;
|
||||
import org.dromara.maxkey.entity.SocialsProvider;
|
||||
import org.dromara.maxkey.entity.Synchronizers;
|
||||
import org.dromara.maxkey.entity.history.HistorySystemLogs;
|
||||
import org.dromara.maxkey.entity.idm.Organizations;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.entity.permissions.Permission;
|
||||
import org.dromara.maxkey.entity.permissions.Resources;
|
||||
import org.dromara.maxkey.entity.permissions.RoleMember;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.HistorySystemLogsMapper;
|
||||
import org.dromara.maxkey.util.JsonUtils;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class HistorySystemLogsServiceImpl extends JpaServiceImpl<HistorySystemLogsMapper,HistorySystemLogs>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(HistorySystemLogsServiceImpl.class);
|
||||
|
||||
public void insert(String topic,Object entity,String action,String result,UserInfo operator) {
|
||||
String message = "";
|
||||
if(entity != null) {
|
||||
if(entity instanceof UserInfo userInfo) {
|
||||
message = buildMsg(userInfo);
|
||||
}else if(entity instanceof Organizations organization) {
|
||||
message = buildMsg(organization);
|
||||
}else if(entity instanceof ChangePassword changePassword) {
|
||||
message = buildMsg(changePassword);
|
||||
}else if(entity instanceof Accounts account) {
|
||||
message = buildMsg(account);
|
||||
}else if(entity instanceof Roles role) {
|
||||
message = buildMsg(role);
|
||||
}else if(entity instanceof RoleMember roleMember) {
|
||||
message = buildMsg(roleMember);
|
||||
}else if(entity instanceof Access access) {
|
||||
message = buildMsg(access);
|
||||
}else if(entity instanceof Resources resource) {
|
||||
message = buildMsg(resource);
|
||||
}else if(entity instanceof Synchronizers synchronizer) {
|
||||
message = buildMsg(synchronizer);
|
||||
}else if(entity instanceof SocialsProvider socialsProvider) {
|
||||
message = buildMsg(socialsProvider);
|
||||
}else if(entity instanceof Permission permission) {
|
||||
message = buildMsg(permission);
|
||||
}else if(entity instanceof String) {
|
||||
message = entity.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
insert(topic,message,action,result,operator, entity);
|
||||
}
|
||||
|
||||
public void insert(String topic,String message,String action,String result,UserInfo operator,Object entity) {
|
||||
HistorySystemLogs systemLog = new HistorySystemLogs();
|
||||
systemLog.setId(systemLog.generateId());
|
||||
systemLog.setTopic(topic);
|
||||
systemLog.setMessage(message);
|
||||
systemLog.setMessageAction(action);
|
||||
systemLog.setMessageResult(result);
|
||||
systemLog.setUserId(operator.getId());
|
||||
systemLog.setUsername(operator.getUsername());
|
||||
systemLog.setDisplayName(operator.getDisplayName());
|
||||
systemLog.setInstId(operator.getInstId());
|
||||
systemLog.setJsonCotent(JsonUtils.gsonToString(entity));
|
||||
systemLog.setExecuteTime(new Date());
|
||||
_logger.trace("System Log {}" ,systemLog);
|
||||
getMapper().insert(systemLog);
|
||||
}
|
||||
|
||||
public String buildMsg(UserInfo userInfo) {
|
||||
return new StringBuilder()
|
||||
.append(userInfo.getDisplayName())
|
||||
.append("[")
|
||||
.append(userInfo.getUsername())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(Organizations org) {
|
||||
return new StringBuilder()
|
||||
.append(org.getOrgName())
|
||||
.append("[")
|
||||
.append(org.getOrgCode())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(Accounts account) {
|
||||
return new StringBuilder()
|
||||
.append(account.getRelatedUsername())
|
||||
.append("[")
|
||||
.append(account.getDisplayName()).append(",")
|
||||
.append(account.getUsername()).append(",")
|
||||
.append(account.getAppName())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(ChangePassword changePassword) {
|
||||
return new StringBuilder()
|
||||
.append(changePassword.getDisplayName())
|
||||
.append("[")
|
||||
.append(changePassword.getUsername())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(Roles g) {
|
||||
return new StringBuilder()
|
||||
.append(g.getRoleName())
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(RoleMember rm) {
|
||||
return new StringBuilder()
|
||||
.append(rm.getRoleName())
|
||||
.append("[")
|
||||
.append(rm.getUsername()).append(",")
|
||||
.append(rm.getDisplayName())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(Access permission) {
|
||||
return new StringBuilder()
|
||||
.append(permission.getGroupName())
|
||||
.append("[")
|
||||
.append(permission.getAppName())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(Permission privilege) {
|
||||
return new StringBuilder()
|
||||
.append(privilege.getGroupId())
|
||||
.append("[")
|
||||
.append(privilege.getResourceId())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
|
||||
public String buildMsg(Resources r) {
|
||||
return new StringBuilder()
|
||||
.append(r.getResourceName())
|
||||
.append("[")
|
||||
.append(r.getResourceType())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
|
||||
public String buildMsg(Synchronizers s) {
|
||||
return new StringBuilder()
|
||||
.append(s.getName())
|
||||
.append("[")
|
||||
.append(s.getSourceType()).append(",")
|
||||
.append(s.getScheduler()).append(",")
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(SocialsProvider s) {
|
||||
return new StringBuilder()
|
||||
.append(s.getProviderName())
|
||||
.append("[")
|
||||
.append(s.getProvider())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.Institutions;
|
||||
import org.dromara.maxkey.persistence.mapper.InstitutionsMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Repository
|
||||
public class InstitutionsServiceImpl extends JpaServiceImpl<InstitutionsMapper,Institutions>{
|
||||
|
||||
public Institutions findByDomain(String domain) {
|
||||
return getMapper().findByDomain(domain);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.OrganizationsCast;
|
||||
import org.dromara.maxkey.persistence.mapper.OrganizationsCastMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Repository
|
||||
public class OrganizationsCastServiceImpl extends JpaServiceImpl<OrganizationsCastMapper,OrganizationsCast>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(OrganizationsCastServiceImpl.class);
|
||||
|
||||
|
||||
public boolean updateCast(OrganizationsCast organizationsCast) {
|
||||
return getMapper().updateCast(organizationsCast) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.dromara.maxkey.entity.idm.Organizations;
|
||||
import org.dromara.maxkey.persistence.mapper.OrganizationsMapper;
|
||||
import org.dromara.maxkey.provision.ProvisionAct;
|
||||
import org.dromara.maxkey.provision.ProvisionService;
|
||||
import org.dromara.maxkey.provision.ProvisionTopic;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Repository
|
||||
public class OrganizationsServiceImpl extends JpaServiceImpl<OrganizationsMapper,Organizations>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(OrganizationsServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
ProvisionService provisionService;
|
||||
|
||||
@Override
|
||||
public boolean insert(Organizations organization) {
|
||||
if(super.insert(organization)){
|
||||
provisionService.send(
|
||||
ProvisionTopic.ORG_TOPIC, organization, ProvisionAct.CREATE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(Organizations organization) {
|
||||
if(super.update(organization)){
|
||||
provisionService.send(
|
||||
ProvisionTopic.ORG_TOPIC, organization, ProvisionAct.UPDATE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void saveOrUpdate(Organizations organization) {
|
||||
Organizations loadOrg =findOne(" id = ? and instid = ?",
|
||||
new Object[] { organization.getId(), organization.getInstId() },
|
||||
new int[] { Types.VARCHAR, Types.VARCHAR });
|
||||
if( loadOrg == null) {
|
||||
insert(organization);
|
||||
}else {
|
||||
organization.setId(organization.getId());
|
||||
update(organization);
|
||||
}
|
||||
}
|
||||
public List<Organizations> queryOrgs(Organizations organization){
|
||||
return getMapper().queryOrgs(organization);
|
||||
}
|
||||
|
||||
public boolean delete(Organizations organization) {
|
||||
if(super.delete(organization.getId())){
|
||||
provisionService.send(
|
||||
ProvisionTopic.ORG_TOPIC, organization, ProvisionAct.DELETE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void reorgNamePath(String instId) {
|
||||
_logger.debug("instId {}", instId);
|
||||
if (StringUtils.isBlank(instId)) {
|
||||
instId = "1";
|
||||
}
|
||||
|
||||
HashMap<String, Organizations> reorgOrgMap = new HashMap<>();
|
||||
List<Organizations> orgList = find(" where instid ='" + instId + "'");
|
||||
List<Organizations> originOrgList = new ArrayList<>();
|
||||
Organizations rootOrg = null;
|
||||
for (Organizations org : orgList) {
|
||||
reorgOrgMap.put(org.getId(), org);
|
||||
if (isRootOrg(org)) {
|
||||
rootOrg = org;
|
||||
}
|
||||
Organizations cloneOrg = new Organizations();
|
||||
BeanUtils.copyProperties(org, cloneOrg);
|
||||
originOrgList.add(cloneOrg);
|
||||
}
|
||||
try {
|
||||
reorg(reorgOrgMap, orgList, rootOrg);
|
||||
_logger.debug("reorged .");
|
||||
long reorgCount = 0;
|
||||
for (Organizations originOrg : originOrgList) {
|
||||
Organizations reorgOrg = reorgOrgMap.get(originOrg.getId());
|
||||
_logger.trace("reorged Organization {}", reorgOrg);
|
||||
if (originOrg.getNamePath() == null || !originOrg.getNamePath().equals(reorgOrg.getNamePath())) {
|
||||
_logger.debug("update reorgCount {} , Organization {}", ++reorgCount, reorgOrg);
|
||||
getMapper().updateNamePath(reorgOrg);
|
||||
}
|
||||
}
|
||||
_logger.debug("reorg finished .");
|
||||
} catch (Exception e) {
|
||||
_logger.error("reorgNamePath Exception ", e);
|
||||
}
|
||||
}
|
||||
|
||||
boolean isRootOrg(Organizations rootOrg) {
|
||||
if (rootOrg.getParentId() == null || rootOrg.getParentId().equalsIgnoreCase("-1")
|
||||
|| rootOrg.getParentId().equalsIgnoreCase(rootOrg.getId())
|
||||
|| rootOrg.getParentId().equalsIgnoreCase(rootOrg.getInstId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void reorg(HashMap<String, Organizations> orgMap, List<Organizations> orgList, Organizations rootOrg) {
|
||||
if (isRootOrg(rootOrg)) {
|
||||
rootOrg.setCodePath("/" + rootOrg.getId() + "/");
|
||||
rootOrg.setNamePath("/" + rootOrg.getOrgName() + "/");
|
||||
} else {
|
||||
Organizations parent = orgMap.get(rootOrg.getParentId());
|
||||
rootOrg.setCodePath(parent.getCodePath() + rootOrg.getId() + "/");
|
||||
rootOrg.setNamePath(parent.getNamePath() + rootOrg.getOrgName() + "/");
|
||||
}
|
||||
rootOrg.setReorgNamePath(true);
|
||||
|
||||
for (Organizations org : orgList) {
|
||||
if (org.isReorgNamePath())
|
||||
continue;
|
||||
if (org.getParentId().equalsIgnoreCase(rootOrg.getId())) {
|
||||
reorg(orgMap, orgList, org);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 根据数据格式返回数据
|
||||
*
|
||||
* @param cell
|
||||
* @return
|
||||
*/
|
||||
public static String getValue(Cell cell) {
|
||||
if (cell == null) {
|
||||
return "";
|
||||
} else if (cell.getCellType() == CellType.BOOLEAN) {
|
||||
return String.valueOf(cell.getBooleanCellValue());
|
||||
} else if (cell.getCellType() == CellType.NUMERIC) {
|
||||
cell.setBlank();
|
||||
return String.valueOf(cell.getStringCellValue().trim());
|
||||
} else {
|
||||
return String.valueOf(cell.getStringCellValue().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.permissions.PermissionRole;
|
||||
import org.dromara.maxkey.persistence.mapper.PermissionRoleMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class PermissionRoleServiceImpl extends JpaServiceImpl<PermissionRoleMapper,PermissionRole>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(PermissionRoleServiceImpl.class);
|
||||
|
||||
|
||||
public boolean insertPermissionRoles(List<PermissionRole> permissionRolesList) {
|
||||
return getMapper().insertPermissionRoles(permissionRolesList)>0;
|
||||
}
|
||||
|
||||
public boolean deletePermissionRoles(List<PermissionRole> permissionRolesList) {
|
||||
return getMapper().deletePermissionRoles(permissionRolesList)>=0;
|
||||
}
|
||||
|
||||
public List<PermissionRole> queryPermissionRoles(PermissionRole permissionRole){
|
||||
return getMapper().queryPermissionRoles(permissionRole);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.permissions.Permission;
|
||||
import org.dromara.maxkey.persistence.mapper.PermissionMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class PermissionServiceImpl extends JpaServiceImpl<PermissionMapper,Permission>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(PermissionServiceImpl.class);
|
||||
|
||||
public boolean insertGroupPrivileges(List<Permission> rolePermissionsList) {
|
||||
return getMapper().insertGroupPrivileges(rolePermissionsList)>0;
|
||||
};
|
||||
|
||||
public boolean deleteGroupPrivileges(List<Permission> rolePermissionsList) {
|
||||
return getMapper().deleteGroupPrivileges(rolePermissionsList)>=0;
|
||||
}
|
||||
|
||||
public List<Permission> queryGroupPrivileges(Permission rolePermissions){
|
||||
return getMapper().queryGroupPrivileges(rolePermissions);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.Register;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.RegisterMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class RegisterServiceImpl extends JpaServiceImpl<RegisterMapper,Register>{
|
||||
|
||||
public UserInfo findByEmail(String email){
|
||||
List<UserInfo> listUserInfo=getMapper().findByEmail(email);
|
||||
return listUserInfo.size()>0?listUserInfo.get(0):null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.dromara.maxkey.persistence.mapper.ReportMapper;
|
||||
import org.dromara.mybatis.jpa.entity.JpaEntity;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class ReportServiceImpl extends JpaServiceImpl<ReportMapper,JpaEntity>{
|
||||
|
||||
public Integer analysisDay(HashMap<String,Object> reportParameter) {
|
||||
return getMapper().analysisDay(reportParameter);
|
||||
};
|
||||
|
||||
public Integer analysisNewUsers(HashMap<String,Object> reportParameter) {
|
||||
return getMapper().analysisNewUsers(reportParameter);
|
||||
};
|
||||
|
||||
public Integer analysisOnlineUsers(HashMap<String,Object> reportParameter) {
|
||||
return getMapper().analysisOnlineUsers(reportParameter);
|
||||
};
|
||||
|
||||
public Integer analysisActiveUsers(HashMap<String,Object> reportParameter) {
|
||||
return getMapper().analysisActiveUsers(reportParameter);
|
||||
};
|
||||
|
||||
public List<Map<String,Object>> analysisDayHour(HashMap<String,Object> reportParameter){
|
||||
return getMapper().analysisDayHour(reportParameter);
|
||||
}
|
||||
|
||||
public List<Map<String,Object>> analysisMonth(HashMap<String,Object> reportParameter){
|
||||
return getMapper().analysisMonth(reportParameter);
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,Object>> analysisBrowser(HashMap<String,Object> reportParameter){
|
||||
return getMapper().analysisBrowser(reportParameter);
|
||||
}
|
||||
|
||||
public List<Map<String,Object>> analysisApp(HashMap<String,Object> reportParameter){
|
||||
return getMapper().analysisApp(reportParameter);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.permissions.Resources;
|
||||
import org.dromara.maxkey.persistence.mapper.ResourcesMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class ResourcesServiceImpl extends JpaServiceImpl<ResourcesMapper,Resources>{
|
||||
|
||||
public List<Resources> queryResourcesTree(Resources resource){
|
||||
return getMapper().fetchPageResults(resource);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.entity.permissions.RoleMember;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.RoleMemberMapper;
|
||||
import org.dromara.mybatis.jpa.entity.JpaPageResults;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class RoleMemberServiceImpl extends JpaServiceImpl<RoleMemberMapper,RoleMember>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(RoleMemberServiceImpl.class);
|
||||
|
||||
public int addDynamicRoleMember(Roles dynamicGroup) {
|
||||
return getMapper().addDynamicRoleMember(dynamicGroup);
|
||||
}
|
||||
|
||||
public int deleteDynamicRoleMember(Roles dynamicGroup) {
|
||||
return getMapper().deleteDynamicRoleMember(dynamicGroup);
|
||||
}
|
||||
|
||||
public int deleteByRoleId(String groupId) {
|
||||
return getMapper().deleteByRoleId(groupId);
|
||||
}
|
||||
|
||||
public List<UserInfo> queryMemberByRoleId(String groupId){
|
||||
return getMapper().queryMemberByRoleId(groupId);
|
||||
}
|
||||
|
||||
|
||||
public JpaPageResults<Roles> rolesNoMember(RoleMember entity) {
|
||||
entity.setPageSelectId(entity.generateId());
|
||||
entity.setStartRow(calculateStartRow(entity.getPageNumber() ,entity.getPageSize()));
|
||||
|
||||
entity.setPageable(true);
|
||||
List<Roles> resultslist = null;
|
||||
try {
|
||||
resultslist = getMapper().rolesNoMember(entity);
|
||||
} catch (Exception e) {
|
||||
_logger.error("fetchPageResults Exception " , e);
|
||||
}
|
||||
entity.setPageable(false);
|
||||
Integer totalPage = resultslist.size();
|
||||
|
||||
Integer totalCount = 0;
|
||||
if(entity.getPageNumber() == 1 && totalPage < entity.getPageSize()) {
|
||||
totalCount = totalPage;
|
||||
}else {
|
||||
totalCount = parseCount(getMapper().fetchCount(entity));
|
||||
}
|
||||
|
||||
return new JpaPageResults<Roles>(entity.getPageNumber(),entity.getPageSize(),totalPage,totalCount,resultslist);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.entity.Institutions;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.RolesMapper;
|
||||
import org.dromara.maxkey.util.StrUtils;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class RolesServiceImpl extends JpaServiceImpl<RolesMapper,Roles> {
|
||||
static final Logger _logger = LoggerFactory.getLogger(RolesServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
RoleMemberServiceImpl roleMemberService;
|
||||
|
||||
@Autowired
|
||||
InstitutionsServiceImpl institutionsService;
|
||||
|
||||
|
||||
public List<Roles> queryDynamicRoles(Roles groups){
|
||||
return this.getMapper().queryDynamicRoles(groups);
|
||||
}
|
||||
|
||||
public boolean deleteById(String groupId) {
|
||||
this.delete(groupId);
|
||||
roleMemberService.deleteByRoleId(groupId);
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<Roles> queryRolesByUserId(String userId){
|
||||
return this.getMapper().queryRolesByUserId(userId);
|
||||
}
|
||||
|
||||
public void refreshDynamicRoles(Roles dynamicRole){
|
||||
if(dynamicRole.getCategory().equals(Roles.Category.DYNAMIC)) {
|
||||
|
||||
if(StringUtils.isNotBlank(dynamicRole.getOrgIdsList())) {
|
||||
String []orgIds = dynamicRole.getOrgIdsList().split(",");
|
||||
StringBuffer orgIdFilters = new StringBuffer();
|
||||
for(String orgId : orgIds) {
|
||||
if(StringUtils.isNotBlank(orgId)) {
|
||||
if(orgIdFilters.length() > 0) {
|
||||
orgIdFilters.append(",");
|
||||
}
|
||||
orgIdFilters.append("'").append(orgId).append("'");
|
||||
}
|
||||
}
|
||||
if(orgIdFilters.length() > 0) {
|
||||
dynamicRole.setOrgIdsList(orgIdFilters.toString());
|
||||
}
|
||||
}
|
||||
|
||||
String filters = dynamicRole.getFilters();
|
||||
_logger.debug("filters {}" , filters);
|
||||
if(StringUtils.isNotBlank(filters)) {
|
||||
if(StrUtils.filtersSQLInjection(filters.toLowerCase())) {
|
||||
_logger.info("filters include SQL Injection Attack Risk.");
|
||||
return;
|
||||
}
|
||||
//replace & with AND, | with OR
|
||||
filters = filters.replace("&", " AND ").replace("\\|", " OR ");
|
||||
|
||||
_logger.debug("set filters {}" , filters);
|
||||
dynamicRole.setFilters(filters);
|
||||
}
|
||||
|
||||
roleMemberService.deleteDynamicRoleMember(dynamicRole);
|
||||
roleMemberService.addDynamicRoleMember(dynamicRole);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshAllDynamicRoles(){
|
||||
List<Institutions> instList =
|
||||
institutionsService.find("where status = ? ", new Object[]{ConstsStatus.ACTIVE}, new int[]{Types.INTEGER});
|
||||
for(Institutions inst : instList) {
|
||||
Roles role = new Roles();
|
||||
role.setInstId(inst.getId());
|
||||
List<Roles> rolesList = queryDynamicRoles(role);
|
||||
for(Roles r : rolesList) {
|
||||
_logger.debug("role {}" , r);
|
||||
refreshDynamicRoles(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.SocialsAssociate;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.SocialsAssociateMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Repository
|
||||
public class SocialsAssociatesServiceImpl extends JpaServiceImpl<SocialsAssociateMapper,SocialsAssociate>{
|
||||
|
||||
public List<SocialsAssociate> queryByUser(UserInfo user) {
|
||||
return getMapper().queryByUser(user);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.SocialsProvider;
|
||||
import org.dromara.maxkey.persistence.mapper.SocialsProviderMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class SocialsProviderServiceImpl extends JpaServiceImpl<SocialsProviderMapper,SocialsProvider>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(SocialsProviderServiceImpl.class);
|
||||
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.SynchroRelated;
|
||||
import org.dromara.maxkey.entity.Synchronizers;
|
||||
import org.dromara.maxkey.entity.idm.Organizations;
|
||||
import org.dromara.maxkey.persistence.mapper.SynchroRelatedMapper;
|
||||
import org.dromara.maxkey.util.DateUtils;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class SynchroRelatedServiceImpl extends JpaServiceImpl<SynchroRelatedMapper,SynchroRelated>{
|
||||
|
||||
public int updateSyncTime(SynchroRelated synchroRelated) {
|
||||
return getMapper().updateSyncTime(synchroRelated);
|
||||
}
|
||||
|
||||
public List<SynchroRelated> findOrgs(Synchronizers synchronizer) {
|
||||
return find(
|
||||
"instid = ? and syncid = ? and objecttype = ? ",
|
||||
new Object[] { synchronizer.getInstId() ,synchronizer.getId(),Organizations.CLASS_TYPE},
|
||||
new int[] { Types.VARCHAR,Types.VARCHAR,Types.VARCHAR}
|
||||
);
|
||||
}
|
||||
|
||||
public SynchroRelated findByOriginId(Synchronizers synchronizer,String originId,String classType) {
|
||||
return findOne("instid = ? and syncId = ? and originid = ? and objecttype = ? ",
|
||||
new Object[] { synchronizer.getInstId(),synchronizer.getId(),originId,classType },
|
||||
new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,Types.VARCHAR});
|
||||
}
|
||||
|
||||
public void updateSynchroRelated(Synchronizers synchronizer,SynchroRelated synchroRelated,String classType) {
|
||||
SynchroRelated loadSynchroRelated =
|
||||
findByOriginId(
|
||||
synchronizer,synchroRelated.getOriginId(),classType );
|
||||
if(loadSynchroRelated == null) {
|
||||
insert(synchroRelated);
|
||||
}else {
|
||||
synchroRelated.setId(loadSynchroRelated.getId());
|
||||
synchroRelated.setSyncTime(DateUtils.formatDateTime(new Date()));
|
||||
updateSyncTime(synchroRelated);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.Synchronizers;
|
||||
import org.dromara.maxkey.persistence.mapper.SynchronizersMapper;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class SynchronizersServiceImpl extends JpaServiceImpl<SynchronizersMapper,Synchronizers>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(SynchronizersServiceImpl.class);
|
||||
|
||||
}
|
||||
@ -0,0 +1,420 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service.impl;
|
||||
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.dromara.maxkey.entity.Accounts;
|
||||
import org.dromara.maxkey.entity.ChangePassword;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.UserInfoMapper;
|
||||
import org.dromara.maxkey.persistence.repository.PasswordPolicyValidator;
|
||||
import org.dromara.maxkey.persistence.service.AccountsService;
|
||||
import org.dromara.maxkey.provision.ProvisionAct;
|
||||
import org.dromara.maxkey.provision.ProvisionService;
|
||||
import org.dromara.maxkey.provision.ProvisionTopic;
|
||||
import org.dromara.maxkey.web.WebContext;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
/**
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
@Repository
|
||||
public class UserInfoServiceImpl extends JpaServiceImpl<UserInfoMapper,UserInfo> {
|
||||
static final Logger _logger = LoggerFactory.getLogger(UserInfoServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
@Autowired
|
||||
PasswordPolicyValidator passwordPolicyValidator;
|
||||
|
||||
@Autowired
|
||||
ProvisionService provisionService;
|
||||
|
||||
AccountsService accountsService;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean insert(UserInfo userInfo) {
|
||||
this.passwordEncoder(userInfo);
|
||||
if (super.insert(userInfo)) {
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
UserInfo loadUserInfo = findUserRelated(userInfo.getId());
|
||||
provisionService.send(
|
||||
ProvisionTopic.USERINFO_TOPIC,
|
||||
loadUserInfo,
|
||||
ProvisionAct.CREATE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean insert(UserInfo userInfo,boolean passwordEncoder) {
|
||||
if(passwordEncoder) {
|
||||
this.passwordEncoder(userInfo);
|
||||
}
|
||||
if (super.insert(userInfo)) {
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
UserInfo loadUserInfo = findUserRelated(userInfo.getId());
|
||||
provisionService.send(
|
||||
ProvisionTopic.USERINFO_TOPIC,
|
||||
loadUserInfo,
|
||||
ProvisionAct.CREATE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(UserInfo userInfo) {
|
||||
ChangePassword changePassword = this.passwordEncoder(userInfo);
|
||||
if (super.update(userInfo)) {
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
UserInfo loadUserInfo = findUserRelated(userInfo.getId());
|
||||
accountUpdate(loadUserInfo);
|
||||
provisionService.send(
|
||||
ProvisionTopic.USERINFO_TOPIC,
|
||||
loadUserInfo,
|
||||
ProvisionAct.UPDATE);
|
||||
}
|
||||
if(userInfo.getPassword() != null) {
|
||||
changePasswordProvisioning(changePassword);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean delete(UserInfo userInfo) {
|
||||
UserInfo loadUserInfo = null;
|
||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||
loadUserInfo = findUserRelated(userInfo.getId());
|
||||
}
|
||||
|
||||
if( super.delete(userInfo.getId())){
|
||||
provisionService.send(
|
||||
ProvisionTopic.USERINFO_TOPIC,
|
||||
loadUserInfo,
|
||||
ProvisionAct.DELETE);
|
||||
accountUpdate(loadUserInfo);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//更新账号状态
|
||||
public void accountUpdate(UserInfo userInfo) {
|
||||
if(userInfo.getStatus() != ConstsStatus.ACTIVE) {
|
||||
if(accountsService==null) {
|
||||
accountsService =
|
||||
WebContext.getBean("accountsService",AccountsService.class);
|
||||
}
|
||||
Accounts queryAcount =new Accounts();
|
||||
queryAcount.setUserId(userInfo.getId());
|
||||
for (Accounts acount : accountsService.query(queryAcount)) {
|
||||
acount.setStatus(ConstsStatus.INACTIVE);
|
||||
accountsService.update(acount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UserInfo findUserRelated(String userId) {
|
||||
UserInfo loadUserInfo =this.get(userId);
|
||||
loadUserInfo.setDepts(getMapper().findDeptsByUserId(userId));
|
||||
return loadUserInfo;
|
||||
}
|
||||
|
||||
public boolean updateGridList(String gridList,UserInfo userInfo) {
|
||||
try {
|
||||
if (gridList != null && !gridList.equals("")) {
|
||||
userInfo.setGridList(Integer.parseInt(gridList));
|
||||
getMapper().updateGridList(userInfo);
|
||||
}
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void saveOrUpdate(UserInfo userInfo) {
|
||||
UserInfo loadUserInfo = findOne(" username = ? and instid = ?",
|
||||
new Object[] { userInfo.getUsername(),userInfo.getInstId() },
|
||||
new int[] { Types.VARCHAR,Types.VARCHAR});
|
||||
if(loadUserInfo == null) {
|
||||
insert(userInfo);
|
||||
}else {
|
||||
userInfo.setId(loadUserInfo.getId());
|
||||
userInfo.setPassword(null);
|
||||
update(userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean updateProtectedApps(UserInfo userinfo) {
|
||||
try {
|
||||
userinfo.setModifiedDate(new Date());
|
||||
return getMapper().updateProtectedApps(userinfo) > 0;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public UserInfo findByUsername(String username) {
|
||||
return getMapper().findByUsername(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().findByAppIdAndUsername(userinfo) ;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ChangePassword passwordEncoder(UserInfo userInfo) {
|
||||
ChangePassword changePassword = null;
|
||||
if(StringUtils.isNotBlank(userInfo.getPassword())) {
|
||||
changePassword = new ChangePassword(userInfo);
|
||||
passwordEncoder(changePassword);
|
||||
userInfo.setPassword(changePassword.getPassword());
|
||||
userInfo.setDecipherable(changePassword.getDecipherable());
|
||||
userInfo.setPasswordLastSetTime(changePassword.getPasswordLastSetTime());
|
||||
}else {
|
||||
userInfo.setPassword(null);
|
||||
userInfo.setDecipherable(null);
|
||||
}
|
||||
return changePassword;
|
||||
}
|
||||
|
||||
public ChangePassword passwordEncoder(ChangePassword changePassword) {
|
||||
//密码不为空,则需要进行加密处理
|
||||
if(StringUtils.isNotBlank(changePassword.getPassword())) {
|
||||
String password = passwordEncoder.encode(changePassword.getPassword());
|
||||
changePassword.setDecipherable(PasswordReciprocal.getInstance().encode(changePassword.getPassword()));
|
||||
_logger.debug("decipherable : {}",changePassword.getDecipherable());
|
||||
changePassword.setPassword(password);
|
||||
changePassword.setPasswordLastSetTime(new Date());
|
||||
|
||||
}else {
|
||||
changePassword.setPassword(null);
|
||||
changePassword.setDecipherable(null);
|
||||
}
|
||||
return changePassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 认证密码修改
|
||||
* @param oldPassword
|
||||
* @param newPassword
|
||||
* @param confirmPassword
|
||||
* @param passwordSetType
|
||||
* @return
|
||||
*/
|
||||
public boolean changePassword( ChangePassword changePassword) {
|
||||
try {
|
||||
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, "");
|
||||
UserInfo userInfo = this.findByUsername(changePassword.getUsername());
|
||||
if(changePassword.getPassword().equals(changePassword.getConfirmPassword())){
|
||||
if(StringUtils.isNotBlank(changePassword.getOldPassword()) &&
|
||||
passwordEncoder.matches(changePassword.getOldPassword(), userInfo.getPassword())){
|
||||
if(changePassword(changePassword,true) ){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}else {
|
||||
if(StringUtils.isNotBlank(changePassword.getOldPassword())&&
|
||||
passwordEncoder.matches(changePassword.getPassword(), userInfo.getPassword())) {
|
||||
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
|
||||
WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_MATCH"));
|
||||
}else {
|
||||
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
|
||||
WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_NOT_MATCH"));
|
||||
}
|
||||
}
|
||||
}else {
|
||||
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
|
||||
WebContext.getI18nValue("PasswordPolicy.CONFIRMPASSWORD_NOT_MATCH"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台密码修改
|
||||
* @param changeUserInfo
|
||||
* @param passwordPolicy
|
||||
* @return
|
||||
*/
|
||||
public boolean changePassword(ChangePassword changePassword,boolean passwordPolicy) {
|
||||
try {
|
||||
_logger.debug("decipherable old : {}" , changePassword.getDecipherable());
|
||||
_logger.debug("decipherable new : {}" , PasswordReciprocal.getInstance().encode(changePassword.getDecipherable()));
|
||||
|
||||
if (passwordPolicy && !passwordPolicyValidator.validator(changePassword)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
changePassword = passwordEncoder(changePassword);
|
||||
|
||||
if (getMapper().changePassword(changePassword) > 0) {
|
||||
changePasswordProvisioning(changePassword);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public String randomPassword() {
|
||||
return passwordPolicyValidator.generateRandomPassword();
|
||||
}
|
||||
|
||||
public void changePasswordProvisioning(ChangePassword changePassworded) {
|
||||
if(changePassworded !=null && StringUtils.isNotBlank(changePassworded.getPassword())) {
|
||||
UserInfo loadUserInfo = findByUsername(changePassworded.getUsername());
|
||||
ChangePassword changePassword = new ChangePassword(loadUserInfo);
|
||||
provisionService.send(ProvisionTopic.PASSWORD_TOPIC, changePassword, ProvisionAct.PASSWORD);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean updateAppLoginPassword(UserInfo userinfo) {
|
||||
try {
|
||||
userinfo.setModifiedDate(new Date());
|
||||
return getMapper().updateAppLoginPassword(userinfo) > 0;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 锁定用户:islock:1 用户解锁 2 用户锁定
|
||||
* @param userInfo
|
||||
*/
|
||||
public void updateLocked(UserInfo userInfo) {
|
||||
try {
|
||||
if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
|
||||
userInfo.setIsLocked(ConstsStatus.LOCK);
|
||||
getMapper().updateLocked(userInfo);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登录成功后,重置错误密码次数和解锁用户
|
||||
* @param userInfo
|
||||
*/
|
||||
public void updateLockout(UserInfo userInfo) {
|
||||
try {
|
||||
if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
|
||||
userInfo.setIsLocked(ConstsStatus.START);
|
||||
userInfo.setBadPasswordCount(0);
|
||||
getMapper().updateLockout(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 updateSharedSecret(UserInfo userInfo){
|
||||
return getMapper().updateSharedSecret(userInfo)>0;
|
||||
}
|
||||
|
||||
public boolean updatePasswordQuestion(UserInfo userInfo){
|
||||
return getMapper().updatePasswordQuestion(userInfo)>0;
|
||||
}
|
||||
|
||||
public boolean updateAuthnType(UserInfo userInfo){
|
||||
return getMapper().updateAuthnType(userInfo)>0;
|
||||
}
|
||||
|
||||
public boolean updateEmail(UserInfo userInfo){
|
||||
return getMapper().updateEmail(userInfo)>0;
|
||||
}
|
||||
|
||||
public boolean updateMobile(UserInfo userInfo){
|
||||
return getMapper().updateMobile(userInfo)>0;
|
||||
}
|
||||
|
||||
public int updateProfile(UserInfo userInfo){
|
||||
return getMapper().updateProfile(userInfo);
|
||||
}
|
||||
|
||||
public boolean updateStatus(UserInfo userInfo) {
|
||||
return getMapper().updateStatus(userInfo) > 0;
|
||||
}
|
||||
|
||||
public void setPasswordPolicyValidator(PasswordPolicyValidator passwordPolicyValidator) {
|
||||
this.passwordPolicyValidator = passwordPolicyValidator;
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,42 +2,16 @@ package org.dromara.maxkey.synchronizer.service;
|
||||
|
||||
import org.dromara.maxkey.entity.SyncJobConfigField;
|
||||
|
||||
import org.dromara.maxkey.persistence.mapper.SyncJobConfigFieldMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import org.dromara.mybatis.jpa.IJpaService;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SyncJobConfigFieldService extends JpaService<SyncJobConfigField> {
|
||||
public SyncJobConfigFieldService() {
|
||||
super(SyncJobConfigFieldMapper.class);
|
||||
}
|
||||
@Override
|
||||
public SyncJobConfigFieldMapper getMapper() {
|
||||
return (SyncJobConfigFieldMapper)super.getMapper();
|
||||
}
|
||||
public interface SyncJobConfigFieldService extends IJpaService<SyncJobConfigField> {
|
||||
|
||||
public List<SyncJobConfigField> findByJobIdAndObjectType(Long jobId, String objectType) {
|
||||
public List<SyncJobConfigField> findByJobIdAndObjectType(Long jobId, String objectType) ;
|
||||
|
||||
return getMapper().findByJobIdAndObjectType(jobId,objectType);
|
||||
}
|
||||
public void deleteFieldMapById(Long id);
|
||||
|
||||
public void deleteFieldMapById(Long id){
|
||||
ArrayList<String> ids = new ArrayList<>();
|
||||
ids.add(String.valueOf(id));
|
||||
super.deleteBatch(ids);
|
||||
}
|
||||
|
||||
public List<SyncJobConfigField> findByJobId(Long jobId) {
|
||||
List<SyncJobConfigField> list = find(" jobid = ?",
|
||||
new Object[]{jobId},
|
||||
new int[]{Types.BIGINT});
|
||||
return list;
|
||||
|
||||
}
|
||||
public List<SyncJobConfigField> findByJobId(Long jobId) ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package org.dromara.maxkey.synchronizer.service.impl;
|
||||
|
||||
import org.dromara.maxkey.entity.SyncJobConfigField;
|
||||
|
||||
import org.dromara.maxkey.persistence.mapper.SyncJobConfigFieldMapper;
|
||||
import org.dromara.maxkey.synchronizer.service.SyncJobConfigFieldService;
|
||||
import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SyncJobConfigFieldServiceImpl extends JpaServiceImpl<SyncJobConfigFieldMapper,SyncJobConfigField> implements SyncJobConfigFieldService {
|
||||
|
||||
public List<SyncJobConfigField> findByJobIdAndObjectType(Long jobId, String objectType) {
|
||||
|
||||
return getMapper().findByJobIdAndObjectType(jobId,objectType);
|
||||
}
|
||||
|
||||
public void deleteFieldMapById(Long id){
|
||||
ArrayList<String> ids = new ArrayList<>();
|
||||
ids.add(String.valueOf(id));
|
||||
super.deleteBatch(ids);
|
||||
}
|
||||
|
||||
public List<SyncJobConfigField> findByJobId(Long jobId) {
|
||||
List<SyncJobConfigField> list = find(" jobid = ?",
|
||||
new Object[]{jobId},
|
||||
new int[]{Types.BIGINT});
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
echo off
|
||||
echo set env
|
||||
set JAVA_HOME=C:\IDE\jdk-17.0.2.8
|
||||
set JAVA_HOME=C:\ide\jdk-17.0.9+9
|
||||
set GRADLE_HOME=C:\ide\gradle-8.8
|
||||
|
||||
set MXK_VERSION=4.1.2
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user