synchronizer optimize
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.maxkey.persistence.mapper;
|
||||
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
|
||||
import org.maxkey.entity.SocialsAssociate;
|
||||
|
||||
public interface SocialsAssociateMapper extends IJpaBaseMapper<SocialsAssociate> {
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.maxkey.persistence.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
|
||||
import org.maxkey.entity.SynchroRelated;
|
||||
|
||||
/**
|
||||
* @author Crystal.sea
|
||||
*
|
||||
*/
|
||||
public interface SynchroRelatedMapper extends IJpaBaseMapper<SynchroRelated> {
|
||||
@Update("update mxk_synchro_related set synctime = #{syncTime} where id= #{id} ")
|
||||
public int updateSyncTime(SynchroRelated synchroRelated);
|
||||
}
|
||||
+4
-2
@@ -68,11 +68,13 @@ public class OrganizationsService extends JpaBaseService<Organizations>{
|
||||
}
|
||||
|
||||
public void saveOrUpdate(Organizations organization) {
|
||||
if(findOne(" id = ? and instid = ?",
|
||||
Organizations loadOrg =findOne(" id = ? and instid = ?",
|
||||
new Object[] { organization.getId().toString(), organization.getInstId() },
|
||||
new int[] { Types.VARCHAR, Types.VARCHAR }) == null) {
|
||||
new int[] { Types.VARCHAR, Types.VARCHAR });
|
||||
if( loadOrg == null) {
|
||||
insert(organization);
|
||||
}else {
|
||||
organization.setId(organization.getId());
|
||||
update(organization);
|
||||
}
|
||||
}
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.maxkey.persistence.service;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
||||
import org.maxkey.entity.SocialsAssociate;
|
||||
import org.maxkey.persistence.mapper.SocialsAssociateMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Repository
|
||||
public class SocialsAssociatesService extends JpaBaseService<SocialsAssociate>{
|
||||
|
||||
public SocialsAssociatesService() {
|
||||
super(SocialsAssociateMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public SocialsAssociateMapper getMapper() {
|
||||
return (SocialsAssociateMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+77
@@ -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.maxkey.persistence.service;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
||||
import org.maxkey.entity.Organizations;
|
||||
import org.maxkey.entity.SynchroRelated;
|
||||
import org.maxkey.entity.Synchronizers;
|
||||
import org.maxkey.persistence.mapper.SynchroRelatedMapper;
|
||||
import org.maxkey.util.DateUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class SynchroRelatedService extends JpaBaseService<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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -166,11 +166,13 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
||||
|
||||
|
||||
public void saveOrUpdate(UserInfo userInfo) {
|
||||
if(findOne(" username = ? and instid = ?",
|
||||
UserInfo loadUserInfo = findOne(" username = ? and instid = ?",
|
||||
new Object[] { userInfo.getUsername(),userInfo.getInstId() },
|
||||
new int[] { Types.VARCHAR,Types.VARCHAR}) == null) {
|
||||
new int[] { Types.VARCHAR,Types.VARCHAR});
|
||||
if(loadUserInfo == null) {
|
||||
insert(userInfo);
|
||||
}else {
|
||||
userInfo.setId(loadUserInfo.getId());
|
||||
userInfo.setPassword(null);
|
||||
update(userInfo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user