mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 20:49:00 +08:00
🗃️ 重构部分字段SQL 适配Oracle 数据库
(cherry picked from commit f55bd92a3dbeaea97ae9ae47fc91eed57176b4c2)
This commit is contained in:
1 parent
cfc916ef92
commit
322066bf25
7 files changed
+93
-91
No files matched your search
+1
-1
@@ -1171,7 +1171,7 @@ DROP TABLE IF EXISTS `sys_schedule`;
|
||||
CREATE TABLE `sys_schedule` (
|
||||
`id` bigint(20) NOT NULL COMMENT 'id',
|
||||
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '标题',
|
||||
`type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '日程类型',
|
||||
`schedule_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '日程类型',
|
||||
`state` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '状态',
|
||||
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '内容',
|
||||
`time` time DEFAULT NULL COMMENT '时间',
|
||||
|
||||
+1
-1
@@ -1135,7 +1135,7 @@ DROP TABLE IF EXISTS `sys_schedule`;
|
||||
CREATE TABLE `sys_schedule` (
|
||||
`id` bigint(20) NOT NULL COMMENT 'id',
|
||||
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '标题',
|
||||
`type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '日程类型',
|
||||
`schedule_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '日程类型',
|
||||
`state` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '状态',
|
||||
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '内容',
|
||||
`time` time DEFAULT NULL COMMENT '时间',
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.pig4cloud.pigx.common.core.sensitive.SensitiveTypeEnum;
|
||||
import com.pig4cloud.pigx.common.core.util.TenantTable;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
@@ -42,6 +43,7 @@ import java.time.LocalDateTime;
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@FieldNameConstants
|
||||
@Schema(description = "日志")
|
||||
public class SysLog implements Serializable {
|
||||
|
||||
|
||||
+69
-68
@@ -41,85 +41,86 @@ import java.time.LocalTime;
|
||||
@Schema(description = "日程")
|
||||
public class SysScheduleEntity extends Model<SysScheduleEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 日程类型
|
||||
*/
|
||||
@Schema(description = "日程类型")
|
||||
private String type;
|
||||
/**
|
||||
* 日程类型
|
||||
*/
|
||||
@Schema(description = "日程类型")
|
||||
@TableField("schedule_type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@Schema(description = "状态")
|
||||
private String state;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@Schema(description = "状态")
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@Schema(description = "内容")
|
||||
private String content;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@Schema(description = "内容")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
@Schema(description = "时间")
|
||||
private LocalTime time;
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
@Schema(description = "时间")
|
||||
private LocalTime time;
|
||||
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
@Schema(description = "日期")
|
||||
private LocalDate date;
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
@Schema(description = "日期")
|
||||
private LocalDate date;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Schema(description = "创建人")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createBy;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Schema(description = "创建人")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@Schema(description = "修改人")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private String updateBy;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@Schema(description = "修改人")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
@TableLogic
|
||||
@Schema(description = "删除标记")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
@TableLogic
|
||||
@Schema(description = "删除标记")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
|
||||
}
|
||||
-6
@@ -37,10 +37,4 @@ import java.util.Map;
|
||||
@Mapper
|
||||
public interface SysLogMapper extends PigxBaseMapper<SysLog> {
|
||||
|
||||
/**
|
||||
* 通过日志类型统计日志总数 返回一个包含日志类型和日志总数的列表
|
||||
* @return List<Map<String, Object>>
|
||||
*/
|
||||
List<Map<String, Object>> selectLogSumByType();
|
||||
|
||||
}
|
||||
+20
-1
@@ -19,6 +19,8 @@
|
||||
|
||||
package com.pig4cloud.pigx.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -113,7 +115,24 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getLogSum() {
|
||||
return baseMapper.selectLogSumByType();
|
||||
// 查询createTime 最近 30天的数据
|
||||
List<SysLog> sysLogList = baseMapper
|
||||
.selectList(Wrappers.<SysLog>lambdaQuery().ge(SysLog::getCreateTime, LocalDateTime.now().minusDays(30)));
|
||||
return sysLogList.stream()
|
||||
.collect(Collectors.groupingBy(log -> DateUtil.format(log.getCreateTime(), DatePattern.NORM_DATE_PATTERN)))
|
||||
.entrySet()
|
||||
.stream()
|
||||
.map(entry -> {
|
||||
Map<String, Object> map = entry.getValue()
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(SysLog::getLogType))
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, value -> value.getValue().size()));
|
||||
map.put(SysLog.Fields.createTime, entry.getKey());
|
||||
return map;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,18 +21,4 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.pig4cloud.pigx.admin.mapper.SysLogMapper">
|
||||
|
||||
<select id="selectLogSumByType" resultType="java.util.Map">
|
||||
SELECT
|
||||
DATE(create_time) AS log_date,
|
||||
SUM(CASE WHEN log_type = '0' THEN 1 ELSE 0 END) AS successful_count,
|
||||
SUM(CASE WHEN log_type = '9' THEN 1 ELSE 0 END) AS failed_count
|
||||
FROM
|
||||
sys_log
|
||||
WHERE
|
||||
create_time >= CURDATE() - INTERVAL 30 DAY
|
||||
GROUP BY
|
||||
log_date
|
||||
ORDER BY
|
||||
log_date;
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user