权限问题修复

beetlsql3-dev
Mlxa0324 3 years ago
parent 27f954c384
commit ef7dc07a55

@ -1,18 +1,48 @@
package com.ibeetl.admin.core.util.beetl;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.mysql.cj.jdbc.JdbcConnection;
import org.apache.commons.lang3.StringUtils;
import org.beetl.core.Context;
import org.beetl.core.Function;
import org.beetl.sql.ext.spring.SpringConnectionSource;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
//1商品分类 2商品 3文章分类 4文章 5商品属性 6适用场合 7品牌 8Region
@Component
public class DataTableName implements Function {
public static String dataName;
public volatile Map<String, String> dataSourceMap = new ConcurrentHashMap<>();
@Override
public Object call(Object[] objects, Context context) {
// 获取当前线程的数据源
String dataName = getDatabaseName(DynamicDataSourceContextHolder.peek());
return StringUtils.isBlank(dataName)?"springbootplus":dataName;
}
private String getDatabaseName(String sourceName) {
if (StringUtils.isBlank(sourceName)) {
sourceName = "master";
}
String s = dataSourceMap.get(sourceName);
if (StringUtils.isNotBlank(s)) {
return s;
}
String beanName = sourceName + "BeetlSqlDataSourceBean";
SpringConnectionSource cs = SpringUtil.getBean(beanName, SpringConnectionSource.class);
JdbcConnection delegate = (JdbcConnection)ReflectUtil.getFieldValue(cs.getMetaData(), "delegate");
Method getDatabase = ReflectUtil.getMethodByName(JdbcConnection.class, "getDatabase");
// 获取当前线程的数据源库名
String dataBaseName = ReflectUtil.invoke(delegate, getDatabase);
dataSourceMap.put(sourceName, dataBaseName);
return dataBaseName;
}
}

@ -3,8 +3,8 @@ package com.ibeetl.jlw.entity;
import com.ibeetl.admin.core.annotation.Dict;
import com.ibeetl.admin.core.entity.BaseEntity;
import com.ibeetl.admin.core.util.ValidateConfig;
import lombok.Data;
import org.beetl.sql.annotation.entity.AssignID;
import org.beetl.sql.annotation.entity.Table;
import org.beetl.sql.fetch.annotation.Fetch;
import org.beetl.sql.fetch.annotation.FetchSql;
@ -17,7 +17,7 @@ import java.util.List;
* gen by Spring Boot2 Admin 2022-09-11
*/
@Fetch
@Table(name="teacher_open_course_schedule_session")
@Data
public class TeacherOpenCourseScheduleSession extends BaseEntity{
//课程开课-排课位置ID
@ -34,7 +34,7 @@ public class TeacherOpenCourseScheduleSession extends BaseEntity{
//创建时间
private Date teacherOpenCourseScheduleSessionAddTime ;
//状态1正常 2删除
@Dict(type="global_status")
@ -62,16 +62,12 @@ public class TeacherOpenCourseScheduleSession extends BaseEntity{
private Long userId ;
@FetchSql("select * from teacher_open_course_schedule_session where teacher_open_course_id = #teacherOpenCourseId# and teacher_id = #teacherId# and teacher_open_course_schedule_session_status = 1")
private List<TeacherOpenCourseScheduleSessionTag> sessionTagList;
public List<TeacherOpenCourseScheduleSessionTag> getSessionTagList() {
return sessionTagList;
}
public void setSessionTagList(List<TeacherOpenCourseScheduleSessionTag> sessionTagList) {
this.sessionTagList = sessionTagList;
}
@FetchSql("select teacher_open_course_schedule_session_tag_name, teacher_open_course_schedule_session_add_time," +
"teacher_open_course_schedule_session_tag_duration," +
"teacher_open_course_schedule_session_tag_start_time, teacher_open_course_schedule_session_tag_end_time " +
"from teacher_open_course_schedule_session where teacher_open_course_id = #teacherOpenCourseId# " +
"and teacher_id = #teacherId# and teacher_open_course_schedule_session_status = 1")
private List<TeacherOpenCourseScheduleSessionTagTemp> sessionTagList;
//课次名称
@ -101,199 +97,28 @@ public class TeacherOpenCourseScheduleSession extends BaseEntity{
private Integer teacherOpenCourseScheduleSessionWeekNum;
public TeacherOpenCourseScheduleSession(){
}
/**-ID
*@return
*/
public Long getTeacherOpenCourseScheduleSessionId(){
return teacherOpenCourseScheduleSessionId;
}
/**-ID
*@param teacherOpenCourseScheduleSessionId
*/
public void setTeacherOpenCourseScheduleSessionId(Long teacherOpenCourseScheduleSessionId){
this.teacherOpenCourseScheduleSessionId = teacherOpenCourseScheduleSessionId;
}
/**
*@return
*/
public String getTeacherOpenCourseScheduleSessionDayTime(){
return teacherOpenCourseScheduleSessionDayTime;
}
/**
*@param teacherOpenCourseScheduleSessionDayTime
*/
public void setTeacherOpenCourseScheduleSessionDayTime(String teacherOpenCourseScheduleSessionDayTime){
this.teacherOpenCourseScheduleSessionDayTime = teacherOpenCourseScheduleSessionDayTime;
}
/**
*@return
*/
public Date getTeacherOpenCourseScheduleSessionAddTime(){
return teacherOpenCourseScheduleSessionAddTime;
}
/**
*@param teacherOpenCourseScheduleSessionAddTime
*/
public void setTeacherOpenCourseScheduleSessionAddTime(Date teacherOpenCourseScheduleSessionAddTime){
this.teacherOpenCourseScheduleSessionAddTime = teacherOpenCourseScheduleSessionAddTime;
}
/**1 2
*@return
*/
public Integer getTeacherOpenCourseScheduleSessionStatus(){
return teacherOpenCourseScheduleSessionStatus;
}
/**1 2
*@param teacherOpenCourseScheduleSessionStatus
*/
public void setTeacherOpenCourseScheduleSessionStatus(Integer teacherOpenCourseScheduleSessionStatus){
this.teacherOpenCourseScheduleSessionStatus = teacherOpenCourseScheduleSessionStatus;
}
/**ID
*@return
*/
public Long getTeacherOpenCourseId(){
return teacherOpenCourseId;
}
/**ID
*@param teacherOpenCourseId
*/
public void setTeacherOpenCourseId(Long teacherOpenCourseId){
this.teacherOpenCourseId = teacherOpenCourseId;
}
/**ID
*@return
*/
public Long getTeacherId(){
return teacherId;
}
/**ID
*@param teacherId
*/
public void setTeacherId(Long teacherId){
this.teacherId = teacherId;
}
@Data
public static class TeacherOpenCourseScheduleSessionTagTemp {
/**ID
*@return
*/
public String getSchoolClassIds(){
return schoolClassIds;
}
/**ID
*@param schoolClassIds
*/
public void setSchoolClassIds(String schoolClassIds){
this.schoolClassIds = schoolClassIds;
}
//课次名称(支持自定义)
/**ID
*@return
*/
public Long getOrgId(){
return orgId;
}
/**ID
*@param orgId
*/
public void setOrgId(Long orgId){
this.orgId = orgId;
}
private String teacherOpenCourseScheduleSessionTagName;
/**ID
*@return
*/
public Long getUserId(){
return userId;
}
/**ID
*@param userId
*/
public void setUserId(Long userId){
this.userId = userId;
}
//创建时间
/**
*@return
*/
public String getTeacherOpenCourseScheduleSessionTagName(){
return teacherOpenCourseScheduleSessionTagName;
}
/**
*@param teacherOpenCourseScheduleSessionTagName
*/
public void setTeacherOpenCourseScheduleSessionTagName(String teacherOpenCourseScheduleSessionTagName){
this.teacherOpenCourseScheduleSessionTagName = teacherOpenCourseScheduleSessionTagName;
}
private Date teacherOpenCourseScheduleSessionAddTime;
/**
*@return
*/
public Integer getTeacherOpenCourseScheduleSessionTagDuration(){
return teacherOpenCourseScheduleSessionTagDuration;
}
/**
*@param teacherOpenCourseScheduleSessionTagDuration
*/
public void setTeacherOpenCourseScheduleSessionTagDuration(Integer teacherOpenCourseScheduleSessionTagDuration){
this.teacherOpenCourseScheduleSessionTagDuration = teacherOpenCourseScheduleSessionTagDuration;
}
//课程时长(分钟)
/**
*@return
*/
public String getTeacherOpenCourseScheduleSessionTagStartTime(){
return teacherOpenCourseScheduleSessionTagStartTime;
}
/**
*@param teacherOpenCourseScheduleSessionTagStartTime
*/
public void setTeacherOpenCourseScheduleSessionTagStartTime(String teacherOpenCourseScheduleSessionTagStartTime){
this.teacherOpenCourseScheduleSessionTagStartTime = teacherOpenCourseScheduleSessionTagStartTime;
}
private Integer teacherOpenCourseScheduleSessionTagDuration;
/**
*@return
*/
public String getTeacherOpenCourseScheduleSessionTagEndTime(){
return teacherOpenCourseScheduleSessionTagEndTime;
}
/**
*@param teacherOpenCourseScheduleSessionTagEndTime
*/
public void setTeacherOpenCourseScheduleSessionTagEndTime(String teacherOpenCourseScheduleSessionTagEndTime){
this.teacherOpenCourseScheduleSessionTagEndTime = teacherOpenCourseScheduleSessionTagEndTime;
}
public String getTeacherOpenCourseScheduleSessionStartDate() {
return teacherOpenCourseScheduleSessionStartDate;
}
//开始时间
public void setTeacherOpenCourseScheduleSessionStartDate(String teacherOpenCourseScheduleSessionStartDate) {
this.teacherOpenCourseScheduleSessionStartDate = teacherOpenCourseScheduleSessionStartDate;
}
private String teacherOpenCourseScheduleSessionTagStartTime;
public String getTeacherOpenCourseScheduleSessionEndDate() {
return teacherOpenCourseScheduleSessionEndDate;
}
public void setTeacherOpenCourseScheduleSessionEndDate(String teacherOpenCourseScheduleSessionEndDate) {
this.teacherOpenCourseScheduleSessionEndDate = teacherOpenCourseScheduleSessionEndDate;
}
public Integer getTeacherOpenCourseScheduleSessionWeekNum() {
return teacherOpenCourseScheduleSessionWeekNum;
}
//结束时间
public void setTeacherOpenCourseScheduleSessionWeekNum(Integer teacherOpenCourseScheduleSessionWeekNum) {
this.teacherOpenCourseScheduleSessionWeekNum = teacherOpenCourseScheduleSessionWeekNum;
private String teacherOpenCourseScheduleSessionTagEndTime;
}
}

@ -26,6 +26,7 @@ import com.ibeetl.jlw.web.query.TeacherOpenCourseScheduleSessionQuery;
import org.apache.commons.lang3.StringUtils;
import org.beetl.sql.core.SqlId;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -49,6 +50,9 @@ public class TeacherOpenCourseScheduleSessionService extends CoreBaseService<Tea
@Resource private TeacherOpenCourseScheduleSessionDao teacherOpenCourseScheduleSessionDao;
@Lazy
@Resource TeacherOpenCourseScheduleSessionService teacherOpenCourseScheduleSessionService;
@Master
public PageQuery<TeacherOpenCourseScheduleSession>queryByCondition(PageQuery query){
PageQuery ret = teacherOpenCourseScheduleSessionDao.queryByCondition(query);
@ -56,7 +60,7 @@ public class TeacherOpenCourseScheduleSessionService extends CoreBaseService<Tea
return ret;
}
@Master
@DS("ds2")
public PageQuery<TeacherOpenCourseScheduleSession> queryByConditionGroup(PageQuery query){
PageQuery ret = teacherOpenCourseScheduleSessionDao.queryByConditionGroup(query);
queryListAfter(ret.getList());
@ -120,8 +124,8 @@ public class TeacherOpenCourseScheduleSessionService extends CoreBaseService<Tea
jsonResult.setData(teacherOpenCourseScheduleSession.getTeacherOpenCourseScheduleSessionId());//自增的ID丢进去
jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
jsonResult.setMsg(msg);
// 自己类调用自己类的方法,是支持回滚的
// mAdd(teacherOpenCourseScheduleSessionQuery);
// 自己类调用自己类的方法,是支持回滚的。必须注入的方式调用,才能启用@DS注解。否则是同一个库插入操作。切记
// teacherOpenCourseScheduleSessionService.mAdd(teacherOpenCourseScheduleSessionQuery);
return jsonResult;
}
@ -135,9 +139,9 @@ public class TeacherOpenCourseScheduleSessionService extends CoreBaseService<Tea
jsonResult.setData(teacherOpenCourseScheduleSession.getTeacherOpenCourseScheduleSessionId());//自增的ID丢进去
jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
jsonResult.setMsg(msg);
if(1==1){
throw new RuntimeException("模拟异常");
}
// if(1==1){
// throw new RuntimeException("模拟异常");
// }
return jsonResult;
}

@ -1,6 +1,5 @@
package com.ibeetl.jlw.web;
import com.ibeetl.admin.core.util.beetl.DataTableName;
import com.ibeetl.jlw.entity.Quartz;
import com.ibeetl.jlw.service.AttributeService;
import com.ibeetl.jlw.service.IpAddressService;
@ -39,10 +38,11 @@ public class ApplicationRunnerController implements ApplicationRunner {
public void run(ApplicationArguments args) throws Exception {
long l = System.currentTimeMillis();
try {
String url = ResourceBundle.getBundle("application").getString("spring.datasource.baseDataSource.url").split("\\?")[0];
DataTableName.dataName = url.substring(url.lastIndexOf("/") + 1);
} catch (Exception e) {}
// 多数据源用不到这块
// try {
// String url = ResourceBundle.getBundle("application").getString("spring.datasource.baseDataSource.url").split("\\?")[0];
// DataTableName.dataName = url.substring(url.lastIndexOf("/") + 1);
// } catch (Exception e) {}
try {

@ -87,7 +87,6 @@ queryByConditionGroup
@pageTag(){
tz.teacher_open_course_schedule_session_id,
tz.teacher_open_course_schedule_session_day_time,
tz.teacher_open_course_schedule_session_add_time,
tz.teacher_open_course_schedule_session_status,
tz.teacher_open_course_id,
tz.teacher_id,

Loading…
Cancel
Save