jpa fetch -> load
This commit is contained in:
parent
0da00b9837
commit
0dfbee487a
13
pom.xml
13
pom.xml
|
|
@ -28,8 +28,9 @@
|
|||
<commons.fileupload.version>1.3.3</commons.fileupload.version>
|
||||
<poi.version>3.17</poi.version>
|
||||
<velocity.version>1.7</velocity.version>
|
||||
<querydsl.version>4.2.1</querydsl.version>
|
||||
<querydsl.version>4.4.0</querydsl.version>
|
||||
<jaxb.version>2.3.0.1</jaxb.version>
|
||||
<jna.version>5.6.0</jna.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
|
|
@ -40,7 +41,15 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>2.1.1.RELEASE</version>
|
||||
<version>2.3.4.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava-bom</artifactId>
|
||||
<version>29.0-jre</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@
|
|||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-hibernate5</artifactId>
|
||||
<version>2.10.1</version>
|
||||
<version>2.11.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
@ -120,6 +120,11 @@
|
|||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.ruoyi;
|
|||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
|
@ -13,7 +14,7 @@ import org.springframework.context.annotation.Bean;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, CacheAutoConfiguration.class})
|
||||
public class RuoYiApplication extends SpringBootServletInitializer {
|
||||
public static void main(String[] args) {
|
||||
// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||
|
|
|
|||
|
|
@ -69,15 +69,30 @@ spring:
|
|||
use-new-id-generator-mappings: true
|
||||
show-sql: true
|
||||
database-platform: org.hibernate.dialect.MySQL55Dialect
|
||||
open-in-view: false
|
||||
properties:
|
||||
hibernate:
|
||||
format_sql: false
|
||||
open-in-view: false
|
||||
cache:
|
||||
type: jcache
|
||||
jcache:
|
||||
provider: org.ehcache.jsr107.EhcacheCachingProvider
|
||||
type: redis
|
||||
redis:
|
||||
use-key-prefix: true
|
||||
cache-null-values: true
|
||||
key-prefix: ${spring.application.name}
|
||||
|
||||
redis:
|
||||
database: 2
|
||||
host: localhost
|
||||
port: 6379
|
||||
ssl: false
|
||||
timeout: 3000
|
||||
password:
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8
|
||||
max-idle: 8
|
||||
min-idle: 2
|
||||
max-wait: -1
|
||||
# Shiro
|
||||
shiro:
|
||||
user:
|
||||
|
|
@ -127,3 +142,14 @@ xss:
|
|||
swagger:
|
||||
# 是否开启swagger
|
||||
enabled: true
|
||||
|
||||
cache:
|
||||
names:
|
||||
sys_dict_type:
|
||||
ttl: PT1M
|
||||
sys_user:
|
||||
ttl: PT1M
|
||||
sys_post:
|
||||
ttl: PT1M
|
||||
sys_role:
|
||||
ttl: PT1M
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.ruoyi;
|
||||
|
||||
public class Tesst {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(System.getProperty("java.io.tmpdir"));
|
||||
}
|
||||
}
|
||||
|
|
@ -123,6 +123,20 @@
|
|||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
package com.ruoyi.common.base;
|
||||
|
||||
import com.querydsl.core.types.Constant;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.Predicate;
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.querydsl.ExpressionUtils;
|
||||
|
|
@ -39,6 +42,11 @@ public class BaseService {
|
|||
return ExpressionUtils.notStartWith(path, value);
|
||||
}
|
||||
|
||||
protected Predicate alwaysTrue(){
|
||||
Constant<Boolean> expression = (Constant<Boolean>) com.querydsl.core.types.ExpressionUtils.toExpression(Boolean.TRUE);
|
||||
return com.querydsl.core.types.ExpressionUtils.eqConst(expression, true);
|
||||
}
|
||||
|
||||
public static Collection<Long> toLongIterable(String str){
|
||||
return Arrays.stream(Convert.toStrArray(str))
|
||||
.map(Long::parseLong)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.ruoyi.common.properties;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -17,8 +19,12 @@ public class CacheProperties {
|
|||
|
||||
private Map<String, Config> names = new HashMap<>();
|
||||
|
||||
private Config defaultConfig = new Config(Duration.ofMinutes(1));
|
||||
|
||||
@ToString
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Config{
|
||||
private Duration ttl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,11 +75,13 @@
|
|||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>${jna.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna-platform</artifactId>
|
||||
<version>${jna.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 系统模块-->
|
||||
|
|
|
|||
|
|
@ -8,11 +8,12 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
|||
import com.ruoyi.common.properties.CacheProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
|
|
@ -23,10 +24,9 @@ import org.springframework.data.redis.serializer.RedisSerializationContext;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ConditionalOnClass(name = "org.springframework.data.redis.connection.RedisConnectionFactory")
|
||||
@EnableCaching
|
||||
@Configuration
|
||||
@AutoConfigureAfter(CacheProperties.class)
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class CacheConfig {
|
||||
|
||||
@Autowired
|
||||
|
|
@ -43,6 +43,11 @@ public class CacheConfig {
|
|||
|
||||
@Bean
|
||||
public CacheManager cacheManager() {
|
||||
RedisCacheConfiguration defaultConfiguration = RedisCacheConfiguration.defaultCacheConfig()
|
||||
.disableCachingNullValues()
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(genericJackson2JsonRedisSerializer))
|
||||
.entryTtl(cacheProperties.getDefaultConfig().getTtl());
|
||||
|
||||
Map<String, RedisCacheConfiguration> configurationMap = new HashMap<>();
|
||||
for(String key : cacheProperties.getNames().keySet()){
|
||||
configurationMap.put(key, RedisCacheConfiguration.defaultCacheConfig()
|
||||
|
|
@ -53,6 +58,7 @@ public class CacheConfig {
|
|||
return RedisCacheManager.builder(factory)
|
||||
.initialCacheNames(cacheProperties.getNames().keySet())
|
||||
.withInitialCacheConfigurations(configurationMap)
|
||||
.cacheDefaults(defaultConfiguration)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class MyJCacheRegionFactory extends JCacheRegionFactory {
|
|||
|
||||
final CachingProvider cachingProvider = getCachingProvider( properties );
|
||||
final CacheManager cacheManager;
|
||||
final URI cacheManagerUri = getUri( properties );
|
||||
final URI cacheManagerUri = getUri( settings, properties);
|
||||
// ***** begin patch ******
|
||||
URI uri = cacheManagerUri;
|
||||
URL url = null;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ public class SysJobServiceImpl extends BaseService implements ISysJobService {
|
|||
private Predicate getPredicate(SysJob job){
|
||||
QSysJob qSysJob = QSysJob.sysJob;
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
predicates.add(alwaysTrue());
|
||||
if(StringUtils.isNotEmpty(job.getJobName())){
|
||||
predicates.add(buildLike(qSysJob.jobName, job.getJobName()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public class SysUser extends BaseEntity implements Principal {
|
|||
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
|
||||
@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
|
||||
})
|
||||
@ManyToOne
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "dept_id", referencedColumnName = "deptId")
|
||||
@ForeignKey(name = "none")
|
||||
private SysDept dept;
|
||||
|
|
@ -144,8 +144,6 @@ public class SysUser extends BaseEntity implements Principal {
|
|||
@org.hibernate.annotations.ForeignKey(name = "none")
|
||||
private Set<SysPost> posts = new HashSet<>();
|
||||
|
||||
|
||||
|
||||
public SysUser() {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ public interface SysRoleRepository extends BaseRepository<SysRole, Long> {
|
|||
@Modifying
|
||||
void updateStatus(String status, Long roleId);
|
||||
|
||||
@EntityGraph(attributePaths = {"depts", "menus"})
|
||||
@EntityGraph(attributePaths = {"depts", "menus"}, type = EntityGraph.EntityGraphType.LOAD )
|
||||
SysRole findByRoleId(Long roleId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,31 +13,31 @@ import org.springframework.stereotype.Repository;
|
|||
@Repository
|
||||
public interface SysUserRepository extends BaseRepository<SysUser, Long> {
|
||||
|
||||
@EntityGraph(attributePaths = {"roles", "posts"})
|
||||
@EntityGraph(attributePaths = {"roles", "posts"}, type= EntityGraph.EntityGraphType.LOAD )
|
||||
SysUser findFirstByDelFlagAndLoginName(String delFlag, String loginName);
|
||||
|
||||
@EntityGraph(attributePaths = {"roles", "posts"})
|
||||
SysUser findFirstByDelFlagAndAndPhonenumber(String delFlag, String phone);
|
||||
@EntityGraph(attributePaths = {"roles", "posts"}, type= EntityGraph.EntityGraphType.LOAD)
|
||||
SysUser findFirstByDelFlagAndPhonenumber(String delFlag, String phone);
|
||||
|
||||
@EntityGraph(attributePaths = {"roles", "posts"})
|
||||
@EntityGraph(attributePaths = {"roles", "posts"}, type= EntityGraph.EntityGraphType.LOAD)
|
||||
SysUser findFirstByDelFlagAndEmail(String delFlag, String email);
|
||||
|
||||
int countByDelFlagAndDept(String delFlag, SysDept dept);
|
||||
|
||||
int countByDelFlagAndPostsContaining(String delFlag, SysPost sysPost);
|
||||
|
||||
@EntityGraph(attributePaths = {"roles", "posts"})
|
||||
@EntityGraph(attributePaths = {"roles", "posts"}, type= EntityGraph.EntityGraphType.LOAD)
|
||||
SysUser findSysUserByDelFlagAndUserId(String delFlag, Long userId);
|
||||
|
||||
int countByLoginName(String loginName);
|
||||
|
||||
@EntityGraph(attributePaths = {"roles", "posts"})
|
||||
@EntityGraph(attributePaths = {"roles", "posts"}, type= EntityGraph.EntityGraphType.LOAD)
|
||||
SysUser findFirstByPhonenumber(String phone);
|
||||
|
||||
@EntityGraph(attributePaths = {"roles", "posts"})
|
||||
@EntityGraph(attributePaths = {"roles", "posts"}, type= EntityGraph.EntityGraphType.LOAD)
|
||||
SysUser findFirstByEmail(String email);
|
||||
|
||||
@EntityGraph(attributePaths = {"roles", "posts"})
|
||||
@EntityGraph(attributePaths = {"roles", "posts"}, type= EntityGraph.EntityGraphType.LOAD)
|
||||
SysUser findFirstByLoginName(String loginName);
|
||||
|
||||
@Modifying
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public class SysConfigServiceImpl extends BaseService implements ISysConfigServi
|
|||
private Predicate getPredicate(SysConfig config){
|
||||
QSysConfig qSysConfig = QSysConfig.sysConfig;
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
predicates.add(alwaysTrue());
|
||||
if(StringUtils.isNotEmpty(config.getConfigName())){
|
||||
predicates.add(buildLike(qSysConfig.configName, config.getConfigName()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,11 @@ import com.ruoyi.system.domain.SysDictType;
|
|||
import com.ruoyi.system.repository.SysDictDataRepository;
|
||||
import com.ruoyi.system.repository.SysDictTypeRepository;
|
||||
import com.ruoyi.system.service.ISysDictTypeService;
|
||||
import org.hibernate.query.criteria.internal.predicate.BooleanExpressionPredicate;
|
||||
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.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -29,6 +32,7 @@ import java.util.List;
|
|||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "sys_dict_type")
|
||||
public class SysDictTypeServiceImpl extends BaseService implements ISysDictTypeService {
|
||||
@Autowired
|
||||
private SysDictTypeRepository sysDictTypeRepository;
|
||||
|
|
@ -41,6 +45,7 @@ public class SysDictTypeServiceImpl extends BaseService implements ISysDictTypeS
|
|||
* @param dictType 字典类型信息
|
||||
* @return 字典类型集合信息
|
||||
*/
|
||||
@Cacheable
|
||||
@Override
|
||||
public Page<SysDictType> selectDictTypeList(SysDictType dictType, Pageable pageable) {
|
||||
return sysDictTypeRepository.findAll(getPredicate(dictType), pageable);
|
||||
|
|
@ -49,6 +54,7 @@ public class SysDictTypeServiceImpl extends BaseService implements ISysDictTypeS
|
|||
private Predicate getPredicate(SysDictType sysDictType){
|
||||
QSysDictType qSysDictType = QSysDictType.sysDictType;
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
predicates.add(alwaysTrue());
|
||||
if(StringUtils.isNotEmpty(sysDictType.getDictName())){
|
||||
predicates.add(buildLike(qSysDictType.dictName, sysDictType.getDictName()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ public class SysLogininforServiceImpl extends BaseService implements ISysLoginin
|
|||
private Predicate getPredicate(SysLogininfor logininfor){
|
||||
QSysLogininfor qSysLogininfor = QSysLogininfor.sysLogininfor;
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
predicates.add(alwaysTrue());
|
||||
if(StringUtils.isNotEmpty(logininfor.getIpaddr())){
|
||||
predicates.add(buildLike(qSysLogininfor.ipaddr, logininfor.getIpaddr()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ public class SysNoticeServiceImpl extends BaseService implements ISysNoticeServi
|
|||
private Predicate getPredicate(SysNotice sysNotice){
|
||||
QSysNotice qSysNotice = QSysNotice.sysNotice;
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
predicates.add(alwaysTrue());
|
||||
if(StringUtils.isNotEmpty(sysNotice.getNoticeTitle())){
|
||||
predicates.add(buildLike(qSysNotice.noticeTitle, sysNotice.getNoticeTitle()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public class SysOperLogServiceImpl extends BaseService implements ISysOperLogSer
|
|||
private Predicate getPredicate(SysOperLog operLog){
|
||||
QSysOperLog qSysOperLog = QSysOperLog.sysOperLog;
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
predicates.add(alwaysTrue());
|
||||
if(StringUtils.isNotEmpty(operLog.getTitle())){
|
||||
predicates.add(buildLike(qSysOperLog.title, operLog.getTitle()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import com.ruoyi.system.repository.SysPostRepository;
|
|||
import com.ruoyi.system.repository.SysUserRepository;
|
||||
import com.ruoyi.system.service.ISysPostService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
|
@ -30,6 +32,7 @@ import java.util.List;
|
|||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "sys_post")
|
||||
public class SysPostServiceImpl extends BaseService implements ISysPostService {
|
||||
|
||||
@Autowired
|
||||
|
|
@ -44,6 +47,7 @@ public class SysPostServiceImpl extends BaseService implements ISysPostService {
|
|||
* @param pageRequest
|
||||
* @return 岗位信息集合
|
||||
*/
|
||||
@Cacheable
|
||||
@Override
|
||||
public Page<SysPost> selectPostList(SysPost post, Pageable pageRequest) {
|
||||
return sysPostRepository.findAll(getSpecification(post), pageRequest);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import com.ruoyi.system.repository.SysUserRepository;
|
|||
import com.ruoyi.system.service.ISysRoleService;
|
||||
import com.ruoyi.system.service.base.BusinessService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -29,6 +31,7 @@ import java.util.*;
|
|||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "sys_role")
|
||||
public class SysRoleServiceImpl extends BusinessService implements ISysRoleService {
|
||||
|
||||
@Autowired
|
||||
|
|
@ -43,6 +46,7 @@ public class SysRoleServiceImpl extends BusinessService implements ISysRoleServi
|
|||
* @param user
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
@Cacheable
|
||||
@Override
|
||||
public Page<SysRole> selectRoleList(SysRole role, Pageable pageable, SysUser user) {
|
||||
return sysRoleRepository.findAll(getPredicate(role, user), pageable);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
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.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
|
@ -39,6 +42,7 @@ import java.util.stream.Collectors;
|
|||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "sys_user")
|
||||
public class SysUserServiceImpl extends BaseService implements ISysUserService {
|
||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||
|
||||
|
|
@ -56,6 +60,7 @@ public class SysUserServiceImpl extends BaseService implements ISysUserService {
|
|||
* @param pageRequest
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Cacheable
|
||||
@Override
|
||||
public Page<SysUser> selectUserList(SysUser user, Pageable pageRequest) {
|
||||
return sysUserRepository.findAll(getPredicate(user), pageRequest);
|
||||
|
|
@ -169,6 +174,7 @@ public class SysUserServiceImpl extends BaseService implements ISysUserService {
|
|||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Cacheable
|
||||
@Override
|
||||
public SysUser selectUserByLoginName(String userName) {
|
||||
return sysUserRepository.findFirstByDelFlagAndLoginName(BaseEntity.NOT_DELETED, userName);
|
||||
|
|
@ -182,7 +188,7 @@ public class SysUserServiceImpl extends BaseService implements ISysUserService {
|
|||
*/
|
||||
@Override
|
||||
public SysUser selectUserByPhoneNumber(String phoneNumber) {
|
||||
return sysUserRepository.findFirstByDelFlagAndAndPhonenumber(BaseEntity.NOT_DELETED, phoneNumber);
|
||||
return sysUserRepository.findFirstByDelFlagAndPhonenumber(BaseEntity.NOT_DELETED, phoneNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -231,6 +237,7 @@ public class SysUserServiceImpl extends BaseService implements ISysUserService {
|
|||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional
|
||||
@Override
|
||||
public int deleteUserByIds(String ids) throws BusinessException {
|
||||
|
|
@ -427,6 +434,7 @@ public class SysUserServiceImpl extends BaseService implements ISysUserService {
|
|||
return depts;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#user.userId", unless = "#result == null ")
|
||||
@Override
|
||||
public SysUser registerUser(SysUser user) {
|
||||
user.setUserType(UserConstants.REGISTER_USER_TYPE);
|
||||
|
|
|
|||
Loading…
Reference in New Issue