Accounts Strategy
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.maxkey.persistence.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
|
||||
import org.maxkey.entity.AccountsStrategy;
|
||||
import org.maxkey.entity.Groups;
|
||||
|
||||
/**
|
||||
* @author Crystal.sea
|
||||
*
|
||||
*/
|
||||
|
||||
public interface AccountsStrategyMapper extends IJpaBaseMapper<AccountsStrategy> {
|
||||
|
||||
public List<Groups> queryDynamicGroups(Groups groups);
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* 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.maxkey.persistence.service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
||||
import org.maxkey.entity.AccountsStrategy;
|
||||
import org.maxkey.entity.Groups;
|
||||
import org.maxkey.persistence.mapper.AccountsStrategyMapper;
|
||||
import org.maxkey.persistence.mapper.GroupsMapper;
|
||||
import org.maxkey.util.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
@Repository
|
||||
public class AccountsStrategyService extends JpaBaseService<AccountsStrategy> implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -921086134545225302L;
|
||||
|
||||
final static Logger _logger = LoggerFactory.getLogger(AccountsStrategyService.class);
|
||||
/*
|
||||
@JsonIgnore
|
||||
@Autowired
|
||||
@Qualifier("groupMemberService")
|
||||
GroupMemberService accountsStrategyService;
|
||||
*/
|
||||
public AccountsStrategyService() {
|
||||
super(AccountsStrategyMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public AccountsStrategyMapper getMapper() {
|
||||
// TODO Auto-generated method stub
|
||||
return (AccountsStrategyMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
public List<Groups> queryDynamicGroups(Groups groups){
|
||||
return this.getMapper().queryDynamicGroups(groups);
|
||||
}
|
||||
|
||||
public boolean deleteById(String groupId) {
|
||||
this.remove(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,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.maxkey.persistence.mapper.AccountsStrategyMapper">
|
||||
|
||||
<sql id="where_statement">
|
||||
<if test="id != null and id != ''">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="appId != null and appId != ''">
|
||||
and appid = #{appId}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and name = #{name}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
|
||||
|
||||
<select id="queryPageResults" parameterType="AccountsStrategy" resultType="AccountsStrategy">
|
||||
select
|
||||
*
|
||||
from
|
||||
mxk_accounts_strategy
|
||||
where
|
||||
(1=1)
|
||||
<include refid="where_statement"/>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user