⚡ 优化 适配Oracle 、PG数据库
This commit is contained in:
1 parent
036bf65280
commit
bde8bc0d6a
7 files changed
+27
-24
No files matched your search
+5
-1
@@ -2,6 +2,7 @@ package com.pig4cloud.pigx.common.data.mybatis;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.security.core.Authentication;
|
||||
@@ -25,11 +26,14 @@ public class MybatisPlusMetaObjectHandler implements MetaObjectHandler {
|
||||
log.debug("mybatis plus start insert fill ....");
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
// 审计字段自动填充
|
||||
fillValIfNullByName("createTime", now, metaObject, false);
|
||||
fillValIfNullByName("updateTime", now, metaObject, false);
|
||||
fillValIfNullByName("createBy", getUserName(), metaObject, false);
|
||||
fillValIfNullByName("updateBy", getUserName(), metaObject, false);
|
||||
fillValIfNullByName("delFlag", 1, metaObject, false);
|
||||
|
||||
// 删除标记自动填充
|
||||
fillValIfNullByName("delFlag", CommonConstants.STATUS_NORMAL, metaObject, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -38,6 +38,6 @@ public class DruidDataSourceProperties {
|
||||
/**
|
||||
* 查询数据源的SQL
|
||||
*/
|
||||
private String queryDsSql = "select * from gen_datasource_conf where del_flag = 0";
|
||||
private String queryDsSql = "select * from gen_datasource_conf where del_flag = '0'";
|
||||
|
||||
}
|
||||
@@ -52,7 +52,7 @@
|
||||
sys_menu.del_flag
|
||||
FROM sys_menu
|
||||
LEFT JOIN sys_role_menu ON sys_menu.menu_id = sys_role_menu.menu_id
|
||||
WHERE sys_menu.del_flag = 0
|
||||
WHERE sys_menu.del_flag = '0'
|
||||
AND sys_role_menu.role_id = #{roleId}
|
||||
ORDER BY sys_menu.sort_order DESC
|
||||
</select>
|
||||
@@ -63,7 +63,7 @@
|
||||
FROM sys_menu m,
|
||||
sys_role_menu rm
|
||||
WHERE m.menu_id = rm.menu_id
|
||||
AND m.del_flag = 0
|
||||
AND m.del_flag = '0'
|
||||
AND rm.role_id IN (#{roleIds})
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -47,7 +47,7 @@
|
||||
FROM sys_role,
|
||||
sys_user_role
|
||||
WHERE sys_role.role_id = sys_user_role.role_id
|
||||
AND sys_role.del_flag = 0
|
||||
AND sys_role.del_flag = '0'
|
||||
and sys_user_role.user_id = #{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
+8
-8
@@ -16,10 +16,7 @@
|
||||
*/
|
||||
package com.pig4cloud.pigx.codegen.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -98,17 +95,20 @@ public class GenDatasourceConf extends Model<GenDatasourceConf> {
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createDate;
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateDate;
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
* 0-正常,1-删除
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
|
||||
}
|
||||
+6
-7
@@ -17,9 +17,7 @@
|
||||
|
||||
package com.pig4cloud.pigx.codegen.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -64,19 +62,20 @@ public class GenFormConf extends Model<GenFormConf> {
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
* 0-正常,1-删除
|
||||
*/
|
||||
@ApiModelProperty(value = "删除标记")
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -77,7 +77,7 @@ public class SysJobController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@ApiOperation(value = "唯一标识查询定时任务")
|
||||
public R getById(@PathVariable("id") Integer id) {
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(sysJobService.getById(id));
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class SysJobController {
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('job_sys_job_del')")
|
||||
@ApiOperation(value = "唯一标识查询定时任务,暂停任务才能删除")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
public R removeById(@PathVariable Long id) {
|
||||
SysJob querySysJob = this.sysJobService.getById(id);
|
||||
if (JOB_STATUS_NOT_RUNNING.getType().equals(querySysJob.getJobStatus())) {
|
||||
this.taskUtil.removeJob(querySysJob, scheduler);
|
||||
@@ -234,7 +234,7 @@ public class SysJobController {
|
||||
@PostMapping("/run-job/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('job_sys_job_run_job')")
|
||||
@ApiOperation(value = "立刻执行定时任务")
|
||||
public R runJob(@PathVariable("id") Integer jobId) {
|
||||
public R runJob(@PathVariable("id") Long jobId) {
|
||||
SysJob querySysJob = this.sysJobService.getById(jobId);
|
||||
return TaskUtil.runOnce(scheduler, querySysJob) ? R.ok() : R.failed();
|
||||
}
|
||||
@@ -247,7 +247,7 @@ public class SysJobController {
|
||||
@PostMapping("/shutdown-job/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('job_sys_job_shutdown_job')")
|
||||
@ApiOperation(value = "暂停定时任务")
|
||||
public R shutdownJob(@PathVariable("id") Integer id) {
|
||||
public R shutdownJob(@PathVariable("id") Long id) {
|
||||
SysJob querySysJob = this.sysJobService.getById(id);
|
||||
// 更新定时任务状态条件,运行状态2更新为暂停状态3
|
||||
this.sysJobService.updateById(
|
||||
|
||||
Reference in new issue
Block a user