|
@@ -23,8 +23,16 @@ import org.hswebframework.web.id.IDGenerator;
|
|
import org.hswebframework.web.service.AbstractTreeSortService;
|
|
import org.hswebframework.web.service.AbstractTreeSortService;
|
|
import org.hswebframework.web.service.organizational.OrganizationalService;
|
|
import org.hswebframework.web.service.organizational.OrganizationalService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.cache.annotation.CacheConfig;
|
|
|
|
+import org.springframework.cache.annotation.CacheEvict;
|
|
|
|
+import org.springframework.cache.annotation.Cacheable;
|
|
|
|
+import org.springframework.cache.annotation.Caching;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
+import java.util.Collection;
|
|
|
|
+import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -33,6 +41,7 @@ import java.util.Objects;
|
|
* @author hsweb-generator-online
|
|
* @author hsweb-generator-online
|
|
*/
|
|
*/
|
|
@Service("organizationalService")
|
|
@Service("organizationalService")
|
|
|
|
+@CacheConfig(cacheNames = "organizational")
|
|
public class SimpleOrganizationalService extends AbstractTreeSortService<OrganizationalEntity, String>
|
|
public class SimpleOrganizationalService extends AbstractTreeSortService<OrganizationalEntity, String>
|
|
implements OrganizationalService {
|
|
implements OrganizationalService {
|
|
@Autowired
|
|
@Autowired
|
|
@@ -49,12 +58,52 @@ public class SimpleOrganizationalService extends AbstractTreeSortService<Organiz
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @Caching(evict = {
|
|
|
|
+ @CacheEvict(key = "'id:'+#result"),
|
|
|
|
+ @CacheEvict(key = "'code:'+#entity.code"),
|
|
|
|
+ @CacheEvict(allEntries = true, condition = "#entity.children!=null")
|
|
|
|
+ })
|
|
public String insert(OrganizationalEntity entity) {
|
|
public String insert(OrganizationalEntity entity) {
|
|
entity.setStatus(DataStatus.STATUS_ENABLED);
|
|
entity.setStatus(DataStatus.STATUS_ENABLED);
|
|
return super.insert(entity);
|
|
return super.insert(entity);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @Cacheable(key = "'id:'+#id")
|
|
|
|
+ public OrganizationalEntity selectByPk(String id) {
|
|
|
|
+ return super.selectByPk(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @CacheEvict(allEntries = true)
|
|
|
|
+ public int updateByPk(List<OrganizationalEntity> data) {
|
|
|
|
+ return super.updateByPk(data);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Caching(evict = {
|
|
|
|
+ @CacheEvict(key = "'id:'+#id"),
|
|
|
|
+ @CacheEvict(key = "'code:'+#entity.code"),
|
|
|
|
+ @CacheEvict(allEntries = true, condition = "#entity.children!=null")
|
|
|
|
+ })
|
|
|
|
+ @Override
|
|
|
|
+ public int updateByPk(String id, OrganizationalEntity entity) {
|
|
|
|
+ return super.updateByPk(id, entity);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @CacheEvict(allEntries = true)
|
|
|
|
+ public int updateBatch(Collection<OrganizationalEntity> data) {
|
|
|
|
+ return super.updateBatch(data);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @CacheEvict(allEntries = true)
|
|
|
|
+ public int deleteByPk(String id) {
|
|
|
|
+ return super.deleteByPk(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @CacheEvict(allEntries = true)
|
|
public void disable(String id) {
|
|
public void disable(String id) {
|
|
Objects.requireNonNull(id);
|
|
Objects.requireNonNull(id);
|
|
createUpdate()
|
|
createUpdate()
|
|
@@ -64,6 +113,7 @@ public class SimpleOrganizationalService extends AbstractTreeSortService<Organiz
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @CacheEvict(allEntries = true)
|
|
public void enable(String id) {
|
|
public void enable(String id) {
|
|
Objects.requireNonNull(id);
|
|
Objects.requireNonNull(id);
|
|
createUpdate()
|
|
createUpdate()
|
|
@@ -71,4 +121,12 @@ public class SimpleOrganizationalService extends AbstractTreeSortService<Organiz
|
|
.where(OrganizationalEntity.id, id)
|
|
.where(OrganizationalEntity.id, id)
|
|
.exec();
|
|
.exec();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(readOnly = true)
|
|
|
|
+ @Cacheable(key = "'code:'+#code")
|
|
|
|
+ public OrganizationalEntity selectByCode(String code) {
|
|
|
|
+ if (StringUtils.isEmpty(code)) return null;
|
|
|
|
+ return createQuery().where(OrganizationalEntity.code, code).single();
|
|
|
|
+ }
|
|
}
|
|
}
|