取别名的缓存

beetlsql3-dev
Mlxa0324 2 years ago
parent 91a83d03ac
commit be24c6f757

@ -3,6 +3,8 @@ package com.ibeetl.admin.core.conf;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
@ -34,7 +36,7 @@ import java.util.concurrent.ConcurrentHashMap;
@Configuration @Configuration
@ConditionalOnProperty(name="springext.cache.enabled", havingValue="true" ,matchIfMissing=false) @ConditionalOnProperty(name="springext.cache.enabled", havingValue="true" ,matchIfMissing=false)
public class CacheConfig { public class CacheConfig extends CachingConfigurerSupport {
// 定义一个redis 的频道默认叫cache用于pub/sub // 定义一个redis 的频道默认叫cache用于pub/sub
@Value("${springext.cache.redis.topic:cache}") @Value("${springext.cache.redis.topic:cache}")
@ -111,12 +113,24 @@ public class CacheConfig {
// Sub 一个消息,通知缓存管理器 // Sub 一个消息,通知缓存管理器
String type = new String(bs, StandardCharsets.UTF_8); String type = new String(bs, StandardCharsets.UTF_8);
cacheManager.receiver(type); cacheManager.receiver(type);
} }
}); });
} }
@Override
@Bean
public KeyGenerator keyGenerator() {
return (target, method, params) -> {
StringBuilder sb = new StringBuilder();
sb.append(target.getClass().getName());
sb.append(method.getName());
for (Object obj : params) {
sb.append(obj.toString());
}
return sb.toString();
};
}
class TowLevelCacheManager extends RedisCacheManager { class TowLevelCacheManager extends RedisCacheManager {
RedisTemplate redisTemplate; RedisTemplate redisTemplate;

@ -1,13 +1,11 @@
package com.ibeetl.jlw.entity; package com.ibeetl.jlw.entity;
import com.ibeetl.admin.core.annotation.Dict;
import com.ibeetl.admin.core.entity.BaseEntity; import com.ibeetl.admin.core.entity.BaseEntity;
import com.ibeetl.admin.core.util.ValidateConfig; import com.ibeetl.admin.core.util.ValidateConfig;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.beetl.sql.annotation.entity.AutoID; import org.beetl.sql.annotation.entity.AutoID;
import org.beetl.sql.annotation.entity.InsertIgnore;
import org.beetl.sql.annotation.entity.UpdateIgnore;
import org.beetl.sql.fetch.annotation.Fetch; import org.beetl.sql.fetch.annotation.Fetch;
import org.beetl.sql.fetch.annotation.FetchSql;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
@ -28,14 +26,17 @@ public class TeacherOpenCourseMergeCourseInfo extends BaseEntity implements Comp
private Long teacherOpenCourseMergeCourseInfoId ; private Long teacherOpenCourseMergeCourseInfoId ;
//开课ID //开课ID
@Dict(type="teacher_open_course.teacher_open_course_name.teacher_open_course_status=1")
private Long teacherOpenCourseId ; private Long teacherOpenCourseId ;
@UpdateIgnore // @UpdateIgnore
@InsertIgnore // @InsertIgnore
@FetchSql("select teacher_open_course_title from teacher_open_course " + // @Dict(type="teacher_open_course.teacher_open_course_name.teacher_open_course_status=1")
"where teacher_open_course_status = 1 " + // @FetchSql("select teacher_open_course_title from teacher_open_course " +
"and teacher_open_course_id = #teacherOpenCourseId# ") // "where teacher_open_course_status = 1 " +
private String teacherOpenCourseIdText; // "and teacher_open_course_id = #teacherOpenCourseId# ")
// private String teacherOpenCourseIdText;
//名称(课程名 或 章名 或 节名) //名称(课程名 或 章名 或 节名)
@ -46,14 +47,16 @@ public class TeacherOpenCourseMergeCourseInfo extends BaseEntity implements Comp
private String courseInfoThumbnail ; private String courseInfoThumbnail ;
//课程标签ID //课程标签ID
@Dict(type="course_label.course_label_name.course_label_status=1")
private Long courseLabelId ; private Long courseLabelId ;
@UpdateIgnore // @UpdateIgnore
@InsertIgnore // @InsertIgnore
@FetchSql("select course_label_name from course_label " + // @FetchSql("select course_label_name from course_label " +
"where course_label_status = 1 " + // "where course_label_status = 1 " +
"and course_label_id = #courseLabelId# ") // "and course_label_id = #courseLabelId# ")
private String courseLabelIdText; // private String courseLabelIdText;
//课程学习人数基数 //课程学习人数基数
@ -353,23 +356,6 @@ public class TeacherOpenCourseMergeCourseInfo extends BaseEntity implements Comp
return (List<TeacherOpenCourseMergeCourseInfo>)this.get("children"); return (List<TeacherOpenCourseMergeCourseInfo>)this.get("children");
} }
public String getTeacherOpenCourseIdText() {
return teacherOpenCourseIdText;
}
public void setTeacherOpenCourseIdText(String teacherOpenCourseIdText) {
this.teacherOpenCourseIdText = teacherOpenCourseIdText;
}
public String getCourseLabelIdText() {
return courseLabelIdText;
}
public void setCourseLabelIdText(String courseLabelIdText) {
this.courseLabelIdText = courseLabelIdText;
}
@Override @Override
public int compareTo(TeacherOpenCourseMergeCourseInfo o) { public int compareTo(TeacherOpenCourseMergeCourseInfo o) {
return this.getTeacherOpenCourseMergeCourseInfoId().compareTo(o.getTeacherOpenCourseMergeCourseInfoId()); return this.getTeacherOpenCourseMergeCourseInfoId().compareTo(o.getTeacherOpenCourseMergeCourseInfoId());

Loading…
Cancel
Save