动态标签——指标
This commit is contained in:
commit
a15d10f90b
|
@ -0,0 +1,11 @@
|
||||||
|
target/
|
||||||
|
bin/
|
||||||
|
out/
|
||||||
|
log/
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
tmp/
|
||||||
|
|
||||||
|
*.idea
|
||||||
|
*.iml
|
||||||
|
*.log
|
|
@ -0,0 +1,63 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.szr</groupId>
|
||||||
|
<artifactId>center</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>com.szr</groupId>
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- spring web 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>${swagger.ui.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
|
||||||
|
<version>${knife4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- jdbc 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>${mybatis.plus.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- common 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
<artifactId>fastjson2</artifactId>
|
||||||
|
<version>${fastjson2.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,83 @@
|
||||||
|
package com.common.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName(value = "p_scene")
|
||||||
|
public class Scene {
|
||||||
|
@TableId
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private Integer id;
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
|
||||||
|
@TableField("create_at")
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private Date createAt;
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
|
||||||
|
@TableField("update_at")
|
||||||
|
@ApiModelProperty(value = "修改时间")
|
||||||
|
private Date updateAt;
|
||||||
|
@TableField("scene_name")
|
||||||
|
@ApiModelProperty(value = "技能名称")
|
||||||
|
private String sceneName;
|
||||||
|
@TableField("scene_remark")
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String sceneRemark;
|
||||||
|
@ApiModelProperty(value = "角色串")
|
||||||
|
private String roles;
|
||||||
|
@TableField("model_notes")
|
||||||
|
@ApiModelProperty(value = "模型说明")
|
||||||
|
private String modelNotes;
|
||||||
|
@TableField("file_url")
|
||||||
|
@ApiModelProperty(value = "文件地址")
|
||||||
|
private String fileUrl;
|
||||||
|
@ApiModelProperty(value = "版本")
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
//------------- 这里加一个空格后期需要去掉
|
||||||
|
// @TableField("contribution_name")
|
||||||
|
@TableField(exist=false)
|
||||||
|
@ApiModelProperty(value = "贡献者姓名")
|
||||||
|
private String contributionName;
|
||||||
|
@TableField("scene_type")
|
||||||
|
@ApiModelProperty(value = "技能类别 1定制 2永洪 ")
|
||||||
|
private Short sceneType;
|
||||||
|
@TableField("scene_url")
|
||||||
|
@ApiModelProperty(value = "技能URL")
|
||||||
|
private String sceneUrl;
|
||||||
|
@TableField("scene_skin")
|
||||||
|
@ApiModelProperty(value = "场景皮肤")
|
||||||
|
private String sceneSkin;
|
||||||
|
@TableField("icon_url")
|
||||||
|
@ApiModelProperty(value = "icon地址")
|
||||||
|
private String iconUrl;
|
||||||
|
@TableField("create_by")
|
||||||
|
@ApiModelProperty(value = "创建人")
|
||||||
|
private String createBy;
|
||||||
|
@TableField("update_by")
|
||||||
|
@ApiModelProperty(value = "更新人")
|
||||||
|
private String updateBy;
|
||||||
|
@ApiModelProperty(value = "删除标记:0-未删除 1-已删除")
|
||||||
|
private Short deleted;
|
||||||
|
@TableField("scene_operation")
|
||||||
|
@ApiModelProperty(value = "技能类型 智能脑,聪明口,灵活手,千里眼")
|
||||||
|
private String sceneOperation;
|
||||||
|
@TableField("scene_order")
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private Integer sceneOrder;
|
||||||
|
@TableField("scene_code")
|
||||||
|
@ApiModelProperty(value = "场景编码")
|
||||||
|
private String sceneCode;
|
||||||
|
@TableField("scene_tag")
|
||||||
|
@ApiModelProperty(value = "场景标签")
|
||||||
|
private String sceneTag;
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.common.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName(value = "p_user")
|
||||||
|
public class User {
|
||||||
|
@TableId
|
||||||
|
@ApiModelProperty(value = "用户主键")
|
||||||
|
private Integer id;
|
||||||
|
@TableField("user_id")
|
||||||
|
@ApiModelProperty(value = "用户编号")
|
||||||
|
private String userId;
|
||||||
|
@TableField("login_name")
|
||||||
|
@ApiModelProperty(value = "用户名(登录账号)")
|
||||||
|
private String loginName;
|
||||||
|
@TableField("login_password")
|
||||||
|
@ApiModelProperty(value = "用户密码(登录密码)")
|
||||||
|
private String loginPassword;
|
||||||
|
@TableField("user_name")
|
||||||
|
@ApiModelProperty(value = "用户姓名")
|
||||||
|
private String userName;
|
||||||
|
@TableField("mobile_number")
|
||||||
|
@ApiModelProperty(value = "手机号")
|
||||||
|
private String mobileNumber;
|
||||||
|
@TableField("police_number")
|
||||||
|
@ApiModelProperty(value = "警员编号(警号)")
|
||||||
|
private String policeNumber;
|
||||||
|
@TableField("id_number")
|
||||||
|
@ApiModelProperty(value = "身份证号")
|
||||||
|
private String idNumber;
|
||||||
|
@ApiModelProperty(value = "是否启用 0-未启用 1-启用")
|
||||||
|
private String effective;
|
||||||
|
@TableField("department_id")
|
||||||
|
@ApiModelProperty(value = "所属单位编号")
|
||||||
|
private String departmentId;
|
||||||
|
@TableField("job_title")
|
||||||
|
@ApiModelProperty(value="职称")
|
||||||
|
private String jobTitle;
|
||||||
|
@TableField("role_level")
|
||||||
|
@ApiModelProperty(value="等级:0 系统用户 1 派出所 2 分局")
|
||||||
|
private String roleLevel;
|
||||||
|
@ApiModelProperty(value = "用户角色,role id以逗号拼接")
|
||||||
|
private Set<String> roles;
|
||||||
|
//与其它实体类型和命名不一致
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
|
||||||
|
@TableField("create_time")
|
||||||
|
@ApiModelProperty(value="角色列表")
|
||||||
|
private OffsetDateTime createTime;
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
|
||||||
|
@TableField("update_time")
|
||||||
|
@ApiModelProperty(value="角色列表")
|
||||||
|
private OffsetDateTime updateTime;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.common.entity.base;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Base {
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
@ApiModelProperty(value = "主键(32),保存不需要赋值id",required = true)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
|
||||||
|
@TableField("create_time")
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
|
||||||
|
@TableField("update_time")
|
||||||
|
@ApiModelProperty(value = "修改时间")
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.common.entity.dic;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.common.entity.base.Base;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@TableName(value = "app_dic")
|
||||||
|
public class AppDic extends Base {
|
||||||
|
@TableField("app_type")
|
||||||
|
@ApiModelProperty(value = "模块类型")
|
||||||
|
private String appType;
|
||||||
|
@TableField("parent_id")
|
||||||
|
@ApiModelProperty(value = "父级ID")
|
||||||
|
private String parentId;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.common.entity.dic;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.common.entity.base.Base;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@TableName(value = "indicator_dic")
|
||||||
|
public class IndicatorDic extends Base {
|
||||||
|
@TableField("indicator_type")
|
||||||
|
@ApiModelProperty(value = "指标类型")
|
||||||
|
private String indicatorType;
|
||||||
|
@TableField("parent_id")
|
||||||
|
@ApiModelProperty(value = "父级ID")
|
||||||
|
private Integer parentId;
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.common.info;
|
||||||
|
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public enum CodeMsg {
|
||||||
|
SUCCESS(200, "成功"),
|
||||||
|
FAILURE(500, "失败"),
|
||||||
|
AUTH_FAILURE(401, "认证失败");
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
CodeMsg(Integer code, String message){
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.common.info;
|
||||||
|
|
||||||
|
public class Parameter {
|
||||||
|
public static final String TOKEN = "userId";
|
||||||
|
public static String TABLE_SCHEMA = "public";
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.common.tool;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
public class EqTool {
|
||||||
|
public static boolean compareObjects(Object obj1, Object obj2) {
|
||||||
|
Class<?> clazz = obj1.getClass(); // 获取类信息
|
||||||
|
Field[] fields = clazz.getDeclaredFields(); // 获取所有字段
|
||||||
|
for (Field field : fields) {
|
||||||
|
field.setAccessible(true); // 设置为可访问
|
||||||
|
if (!field.equals(obj2)) { // 判断字段值是否相等
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
drop table if exists public.p_user;
|
||||||
|
create table public.p_user (
|
||||||
|
id int4 generated always as identity primary key,
|
||||||
|
user_id varchar(32) null,
|
||||||
|
login_name varchar(500) null,
|
||||||
|
login_password varchar(500) null,
|
||||||
|
user_name varchar(500) null,
|
||||||
|
mobile_number varchar(500) null,
|
||||||
|
police_number varchar(500) not null,
|
||||||
|
id_number varchar(500) null,
|
||||||
|
effective varchar(1) null default 1,
|
||||||
|
department_id varchar(500) null,
|
||||||
|
create_time timestamp(6) null default now(),
|
||||||
|
update_time timestamp(6) null,
|
||||||
|
job_title varchar(200) null,
|
||||||
|
role_level varchar(10) not null default 1,
|
||||||
|
roles varchar(255) null
|
||||||
|
);
|
||||||
|
create index idx_dep on public.p_user using btree (department_id);
|
||||||
|
create index idx_dep_branch on public.p_user using btree (substr((department_id)::text, 1, 6));
|
||||||
|
create index idx_dep_station on public.p_user using btree (substr((department_id)::text, 1, 8));
|
||||||
|
create index idx_uid on public.p_user using btree (user_id);
|
||||||
|
comment on tree public.p_user.user_id is '用户编号';
|
||||||
|
comment on tree public.p_user.login_name is '用户名(登录账号)';
|
||||||
|
comment on tree public.p_user.login_password is '用户密码(登录密码)';
|
||||||
|
comment on tree public.p_user.user_name is '用户姓名';
|
||||||
|
comment on tree public.p_user.mobile_number is '手机号';
|
||||||
|
comment on tree public.p_user.police_number is '警员编号(警号)';
|
||||||
|
comment on tree public.p_user.id_number is '身份证号';
|
||||||
|
comment on tree public.p_user.effective is '是否启用:0 无效 1有效 默认 1';
|
||||||
|
comment on tree public.p_user.department_id is '所属单位编号';
|
||||||
|
comment on tree public.p_user.create_time is '创建时间';
|
||||||
|
comment on tree public.p_user.update_time is '更新时间';
|
||||||
|
comment on tree public.p_user.job_title is '职称';
|
||||||
|
comment on tree public.p_user.role_level is '等级:0运营 1派出所 2分局';
|
||||||
|
comment on tree public.p_user.roles is 'role id以逗号拼接';
|
||||||
|
|
||||||
|
drop table if exists public.p_role;
|
||||||
|
create table public.p_role (
|
||||||
|
id int4 generated always as identity primary key,
|
||||||
|
role_type varchar(10) null,
|
||||||
|
role_name varchar(255) null,
|
||||||
|
role_desc varchar(255) null,
|
||||||
|
create_at date null,
|
||||||
|
create_by varchar(255) null,
|
||||||
|
update_at date null,
|
||||||
|
update_by varchar(255) null,
|
||||||
|
deleted int2 null,
|
||||||
|
data_scope int4 null
|
||||||
|
);
|
||||||
|
comment on tree public.p_role.role_type is '角色类型-字典表jslx';
|
||||||
|
comment on tree public.p_role.role_name is '角色名';
|
||||||
|
comment on tree public.p_role.role_desc is '角色描述';
|
||||||
|
comment on tree public.p_role.create_at is '创建时间';
|
||||||
|
comment on tree public.p_role.create_by is '创建人';
|
||||||
|
comment on tree public.p_role.update_at is '修改时间';
|
||||||
|
comment on tree public.p_role.update_by is '修改人';
|
||||||
|
comment on tree public.p_role.deleted is '删除标记 0-未删除 1-已删除';
|
||||||
|
comment on tree public.p_role.data_scope is '数据权限定义 1-全部权限 2-本部门及以下部门 3-本部门 4-本人 5-自定义';
|
||||||
|
|
||||||
|
drop table if exists public.p_scene;
|
||||||
|
create table public.p_scene (
|
||||||
|
id int4 generated always as identity primary key,
|
||||||
|
scene_name varchar(255) null,
|
||||||
|
scene_remark varchar(500) null,
|
||||||
|
roles varchar(100) null,
|
||||||
|
model_notes varchar(1000) null,
|
||||||
|
file_url varchar(255) null,
|
||||||
|
"version" varchar(20) null,
|
||||||
|
contribution_name varchar(255) null,
|
||||||
|
scene_type int2 null,
|
||||||
|
scene_url varchar(255) null,
|
||||||
|
scene_skin varchar(16) null,
|
||||||
|
icon_url varchar(255) null,
|
||||||
|
create_at date null,
|
||||||
|
create_by varchar(255) null,
|
||||||
|
update_at date null,
|
||||||
|
update_by varchar(255) null,
|
||||||
|
deleted int2 null,
|
||||||
|
scene_operation varchar(255) null,
|
||||||
|
scene_order int4 null,
|
||||||
|
scene_code varchar(255) null,
|
||||||
|
scene_tag varchar(200) null
|
||||||
|
);
|
||||||
|
comment on tree public.p_scene.scene_name is '场景名称';
|
||||||
|
comment on tree public.p_scene.scene_remark is '场景说明';
|
||||||
|
comment on tree public.p_scene.roles is '适用角色 逗号拼接串';
|
||||||
|
comment on tree public.p_scene.model_notes is '模型逻辑说明';
|
||||||
|
comment on tree public.p_scene.file_url is '文件上传路径';
|
||||||
|
comment on tree public.p_scene."version" is '版本';
|
||||||
|
comment on tree public.p_scene.contribution_name is '贡献者姓名';
|
||||||
|
comment on tree public.p_scene.scene_type is '1:定制 2:永洪编排';
|
||||||
|
comment on tree public.p_scene.scene_url is '场景url';
|
||||||
|
comment on tree public.p_scene.icon_url is 'icon图片地址';
|
||||||
|
comment on tree public.p_scene.create_at is '创建时间';
|
||||||
|
comment on tree public.p_scene.create_by is '创建人';
|
||||||
|
comment on tree public.p_scene.update_at is '修改时间';
|
||||||
|
comment on tree public.p_scene.update_by is '更新人';
|
||||||
|
comment on tree public.p_scene.deleted is '删除标记:0-未删除 1-已删除';
|
||||||
|
comment on tree public.p_scene.scene_operation is '智能脑,聪明口,灵活手,千里眼';
|
||||||
|
comment on tree public.p_scene.scene_order is '排序';
|
||||||
|
comment on tree public.p_scene.scene_code is '场景编码';
|
||||||
|
comment on tree public.p_scene.scene_tag is '技能标签';
|
|
@ -0,0 +1,19 @@
|
||||||
|
select exists (select from information_schema.tables where table_name = 'app_dic') as is_exists;
|
||||||
|
alter table app_dic add column if not exists t_alter varchar(255);
|
||||||
|
alter table app_dic drop column if exists t_alter;
|
||||||
|
drop table if exists app_dic;
|
||||||
|
select * from p_scene where scene_name like '%人%' or scene_remark like '%人%' or model_notes like '%人%';
|
||||||
|
|
||||||
|
--查询表字段和注释
|
||||||
|
select
|
||||||
|
col_description (pg_attr.attrelid, pg_attr.attnum) as comment,
|
||||||
|
format_type (pg_attr.atttypid, pg_attr.atttypmod) as type,
|
||||||
|
pg_attr.attname as name,
|
||||||
|
pg_attr.attnotnull as notnull
|
||||||
|
from
|
||||||
|
pg_class as pg_cla,
|
||||||
|
pg_attribute as pg_attr
|
||||||
|
where
|
||||||
|
pg_cla.relname = 'p_indicator'
|
||||||
|
and pg_attr.attrelid = pg_cla.oid
|
||||||
|
and pg_attr.attnum >0
|
|
@ -0,0 +1,104 @@
|
||||||
|
--generated always 默认从1开始
|
||||||
|
--字典_指标类型
|
||||||
|
drop table if exists indicator_dic;
|
||||||
|
create table indicator_dic (
|
||||||
|
id int4 generated always as identity primary key,
|
||||||
|
indicator_type varchar(128) not null,
|
||||||
|
parent_id int4,
|
||||||
|
create_time timestamp not null,
|
||||||
|
update_time timestamp
|
||||||
|
);
|
||||||
|
comment on column indicator_dic.id is '主键';
|
||||||
|
comment on column indicator_dic.indicator_type is '类型';
|
||||||
|
comment on column indicator_dic.parent_id is '父级ID';
|
||||||
|
comment on column indicator_dic.create_time is '创建时间';
|
||||||
|
comment on column indicator_dic.update_time is '修改时间';
|
||||||
|
insert into indicator_dic(indicator_type,create_time,update_time) values ('基础指标',current_timestamp,current_timestamp);
|
||||||
|
insert into indicator_dic(indicator_type,create_time,update_time) values ('逻辑指标',current_timestamp,current_timestamp);
|
||||||
|
insert into indicator_dic(indicator_type,create_time,update_time) values ('统计指标',current_timestamp,current_timestamp);
|
||||||
|
--字典_应用类型
|
||||||
|
drop table if exists app_dic;
|
||||||
|
create table app_dic (
|
||||||
|
id int4 generated always as identity primary key,
|
||||||
|
app_type varchar(128) not null,
|
||||||
|
parent_id int4,
|
||||||
|
create_time timestamp not null,
|
||||||
|
update_time timestamp
|
||||||
|
);
|
||||||
|
comment on column app_dic.id is '主键';
|
||||||
|
comment on column app_dic.app_type is '类型';
|
||||||
|
comment on column app_dic.parent_id is '父级ID';
|
||||||
|
comment on column app_dic.create_time is '创建时间';
|
||||||
|
comment on column app_dic.update_time is '修改时间';
|
||||||
|
insert into app_dic(app_type,create_time,update_time) values ('态势感知',current_timestamp,current_timestamp);
|
||||||
|
insert into app_dic(app_type,create_time,update_time) values ('智能战果分析',current_timestamp,current_timestamp);
|
||||||
|
insert into app_dic(app_type,parent_id,create_time,update_time) values ('风险人',1,current_timestamp,current_timestamp);
|
||||||
|
insert into app_dic(app_type,parent_id,create_time,update_time) values ('风险事',1,current_timestamp,current_timestamp);
|
||||||
|
insert into app_dic(app_type,parent_id,create_time,update_time) values ('风险物',1,current_timestamp,current_timestamp);
|
||||||
|
insert into app_dic(app_type,parent_id,create_time,update_time) values ('人',2,current_timestamp,current_timestamp);
|
||||||
|
insert into app_dic(app_type,parent_id,create_time,update_time) values ('事',2,current_timestamp,current_timestamp);
|
||||||
|
insert into app_dic(app_type,parent_id,create_time,update_time) values ('物',2,current_timestamp,current_timestamp);
|
||||||
|
|
||||||
|
--表_指标
|
||||||
|
drop table if exists p_indicator;
|
||||||
|
create table p_indicator (
|
||||||
|
id int4 generated always as identity primary key,
|
||||||
|
dynamic_table varchar(128) not null,
|
||||||
|
dynamic_column varchar(128) not null,
|
||||||
|
scene_id int4,
|
||||||
|
indicator_dic_id int4,
|
||||||
|
app_dic_p_id int4,
|
||||||
|
app_dic_c_id int4,
|
||||||
|
search_table varchar(255),
|
||||||
|
search_column varchar(255),
|
||||||
|
indicator_code varchar(128),
|
||||||
|
create_time timestamp not null,
|
||||||
|
update_time timestamp
|
||||||
|
);
|
||||||
|
comment on column p_indicator.id is '指标编号';
|
||||||
|
comment on column p_indicator.dynamic_table is '动态表名称';
|
||||||
|
comment on column p_indicator.dynamic_column is '动态表字段英文名称';
|
||||||
|
comment on column p_indicator.scene_id is '关联技能';
|
||||||
|
comment on column p_indicator.indicator_dic_id is '指标类型';
|
||||||
|
comment on column p_indicator.app_dic_p_id is '关联应用模块';
|
||||||
|
comment on column p_indicator.app_dic_c_id is '关联功能';
|
||||||
|
comment on column p_indicator.search_table is '关联表名称';
|
||||||
|
comment on column p_indicator.search_column is '关联表字段名称';
|
||||||
|
comment on column p_indicator.indicator_code is '代码值';
|
||||||
|
comment on column p_indicator.create_time is '创建时间';
|
||||||
|
comment on column p_indicator.update_time is '修改时间';
|
||||||
|
--表_指标_标签
|
||||||
|
drop table if exists p_indicator_label;
|
||||||
|
create table p_indicator_label (
|
||||||
|
id int4 generated always as identity primary key,
|
||||||
|
table_name varchar(128) not null,
|
||||||
|
label_name varchar(128) not null,
|
||||||
|
label_level int4 not null,
|
||||||
|
parent_id int4,
|
||||||
|
column_name varchar(128),
|
||||||
|
create_time timestamp not null,
|
||||||
|
update_time timestamp
|
||||||
|
);
|
||||||
|
comment on column p_indicator_label.id is '标签ID';
|
||||||
|
comment on column p_indicator_label.table_name is '表名称';
|
||||||
|
comment on column p_indicator_label.label_name is '标签名称';
|
||||||
|
comment on column p_indicator_label.label_level is '标签等级';
|
||||||
|
comment on column p_indicator_label.parent_id is '父级ID';
|
||||||
|
comment on column p_indicator_label.column_name is '字段名称';
|
||||||
|
comment on column p_indicator_label.create_time is '创建时间';
|
||||||
|
comment on column p_indicator_label.update_time is '修改时间';
|
||||||
|
--表_指标_标签_中间表
|
||||||
|
drop table if exists p_indicator_label_tmp;
|
||||||
|
create table p_indicator_label_tmp (
|
||||||
|
id int4 generated always as identity primary key,
|
||||||
|
indicator_id int4,
|
||||||
|
label_id int4,
|
||||||
|
create_time timestamp not null,
|
||||||
|
update_time timestamp
|
||||||
|
);
|
||||||
|
comment on column p_indicator_label_tmp.id is '标签ID';
|
||||||
|
comment on column p_indicator_label_tmp.indicator_id is '指标ID';
|
||||||
|
comment on column p_indicator_label_tmp.label_id is '标签id';
|
||||||
|
comment on column p_indicator_label_tmp.create_time is '创建时间';
|
||||||
|
comment on column p_indicator_label_tmp.update_time is '修改时间';
|
||||||
|
|
|
@ -0,0 +1,168 @@
|
||||||
|
一、indicator api说明
|
||||||
|
1、由appDicCId、appDicPId、indicatorDicId、sceneId组成动态表名
|
||||||
|
2、由dynamicColumnEn和表名判断字段有没有重复
|
||||||
|
3、标签参数说明
|
||||||
|
I、保存指标
|
||||||
|
1、初始化多级标签,所有标签id为null,所有标签都会保存,标签id与父节点的id关联,parent id后台自动通过标签id关联
|
||||||
|
2、级联新增标签,标签格式为:父级(必须包含id)+新增标签
|
||||||
|
3、lableList不能为null,最少有一级标签
|
||||||
|
II、更新指标(需要通过查询获取标签属性后,在之前的属性上进行修改,只能进行属性更新,关联更新需要删除指标+保存指标处理)
|
||||||
|
1、所有标签id不能为null,用于批量或者局部更新(无序、有序标签都可以)
|
||||||
|
2、lableList为null,标签不更新,更新指标其它参数
|
||||||
|
4、删除指标时,含有兄弟节点的只删除最高级标签
|
||||||
|
|
||||||
|
|
||||||
|
二、indicator api测试
|
||||||
|
1、保存indicator
|
||||||
|
I、创建动态表 indicator_2_1_2_6,字段为id,c1, 标签为:爷爷1 → 儿子1 → 孙子1
|
||||||
|
{
|
||||||
|
"appDicCId": 6,
|
||||||
|
"appDicPId": 2,
|
||||||
|
"dynamicColumnEn": "c1",
|
||||||
|
"indicatorDicId": 1,
|
||||||
|
"lableList": [
|
||||||
|
{
|
||||||
|
"labelLevel": 1,
|
||||||
|
"labelName": "爷爷1"
|
||||||
|
},{
|
||||||
|
"labelLevel": 2,
|
||||||
|
"labelName": "儿子1"
|
||||||
|
},{
|
||||||
|
"labelLevel": 3,
|
||||||
|
"labelName": "孙子1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sceneId": 2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
II、更新表indicator_2_1_2_6,新字段为c2, 标签为:爷爷1 → 儿子1 → 孙子1,孙子2
|
||||||
|
{
|
||||||
|
"appDicCId": 6,
|
||||||
|
"appDicPId": 2,
|
||||||
|
"dynamicColumnEn": "c2",
|
||||||
|
"indicatorDicId": 1,
|
||||||
|
"lableList": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"labelLevel": 1,
|
||||||
|
"labelName": "爷爷1"
|
||||||
|
},{
|
||||||
|
"id": 2,
|
||||||
|
"labelLevel": 2,
|
||||||
|
"labelName": "儿子1"
|
||||||
|
},{
|
||||||
|
"labelLevel": 3,
|
||||||
|
"labelName": "孙子2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sceneId": 2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
III、更新表indicator_2_1_2_6,新字段为c3, 标签为:爷爷1 → 儿子1 → 孙子1,孙子2 | 爷爷2
|
||||||
|
{
|
||||||
|
"appDicCId": 6,
|
||||||
|
"appDicPId": 2,
|
||||||
|
"dynamicColumnEn": "c3",
|
||||||
|
"indicatorDicId": 1,
|
||||||
|
"lableList": [
|
||||||
|
{
|
||||||
|
"labelLevel": 1,
|
||||||
|
"labelName": "爷爷2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sceneId": 2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IV、更新表indicator_2_1_2_6,新字段为c4, 标签为:爷爷1 → 儿子1 → 孙子1,孙子2 | 爷爷2 | 爷爷3 → 儿子1
|
||||||
|
{
|
||||||
|
"appDicCId": 6,
|
||||||
|
"appDicPId": 2,
|
||||||
|
"dynamicColumnEn": "c4",
|
||||||
|
"indicatorDicId": 1,
|
||||||
|
"lableList": [
|
||||||
|
{
|
||||||
|
"labelLevel": 1,
|
||||||
|
"labelName": "爷爷3"
|
||||||
|
},{
|
||||||
|
"labelLevel": 2,
|
||||||
|
"labelName": "儿子1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sceneId": 2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
V、更新表indicator_2_1_2_6,新字段为c5, 标签为:爷爷1 → 儿子1 → 孙子1,孙子2 | 爷爷2 | 爷爷3 → 儿子1,儿子2
|
||||||
|
{
|
||||||
|
"appDicCId": 6,
|
||||||
|
"appDicPId": 2,
|
||||||
|
"dynamicColumnEn": "c5",
|
||||||
|
"indicatorDicId": 1,
|
||||||
|
"lableList": [
|
||||||
|
{
|
||||||
|
"id": 6,
|
||||||
|
"labelLevel": 1,
|
||||||
|
"labelName": "爷爷3"
|
||||||
|
},{
|
||||||
|
"labelLevel": 2,
|
||||||
|
"labelName": "儿子2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sceneId": 2
|
||||||
|
}
|
||||||
|
|
||||||
|
VI、更新表indicator_2_1_2_6,新字段为c6, 标签为:爷爷1 → 儿子1 → 孙子1,孙子2,孙子3 | 爷爷2 | 爷爷3 → 儿子1,儿子2
|
||||||
|
{
|
||||||
|
"appDicCId": 6,
|
||||||
|
"appDicPId": 2,
|
||||||
|
"dynamicColumnEn": "c6",
|
||||||
|
"indicatorDicId": 1,
|
||||||
|
"lableList": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"labelLevel": 1,
|
||||||
|
"labelName": "爷爷1"
|
||||||
|
},{
|
||||||
|
"id": 2,
|
||||||
|
"labelLevel": 2,
|
||||||
|
"labelName": "儿子1"
|
||||||
|
},{
|
||||||
|
"labelLevel": 3,
|
||||||
|
"labelName": "孙子3"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sceneId": 2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
2、更新indicator
|
||||||
|
|
||||||
|
I、更新表indicator_2_1_2_6,新字段为c7, id
|
||||||
|
{
|
||||||
|
"id": 7,
|
||||||
|
"appDicCId": 6,
|
||||||
|
"appDicPId": 2,
|
||||||
|
"dynamicColumnEn": "column7",
|
||||||
|
"indicatorDicId": 1,
|
||||||
|
"lableList": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"labelLevel": 1,
|
||||||
|
"labelName": "爷爷1"
|
||||||
|
},{
|
||||||
|
"id": 1,
|
||||||
|
"labelLevel": 2,
|
||||||
|
"labelName": "儿子2"
|
||||||
|
},{
|
||||||
|
"labelLevel": 3,
|
||||||
|
"labelName": "孙子1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sceneId": 2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
Manifest-Version: 1.0
|
||||||
|
Main-Class: com.indicator.Run
|
||||||
|
Class-Path: spring-plugin-core-2.0.0.RELEASE.jar swagger-annotations-1.6
|
||||||
|
.6.jar slf4j-api-1.7.36.jar simpleclient_tracer_otel_agent-0.15.0.jar m
|
||||||
|
change-commons-java-0.2.19.jar bcutil-jdk15on-1.69.jar spring-context-s
|
||||||
|
upport-1.0.10.jar spring-plugin-metadata-2.0.0.RELEASE.jar commons-io-2
|
||||||
|
.2.jar springfox-swagger-common-2.10.5.jar log4j-to-slf4j-2.17.2.jar ja
|
||||||
|
vassist-3.25.0-GA.jar spring-cloud-alibaba-commons-2021.1.jar swagger-m
|
||||||
|
odels-1.6.6.jar httpasyncclient-4.1.5.jar simpleclient_tracer_otel-0.15
|
||||||
|
.0.jar logback-core-1.2.12.jar feign-form-3.8.0.jar animal-sniffer-anno
|
||||||
|
tations-1.14.jar c3p0-0.9.5.5.jar postgresql-42.3.8.jar spring-security
|
||||||
|
-rsa-1.0.11.RELEASE.jar mybatis-spring-2.1.2.jar spring-boot-starter-2.
|
||||||
|
7.12.jar spring-webmvc-5.3.27.jar checker-qual-3.5.0.jar spring-boot-st
|
||||||
|
arter-aop-2.7.12.jar spring-core-5.3.27.jar simpleclient_tracer_common-
|
||||||
|
0.15.0.jar jsr305-1.3.9.jar spring-cloud-openfeign-core-3.1.8.jar sprin
|
||||||
|
g-boot-devtools-2.7.12.jar spring-boot-starter-web-2.7.12.jar jackson-d
|
||||||
|
atatype-jdk8-2.13.5.jar spring-security-crypto-5.7.8.jar spring-boot-st
|
||||||
|
arter-jdbc-2.7.12.jar spring-jcl-5.3.27.jar spring-cloud-starter-3.1.7.
|
||||||
|
jar spring-boot-autoconfigure-2.7.12.jar protobuf-java-3.11.4.jar tomca
|
||||||
|
t-embed-core-9.0.75.jar lombok-1.18.22.jar simpleclient-0.15.0.jar myba
|
||||||
|
tis-plus-core-3.5.5.jar bcpkix-jdk15on-1.69.jar springfox-spi-2.10.5.ja
|
||||||
|
r jackson-module-parameter-names-2.13.5.jar mybatis-plus-extension-3.5.
|
||||||
|
5.jar feign-slf4j-11.10.jar spring-beans-5.3.27.jar springfox-schema-2.
|
||||||
|
10.5.jar hibernate-validator-6.2.5.Final.jar httpcore-4.4.16.jar jackso
|
||||||
|
n-core-2.13.5.jar spring-boot-starter-tomcat-2.7.12.jar mybatis-3.5.15.
|
||||||
|
jar springfox-spring-webmvc-2.10.5.jar knife4j-openapi2-spring-boot-sta
|
||||||
|
rter-4.1.0.jar HikariCP-4.0.3.jar spring-web-5.3.27.jar httpcore-nio-4.
|
||||||
|
4.16.jar mybatis-plus-boot-starter-3.5.5.jar spring-boot-2.7.12.jar htt
|
||||||
|
pclient-4.5.14.jar spring-boot-starter-validation-2.7.12.jar nacos-api-
|
||||||
|
1.4.1.jar error_prone_annotations-2.1.3.jar springfox-spring-web-2.10.5
|
||||||
|
.jar spring-tx-5.3.27.jar jakarta.annotation-api-1.3.5.jar log4j-api-2.
|
||||||
|
17.2.jar checker-compat-qual-2.0.0.jar snakeyaml-1.30.jar jakarta.valid
|
||||||
|
ation-api-2.0.2.jar spring-aop-5.3.27.jar mapstruct-1.3.1.Final.jar fei
|
||||||
|
gn-form-spring-3.8.0.jar jackson-annotations-2.13.5.jar tomcat-embed-el
|
||||||
|
-9.0.75.jar tomcat-embed-websocket-9.0.75.jar j2objc-annotations-1.1.ja
|
||||||
|
r knife4j-core-4.1.0.jar spring-cloud-starter-alibaba-nacos-discovery-2
|
||||||
|
021.1.jar mybatis-plus-annotation-3.5.5.jar bcprov-jdk15on-1.69.jar spr
|
||||||
|
ingfox-bean-validators-2.10.5.jar jackson-datatype-jsr310-2.13.5.jar cl
|
||||||
|
assgraph-4.1.7.jar nacos-client-1.4.1.jar byte-buddy-1.12.23.jar spring
|
||||||
|
-cloud-context-3.1.7.jar aspectjweaver-1.9.7.jar springfox-core-2.10.5.
|
||||||
|
jar mybatis-plus-3.5.5.jar jboss-logging-3.4.3.Final.jar spring-jdbc-5.
|
||||||
|
3.27.jar guava-24.1.1-jre.jar knife4j-openapi2-ui-4.1.0.jar springfox-s
|
||||||
|
wagger-ui-2.10.5.jar mybatis-plus-spring-boot-autoconfigure-3.5.5.jar s
|
||||||
|
pring-cloud-commons-3.1.7.jar spring-context-5.3.27.jar commons-fileupl
|
||||||
|
oad-1.5.jar jul-to-slf4j-1.7.36.jar spring-cloud-starter-openfeign-3.1.
|
||||||
|
8.jar nacos-common-1.4.1.jar classmate-1.5.1.jar jsqlparser-4.6.jar log
|
||||||
|
back-classic-1.2.12.jar fastjson2-2.0.10.jar jackson-databind-2.13.5.ja
|
||||||
|
r mysql-connector-java-8.0.28.jar spring-boot-starter-json-2.7.12.jar f
|
||||||
|
eign-core-11.10.jar commons-codec-1.15.jar spring-boot-starter-logging-
|
||||||
|
2.7.12.jar springfox-swagger2-2.10.5.jar spring-expression-5.3.27.jar
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.szr</groupId>
|
||||||
|
<artifactId>center</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>com.szr</groupId>
|
||||||
|
<artifactId>indicator</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!--基础 包 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.szr</groupId>
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- jdbc 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mchange</groupId>
|
||||||
|
<artifactId>c3p0</artifactId>
|
||||||
|
<version>${c3p0.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.postgresql</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
<version>${postgresql.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>${mysql.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 热部署 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
<scope>true</scope>
|
||||||
|
</dependency>
|
||||||
|
<!--测试依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-collections4</artifactId>
|
||||||
|
<version>4.4</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.indicator;
|
||||||
|
|
||||||
|
import com.indicator.init.CustomInitializer;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
|
||||||
|
|
||||||
|
@EnableDiscoveryClient
|
||||||
|
@SpringBootApplication
|
||||||
|
public class Run {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication application = new SpringApplication(Run.class);
|
||||||
|
application.addInitializers(new CustomInitializer());
|
||||||
|
application.run();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.indicator.aop;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.common.info.Parameter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.*;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class LogAop {
|
||||||
|
@Pointcut("execution( * com.indicator.controller..*.*(..))")
|
||||||
|
public void log() {}
|
||||||
|
|
||||||
|
@Around("log()")
|
||||||
|
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||||
|
long startTime=System.currentTimeMillis();
|
||||||
|
Object result=joinPoint.proceed();
|
||||||
|
log.info("Response:"+ JSON.toJSON(result));
|
||||||
|
log.info("耗时:"+(System.currentTimeMillis()-startTime));
|
||||||
|
log.info("==================End=================");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before("log()")
|
||||||
|
public void doBefore(JoinPoint joinPoint) {
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
log.info("");
|
||||||
|
log.info("==================Start=================");
|
||||||
|
log.info("URL:" + request.getRequestURL().toString());
|
||||||
|
log.info("Header:" +Parameter.TOKEN + " = " + request.getHeader(Parameter.TOKEN));
|
||||||
|
log.info("Method:" + request.getMethod().toString());
|
||||||
|
log.info("Class Method:" + joinPoint.getSignature().getDeclaringTypeName() + "," + joinPoint.getSignature().getName());
|
||||||
|
log.info("客户端IP:" + request.getRemoteAddr());
|
||||||
|
log.info("请求参数:" + JSON.toJSON(joinPoint.getArgs()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.indicator.config;
|
||||||
|
|
||||||
|
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class C3P0Config {
|
||||||
|
@Bean("datasource")
|
||||||
|
@Primary
|
||||||
|
@ConfigurationProperties(prefix = "c3p0")
|
||||||
|
public DataSource dataSource(){
|
||||||
|
return DataSourceBuilder.create().type(ComboPooledDataSource.class).build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.indicator.config;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@MapperScan("com.indicator.mapper")
|
||||||
|
public class PageConfig {
|
||||||
|
@Bean
|
||||||
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL));
|
||||||
|
return interceptor;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.indicator.config;
|
||||||
|
|
||||||
|
import com.indicator.filter.TokenInterceptor;
|
||||||
|
import com.indicator.repository.UserRepository;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* http://localhost:8601/doc.html
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@Import(BeanValidatorPluginsConfiguration.class)
|
||||||
|
@EnableSwagger2WebMvc
|
||||||
|
public class Swagger2Config implements WebMvcConfigurer {
|
||||||
|
@Resource
|
||||||
|
private UserRepository userRepository;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Docket createRestApi() {
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.apiInfo(new ApiInfoBuilder()
|
||||||
|
.title("指标设置 API")
|
||||||
|
.description("指标设置 API 说明,Token认证添加Header参数设置步骤: 文档管理 > 个性化设置 > 开启请求参数缓存,开启动态请求参数 | 设置完需要刷新页面")
|
||||||
|
.version("V-1.0")
|
||||||
|
.build())
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("com.indicator.controller"))
|
||||||
|
.paths(PathSelectors.any())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
//过滤器
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
//添加拦截器
|
||||||
|
registry.addInterceptor(new TokenInterceptor(userRepository))
|
||||||
|
.addPathPatterns("/**")
|
||||||
|
.excludePathPatterns("/doc.html")
|
||||||
|
.excludePathPatterns("/swagger-resources/**")
|
||||||
|
.excludePathPatterns("/webjars/**")
|
||||||
|
.excludePathPatterns("/v2/**")
|
||||||
|
.excludePathPatterns("/favicon.ico")
|
||||||
|
.excludePathPatterns("/swagger-ui.html/**")
|
||||||
|
.excludePathPatterns("/keyPerson/callBackResult")
|
||||||
|
.excludePathPatterns("/upload/**")
|
||||||
|
.excludePathPatterns("/openapi/*");//白名单
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,707 @@
|
||||||
|
package com.indicator.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.common.entity.Scene;
|
||||||
|
import com.common.entity.dic.IndicatorDic;
|
||||||
|
import com.common.entity.dic.AppDic;
|
||||||
|
import com.common.info.CodeMsg;
|
||||||
|
import com.indicator.entity.Indicator;
|
||||||
|
import com.indicator.entity.IndicatorLabel;
|
||||||
|
import com.indicator.entity.Label;
|
||||||
|
import com.indicator.info.Result;
|
||||||
|
import com.indicator.mapper.IndicatorLabelMapper;
|
||||||
|
import com.indicator.mapper.LabelMapper;
|
||||||
|
import com.indicator.repository.*;
|
||||||
|
import com.indicator.vo.IndicatorVo;
|
||||||
|
import com.indicator.info.Search;
|
||||||
|
import com.indicator.vo.DynamicTable;
|
||||||
|
import com.indicator.mapper.IndicatorMapper;
|
||||||
|
import com.indicator.service.DynamicTableService;
|
||||||
|
import com.indicator.service.SearchService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/indicator")
|
||||||
|
@Api(tags = "服务接口")
|
||||||
|
public class IndicatorController {
|
||||||
|
@Resource
|
||||||
|
private SceneRepository sceneRepository;
|
||||||
|
@Resource
|
||||||
|
private IndicatorDicRepository indicatorDicRepository;
|
||||||
|
@Resource
|
||||||
|
private AppDicRepository appDicRepository;
|
||||||
|
@Resource
|
||||||
|
private IndicatorRepository indicatorRepository;
|
||||||
|
@Resource
|
||||||
|
private IndicatorMapper indicatorMapper;
|
||||||
|
@Resource
|
||||||
|
private LabelRepository labelRepository;
|
||||||
|
@Resource
|
||||||
|
private LabelMapper labelMapper;
|
||||||
|
@Resource
|
||||||
|
private IndicatorLabelRepository indicatorLabelRepository;
|
||||||
|
@Resource
|
||||||
|
private IndicatorLabelMapper indicatorLabelMapper;
|
||||||
|
@Resource
|
||||||
|
private DynamicTableService dynamicTableService;
|
||||||
|
@Resource
|
||||||
|
private SearchService searchService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void setSuccess(Result result){
|
||||||
|
if(result.getCode() == null){
|
||||||
|
result.setCode(CodeMsg.SUCCESS.getCode());
|
||||||
|
}
|
||||||
|
if(result.getMsg() == null){
|
||||||
|
result.setMsg(CodeMsg.SUCCESS.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setListSuccess(Result result,List list){
|
||||||
|
setSuccess(result);
|
||||||
|
|
||||||
|
if(list != null){
|
||||||
|
result.setData(list);
|
||||||
|
if(result.getTotal() == null){
|
||||||
|
result.setTotal((long) list.size());
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
result.setTotal(0L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFailure(Result result){
|
||||||
|
if(result.getCode() == null){
|
||||||
|
result.setCode(CodeMsg.FAILURE.getCode());
|
||||||
|
}
|
||||||
|
if(result.getMsg() == null){
|
||||||
|
result.setMsg(CodeMsg.FAILURE.getMessage());
|
||||||
|
}
|
||||||
|
result.setTotal(0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setExFailure(Result result,Exception e){
|
||||||
|
result.setData(e.getMessage());
|
||||||
|
setFailure(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联场景查询
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取关联场景",notes = "获取关联场景列表信息")
|
||||||
|
@GetMapping("get_scenes")
|
||||||
|
public Result getScenes() {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
List<Scene> list = sceneRepository.list();
|
||||||
|
setListSuccess(result,list);
|
||||||
|
log.info("-------- 获取关联场景成功 ");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 获取关联场景异常 : "+e.getMessage(),e);
|
||||||
|
setExFailure(result,e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指标类型查询
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取指标类型",notes = "获取指标类型列表信息")
|
||||||
|
@GetMapping("get_indicator_dic")
|
||||||
|
public Result getIndicatorDic() {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
List<IndicatorDic> list = indicatorDicRepository.list();
|
||||||
|
setListSuccess(result,list);
|
||||||
|
log.info("-------- 获取指标类型成功 ");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 获取指标类型异常 : "+e.getMessage(),e);
|
||||||
|
setExFailure(result,e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联应用模块类型查询
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取关联应用模块类型",notes = "获取关联应用模块类型列表信息")
|
||||||
|
@GetMapping("get_app_p_dic")
|
||||||
|
public Result getAppPDic() {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
List<AppDic> list = appDicRepository.lambdaQuery().isNull(AppDic::getParentId).list();
|
||||||
|
setListSuccess(result,list);
|
||||||
|
log.info("-------- 获取关联应用模块成功 ");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 获取关联应用模块异常 : "+e.getMessage(),e);
|
||||||
|
setExFailure(result,e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联功能类型查询
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取关联功能类型",notes = "获取关联功能类型列表信息")
|
||||||
|
@ApiImplicitParam(name = "p_id",value = "关联应用模块类型 id,Content-Type:application/x-www-form-urlencoded",required = true)
|
||||||
|
@GetMapping("get_app_c_dic")
|
||||||
|
public Result getAppCDic(Integer p_id) {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
List<AppDic> list = appDicRepository.lambdaQuery().eq(AppDic::getParentId,p_id).list();
|
||||||
|
setListSuccess(result,list);
|
||||||
|
log.info("-------- 获取联功能成功 ");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 获取联功能异常,p_id : "+p_id,e);
|
||||||
|
setExFailure(result,e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联应用表信息查询
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取关联应用表信息",notes = "获取关联应用表信息")
|
||||||
|
@GetMapping("get_app_tables")
|
||||||
|
public Result getAppTables() {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
List<String> list = searchService.getTableNames();
|
||||||
|
setListSuccess(result,list);
|
||||||
|
log.info("-------- 获取关联应用表成功 ");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 获取关联应用表异常 : "+e.getMessage(),e);
|
||||||
|
setExFailure(result,e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联应用表信息查询
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取关联应用表字段信息",notes = "获取关联应用表字段信息")
|
||||||
|
@ApiImplicitParam(name = "tableName",value = "关联应用表名称,Content-Type:application/x-www-form-urlencoded",required = true)
|
||||||
|
@GetMapping("get_app_table_columns")
|
||||||
|
public Result getAppTableColumns(String tableName) {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
List<String> list = searchService.getColumns(tableName);
|
||||||
|
setListSuccess(result,list);
|
||||||
|
log.info("-------- 获取关联应用表字段成功 ");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 获取关联应用表字段异常 : "+e.getMessage(),e);
|
||||||
|
setExFailure(result,e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联应用模块类型查询
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取一级标签",notes = "获取一级标签列表信息")
|
||||||
|
@GetMapping("get_p_label")
|
||||||
|
public Result getPLabel() {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
List<Label> list = labelRepository.lambdaQuery().isNull(Label::getParentId).list();
|
||||||
|
setListSuccess(result,list);
|
||||||
|
log.info("-------- 获取一级标签成功 ");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 获取一级标签异常 : "+e.getMessage(),e);
|
||||||
|
setExFailure(result,e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标签查询
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取子级标签",notes = "获取子级标签列表信息")
|
||||||
|
@ApiImplicitParam(name = "p_id",value = "标签 id,Content-Type:application/x-www-form-urlencoded",required = true)
|
||||||
|
@GetMapping("get_c_label")
|
||||||
|
public Result getCLabel(Integer p_id) {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
List<Label> list = labelRepository.lambdaQuery().eq(Label::getParentId,p_id).list();
|
||||||
|
setListSuccess(result,list);
|
||||||
|
log.info("-------- 获取子级标签成功 ");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 获取子级标签异常,p_id : "+p_id,e);
|
||||||
|
setExFailure(result,e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Indicator> getValidList(Indicator indicator){
|
||||||
|
List<Indicator> list = indicatorRepository.lambdaQuery()
|
||||||
|
.eq(Indicator::getSceneId,indicator.getSceneId())
|
||||||
|
.eq(Indicator::getIndicatorDicId,indicator.getIndicatorDicId())
|
||||||
|
.eq(Indicator::getAppDicPId,indicator.getAppDicPId())
|
||||||
|
.eq(Indicator::getAppDicCId,indicator.getAppDicCId())
|
||||||
|
.eq(Indicator::getDynamicColumn,indicator.getDynamicColumn())
|
||||||
|
.list();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int validSave(Indicator indicator){
|
||||||
|
List<Indicator> list = getValidList(indicator);
|
||||||
|
if(list != null && list.size() > 0){
|
||||||
|
return 1;
|
||||||
|
}else {
|
||||||
|
//true
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int validUpdate(Indicator indicator,Indicator oldIndicator){
|
||||||
|
List<Indicator> list5 = getValidList(indicator);
|
||||||
|
List<Indicator> list6 = indicatorRepository.lambdaQuery()
|
||||||
|
.eq(Indicator::getSceneId,indicator.getSceneId())
|
||||||
|
.eq(Indicator::getIndicatorDicId,indicator.getIndicatorDicId())
|
||||||
|
.eq(Indicator::getAppDicPId,indicator.getAppDicPId())
|
||||||
|
.eq(Indicator::getAppDicCId,indicator.getAppDicCId())
|
||||||
|
.eq(Indicator::getDynamicColumn,indicator.getDynamicColumn())
|
||||||
|
.eq(Indicator::getId,indicator.getId())
|
||||||
|
.list();
|
||||||
|
List<Indicator> list4 = indicatorRepository.lambdaQuery()
|
||||||
|
.eq(Indicator::getSceneId,indicator.getSceneId())
|
||||||
|
.eq(Indicator::getIndicatorDicId,indicator.getIndicatorDicId())
|
||||||
|
.eq(Indicator::getAppDicPId,indicator.getAppDicPId())
|
||||||
|
.eq(Indicator::getAppDicCId,indicator.getAppDicCId())
|
||||||
|
.list();
|
||||||
|
|
||||||
|
if(oldIndicator != null){
|
||||||
|
if(list5 != null && list5.size() > 0){
|
||||||
|
if(list6 != null && list6.size() > 0){
|
||||||
|
//自身更新,true
|
||||||
|
return 1;
|
||||||
|
}else {
|
||||||
|
//en name 重复
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
String tableName = dynamicTableService.getTableName(indicator);
|
||||||
|
String oldTableName = dynamicTableService.getTableName(oldIndicator);
|
||||||
|
if(list4 != null && list4.size() > 0 && oldTableName.equals(tableName)){
|
||||||
|
//代表同一张表
|
||||||
|
//rename true
|
||||||
|
return 4;
|
||||||
|
}else {
|
||||||
|
//2张表联动更新 true
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
//id不存在
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验指标动态表名称
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "校验指标动态表名称",notes = "新建0和1代表合法;更新0代表合法")
|
||||||
|
@PostMapping("valid_dynamic_column")
|
||||||
|
public Result validDynamicColumn(@RequestBody Indicator indicator) {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
int flag;
|
||||||
|
if(indicator.getId() != null){
|
||||||
|
Indicator oldIndicator = indicatorRepository.lambdaQuery().eq(Indicator::getId,indicator.getId()).one();
|
||||||
|
flag = validUpdate(indicator,oldIndicator);
|
||||||
|
if(0 == flag || 1 == flag){
|
||||||
|
log.info("-------- 指标动态字段可用,name :"+indicator.getDynamicColumn());
|
||||||
|
result.setCode(CodeMsg.SUCCESS.getCode());
|
||||||
|
result.setMsg("指标英文名称可用");
|
||||||
|
}else {
|
||||||
|
log.error("-------- 指标动态字段重名!!! name :"+indicator.getDynamicColumn());
|
||||||
|
result.setCode(CodeMsg.FAILURE.getCode());
|
||||||
|
result.setMsg("指标动态字段重名");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
flag = validSave(indicator);
|
||||||
|
if(0 == flag){
|
||||||
|
log.info("-------- 指标动态字段可用,name :"+indicator.getDynamicColumn());
|
||||||
|
result.setCode(CodeMsg.SUCCESS.getCode());
|
||||||
|
result.setMsg("指标英文名称可用");
|
||||||
|
}else {
|
||||||
|
log.error("-------- 指标动态字段重名!!! name :"+indicator.getDynamicColumn());
|
||||||
|
result.setCode(CodeMsg.FAILURE.getCode());
|
||||||
|
result.setMsg("指标动态字段重名");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.setTotal(0L);
|
||||||
|
result.setData(flag);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 获取联功能异常,indicator : "+indicator,e);
|
||||||
|
setExFailure(result,e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取标签")
|
||||||
|
@ApiImplicitParams({@ApiImplicitParam(name = "table", value = "表名称", required = true),@ApiImplicitParam(name = "level", value = "级别", required = true)})
|
||||||
|
@GetMapping("get_label")
|
||||||
|
public Result getLabel(String table,int level) {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
List<Label> list = labelRepository.lambdaQuery().eq(Label::getTableName,table).eq(Label::getLabelLevel,level).list();
|
||||||
|
setListSuccess(result,list);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 获取联功能异常,table : "+table+" level:"+level,e);
|
||||||
|
setExFailure(result,e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存或修改指标
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "保存或修改指标",notes = "保存指标")
|
||||||
|
@PostMapping("save_update_indicator")
|
||||||
|
@Transactional
|
||||||
|
public Result saveUpdateIndicator(@RequestBody IndicatorVo indicator) {
|
||||||
|
Result result = new Result();
|
||||||
|
Date date = new Date();
|
||||||
|
boolean updateFlag = true;
|
||||||
|
int updateNum = 6;
|
||||||
|
Indicator oldIndicator = null;
|
||||||
|
String tableName = null;
|
||||||
|
try {
|
||||||
|
tableName = dynamicTableService.getTableName(indicator);
|
||||||
|
//1、校验指标名称会不会重复
|
||||||
|
if(indicator.getId() == null){
|
||||||
|
updateFlag = false;
|
||||||
|
|
||||||
|
if(validSave(indicator) == 0){
|
||||||
|
indicator.setCreateTime(date);
|
||||||
|
indicator.setUpdateTime(date);
|
||||||
|
}else {
|
||||||
|
result.setCode(CodeMsg.FAILURE.getCode());
|
||||||
|
result.setMsg("参数错误");
|
||||||
|
result.setTotal(0L);
|
||||||
|
result.setData("保存指标动态表字段重复 table name : column " + tableName +" : "+indicator.getDynamicColumn());
|
||||||
|
log.error("-------- 保存指标动态表字段重复 table name : column " + tableName +" : "+indicator.getDynamicColumn());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
oldIndicator = indicatorRepository.lambdaQuery().eq(Indicator::getId,indicator.getId()).one();
|
||||||
|
updateNum = validUpdate(indicator,oldIndicator);
|
||||||
|
if(updateNum == 0 || updateNum == 1){
|
||||||
|
indicator.setUpdateTime(date);
|
||||||
|
}else {
|
||||||
|
if(updateNum == 2){
|
||||||
|
result.setData("保存指标动态表字段重复 table name : column " + tableName +" : "+indicator.getDynamicColumn());
|
||||||
|
log.error("-------- 保存指标动态表字段重复 table name : column " + tableName +" : "+indicator.getDynamicColumn());
|
||||||
|
result.setCode(CodeMsg.FAILURE.getCode());
|
||||||
|
result.setMsg("参数错误");
|
||||||
|
result.setTotal(0L);
|
||||||
|
return result;
|
||||||
|
}else if(updateNum == 3){
|
||||||
|
result.setData("在数据库中找不到需要更新的 id = " + indicator.getId());
|
||||||
|
log.error("-------- 在数据库中找不到需要更新的 id = " + indicator.getId());
|
||||||
|
result.setCode(CodeMsg.FAILURE.getCode());
|
||||||
|
result.setMsg("参数错误");
|
||||||
|
result.setTotal(0L);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("--------1、 指标动态字段 : " + tableName +"_"+indicator.getDynamicColumn()+" 校验成功");
|
||||||
|
|
||||||
|
//2、创建表 , 后面的异常要向上抛出
|
||||||
|
indicator.setDynamicTable(tableName);
|
||||||
|
List<Label> label_list = indicator.getLableList();
|
||||||
|
if(label_list != null && label_list.size()>0) {
|
||||||
|
Collections.sort(label_list, (Label1, Label2) -> Label1.getLabelLevel() - Label2.getLabelLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean indicator_flag = indicatorRepository.saveOrUpdate(indicator);
|
||||||
|
if(indicator_flag){
|
||||||
|
if(!updateFlag){
|
||||||
|
if(label_list == null || label_list.size()==0){
|
||||||
|
log.error("-------- 保存指标异常, 保存指标时, 标签不能为空,最少包含一级标签");
|
||||||
|
throw new RuntimeException("保存指标时, 标签不能为空,最少包含一级标签");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(label_list != null && label_list.size()>0){
|
||||||
|
for (int i = 0; i < label_list.size(); i++) {
|
||||||
|
if(!updateFlag){
|
||||||
|
if(i > 0 && i <(label_list.size())) {
|
||||||
|
label_list.get(i).setParentId(label_list.get(i-1).getId());
|
||||||
|
}
|
||||||
|
label_list.get(i).setCreateTime(date);
|
||||||
|
}else {
|
||||||
|
if (label_list.get(i).getId() == null) {
|
||||||
|
log.error("-------- 保存指标异常, 更新指标时, 标签id不能为空" + label_list.get(i));
|
||||||
|
throw new RuntimeException("更新指标时, 标签id不能为空" + label_list.get(i));
|
||||||
|
}
|
||||||
|
List<IndicatorLabel> I_L_list =indicatorLabelRepository.lambdaQuery().eq(IndicatorLabel::getIndicatorId,indicator.getId()).list();
|
||||||
|
boolean ILFlag = false;
|
||||||
|
for (int j=0; j<I_L_list.size(); j++) {
|
||||||
|
if(label_list.get(i).getId() == I_L_list.get(j).getLabelId()){
|
||||||
|
ILFlag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!ILFlag){
|
||||||
|
log.error("-------- 保存指标异常, 更新指标id : "+label_list.get(i).getId()+"无效,请输入正确的指标id");
|
||||||
|
throw new RuntimeException("更新指标id : "+label_list.get(i).getId()+"无效,请输入正确的指标id");
|
||||||
|
}
|
||||||
|
Label label = labelRepository.getById(label_list.get(i).getId());
|
||||||
|
label_list.get(i).setParentId(label.getParentId());
|
||||||
|
}
|
||||||
|
label_list.get(i).setTableName(tableName);
|
||||||
|
label_list.get(i).setUpdateTime(date);
|
||||||
|
if(i == label_list.size()-1){
|
||||||
|
label_list.get(i).setColumnName(indicator.getDynamicColumn());
|
||||||
|
}
|
||||||
|
boolean label_flag = labelRepository.saveOrUpdate(label_list.get(i));
|
||||||
|
|
||||||
|
System.out.println("___"+label_list.get(i).getId());
|
||||||
|
if(label_flag){
|
||||||
|
if(!updateFlag){
|
||||||
|
IndicatorLabel indicator_label = new IndicatorLabel();
|
||||||
|
indicator_label.setIndicatorId(indicator.getId());
|
||||||
|
indicator_label.setLabelId(label_list.get(i).getId());
|
||||||
|
indicator_label.setCreateTime(date);
|
||||||
|
indicator_label.setUpdateTime(date);
|
||||||
|
indicatorLabelRepository.saveOrUpdate(indicator_label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
log.error("-------- 保存指标异常, 更新指标失败 : table , column (" + tableName +" , "+indicator.getDynamicColumn()+")");
|
||||||
|
throw new RuntimeException("更新指标失败 : table , column (" + tableName +" , "+indicator.getDynamicColumn()+")");
|
||||||
|
}
|
||||||
|
log.info("--------2、 动态标签创建成功");
|
||||||
|
|
||||||
|
if(StringUtils.hasLength(indicator.getDynamicColumn())){
|
||||||
|
if(2 == indicator.getAppDicPId()){
|
||||||
|
result.setData("创建动态表 : table , column (" + tableName +" , "+indicator.getDynamicColumn()+")");
|
||||||
|
if(updateFlag){
|
||||||
|
//updateNum == 1 自身更新,无需修改表
|
||||||
|
if(updateNum == 0){
|
||||||
|
dynamicTableService.executeUpdate0(indicator,oldIndicator);
|
||||||
|
}else if(updateNum == 4){
|
||||||
|
dynamicTableService.executeUpdate1(indicator,oldIndicator);
|
||||||
|
}
|
||||||
|
result.setMsg("更新成功");
|
||||||
|
log.info("-------- 更新成功 : table , column (" + tableName +" , "+indicator.getDynamicColumn()+")");
|
||||||
|
}else {
|
||||||
|
dynamicTableService.executeSave(indicator);
|
||||||
|
result.setMsg("保存成功");
|
||||||
|
log.info("-------- 保存指标成功 : table , column (" + tableName +" , "+indicator.getDynamicColumn()+")");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
log.info("-------- 指标类型 :" + indicator.getAppDicPId() +" 动态表未改动");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
log.info("-------- 英文字段为空,动态表未改动");
|
||||||
|
}
|
||||||
|
|
||||||
|
result.setCode(CodeMsg.SUCCESS.getCode());
|
||||||
|
result.setTotal(0L);
|
||||||
|
}catch (Exception e){
|
||||||
|
if(updateFlag){
|
||||||
|
log.error("-------- 更新指标异常 : table , column (" + tableName +" , "+indicator.getDynamicColumn()+")");
|
||||||
|
throw new RuntimeException("更新指标异常"+e.getMessage());
|
||||||
|
}else {
|
||||||
|
log.error("-------- 保存指标异常 : table , column (" + tableName +" , "+indicator.getDynamicColumn()+")");
|
||||||
|
throw new RuntimeException("保存指标异常"+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除指标
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "删除指标",notes = "删除指标")
|
||||||
|
@ApiImplicitParam(name = "id",value = "关联应用表名称,Content-Type:application/x-www-form-urlencoded",required = true)
|
||||||
|
@GetMapping("delete_indicator")
|
||||||
|
@Transactional
|
||||||
|
public Result deleteIndicator(Integer id) {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
Indicator indicator = indicatorRepository.lambdaQuery().eq(Indicator::getId,id).one();
|
||||||
|
if(indicator == null){
|
||||||
|
result.setMsg("删除失败");
|
||||||
|
result.setData("无效的指标ID : "+id);
|
||||||
|
setFailure(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
boolean delete_indicator_flag = indicatorRepository.removeById(indicator);
|
||||||
|
if(delete_indicator_flag){
|
||||||
|
//1、根据依赖关系删除标签
|
||||||
|
LambdaQueryChainWrapper<IndicatorLabel> wrapper = indicatorLabelRepository.lambdaQuery().eq(IndicatorLabel::getIndicatorId,id);
|
||||||
|
List<IndicatorLabel> lable_id_list = wrapper.select(IndicatorLabel::getLabelId).list();
|
||||||
|
for (IndicatorLabel indicator_label : lable_id_list) {
|
||||||
|
if(indicatorLabelRepository.lambdaQuery().eq(IndicatorLabel::getLabelId,indicator_label.getLabelId()).list().size() == 1){
|
||||||
|
boolean label_flag = labelRepository.removeById(indicator_label.getLabelId());
|
||||||
|
if(!label_flag){
|
||||||
|
log.error("-------- 删除标签失败,标签 id : "+indicator_label.getLabelId());
|
||||||
|
throw new RuntimeException("删除标签失败,标签 id : "+indicator_label.getLabelId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//2、批量删除中间关系
|
||||||
|
boolean i_l_flag = indicatorLabelRepository.removeBatchByIds(wrapper.select(IndicatorLabel::getId).list());
|
||||||
|
|
||||||
|
if(i_l_flag){
|
||||||
|
//3、删除动态字段
|
||||||
|
if(2 == indicator.getAppDicPId()){
|
||||||
|
dynamicTableService.deleteTable(indicator);
|
||||||
|
result.setCode(CodeMsg.SUCCESS.getCode());
|
||||||
|
result.setMsg("删除成功");
|
||||||
|
result.setData("删除指标成功");
|
||||||
|
result.setTotal(0L);
|
||||||
|
log.info("-------- 删除指标成功 ");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
log.error("-------- 删除多对多映射关系失败");
|
||||||
|
throw new RuntimeException("删除多对多映射关系失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
log.error("-------- 删除指标失败,indicator : "+indicator);
|
||||||
|
throw new RuntimeException("删除指标失败");
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 删除指标失败,indicator id : "+id,e);
|
||||||
|
throw new RuntimeException("-------- 删除指标失败,indicator id : "+id);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询指标列表
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "查询指标列表")
|
||||||
|
@PostMapping("search_indicator")
|
||||||
|
public Result searchIndicator(@RequestBody Search search) {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
Page<IndicatorVo> query = new Page(search.getCurrentPage(), search.getPageSize());
|
||||||
|
Page<IndicatorVo> page = indicatorMapper.getIndicatorPage(query,search.getValue());
|
||||||
|
for (IndicatorVo vo : page.getRecords()) {
|
||||||
|
LambdaQueryChainWrapper<IndicatorLabel> wrapper = indicatorLabelRepository.lambdaQuery().eq(IndicatorLabel::getIndicatorId,vo.getId());
|
||||||
|
List<Integer> list = new ArrayList();
|
||||||
|
for (IndicatorLabel indicatorLabel : wrapper.select(IndicatorLabel::getLabelId).list()) {
|
||||||
|
list.add(indicatorLabel.getLabelId());
|
||||||
|
}
|
||||||
|
List<Label> labelList = labelMapper.selectBatchIds(list);
|
||||||
|
vo.setLableList(labelList);
|
||||||
|
}
|
||||||
|
result.setTotal(page.getTotal());
|
||||||
|
setListSuccess(result,page.getRecords());
|
||||||
|
log.info("-------- 获取关联应用表字段成功 ");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 获取联功能异常,search : "+search,e);
|
||||||
|
setExFailure(result,e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询指标列表
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "查询指标动态表")
|
||||||
|
@GetMapping("search_dynamic_tables")
|
||||||
|
public Result getDynamicTables() {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
List<DynamicTable> list = searchService.getTableInfo();
|
||||||
|
List<Scene> scene_list = sceneRepository.list();
|
||||||
|
List<IndicatorDic> indicator_list = indicatorDicRepository.list();
|
||||||
|
List<AppDic> app_p_list = appDicRepository.lambdaQuery().isNull(AppDic::getParentId).list();
|
||||||
|
|
||||||
|
for (DynamicTable dynamicTable : list) {
|
||||||
|
String scene_id = dynamicTable.getTableNameEn().split("_")[1];
|
||||||
|
String indicator_id = dynamicTable.getTableNameEn().split("_")[2];
|
||||||
|
String app_p_id = dynamicTable.getTableNameEn().split("_")[3];
|
||||||
|
String app_c_id = dynamicTable.getTableNameEn().split("_")[4];
|
||||||
|
StringBuffer tableName = new StringBuffer();
|
||||||
|
for (Scene scene : scene_list) {
|
||||||
|
if(scene_id.equals(scene.getId()+"")){
|
||||||
|
dynamicTable.setSceneName(scene.getSceneName());
|
||||||
|
tableName.append(scene.getSceneName()+"_");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (IndicatorDic indicatorDic : indicator_list) {
|
||||||
|
if(indicator_id.equals(indicatorDic.getId()+"")){
|
||||||
|
tableName.append(indicatorDic.getIndicatorType()+"_");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (AppDic appDic : app_p_list) {
|
||||||
|
if(app_p_id.equals(appDic.getId()+"")){
|
||||||
|
tableName.append(appDic.getAppType()+"_");
|
||||||
|
List<AppDic> app_c_list = appDicRepository.lambdaQuery().eq(AppDic::getParentId,appDic.getId()).list();
|
||||||
|
for (AppDic dic : app_c_list) {
|
||||||
|
if(app_c_id.equals(dic.getId()+"")){
|
||||||
|
tableName.append(dic.getAppType());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamicTable.setTableNameCn(tableName.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
result.setTotal((long) list.size());
|
||||||
|
setListSuccess(result,list);
|
||||||
|
log.info("-------- 查询指标动态表成功 ");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 查询指标动态表异常",e);
|
||||||
|
setExFailure(result,e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.indicator.controller;
|
||||||
|
|
||||||
|
import com.common.info.CodeMsg;
|
||||||
|
import com.common.entity.User;
|
||||||
|
import com.indicator.vo.Login;
|
||||||
|
import com.indicator.info.Result;
|
||||||
|
import com.indicator.repository.UserRepository;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/openapi")
|
||||||
|
@Api(tags = "服务接口")
|
||||||
|
public class OpenApiController {
|
||||||
|
@Resource
|
||||||
|
private UserRepository userRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录表单需要校验字段是否含有 or 1=1
|
||||||
|
* @param info
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "登录",notes = "登录服务")
|
||||||
|
@PostMapping("login")
|
||||||
|
public Result login(@RequestBody Login info) {
|
||||||
|
Result result = new Result();
|
||||||
|
try {
|
||||||
|
User user = userRepository.lambdaQuery().eq(User::getLoginName,info.getUserName()).eq(User::getLoginPassword,info.getPassWord()).one();
|
||||||
|
if(user!=null){
|
||||||
|
result.setCode(CodeMsg.SUCCESS.getCode());
|
||||||
|
result.setMsg(CodeMsg.SUCCESS.getMessage());
|
||||||
|
result.setData("真 * token 串");
|
||||||
|
log.error("-------- 登录成功 ");
|
||||||
|
}else {
|
||||||
|
result.setCode(CodeMsg.AUTH_FAILURE.getCode());
|
||||||
|
result.setMsg(CodeMsg.AUTH_FAILURE.getMessage());
|
||||||
|
log.error("-------- 登录失败,用户名或者密码错误");
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("-------- 登录异常 : "+e.getMessage(),e);
|
||||||
|
result.setCode(CodeMsg.FAILURE.getCode());
|
||||||
|
result.setMsg(e.getMessage());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "测试")
|
||||||
|
@GetMapping("test")
|
||||||
|
public Result test() {
|
||||||
|
Result result = new Result();
|
||||||
|
result.setCode(CodeMsg.SUCCESS.getCode());
|
||||||
|
result.setMsg(CodeMsg.SUCCESS.getMessage());
|
||||||
|
result.setData("真 * test 串");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.indicator.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.common.entity.base.Base;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName(value = "p_indicator")
|
||||||
|
public class Indicator extends Base {
|
||||||
|
@TableField("dynamic_table")
|
||||||
|
@ApiModelProperty(value = "动态表名称(128)",required = true)
|
||||||
|
private String dynamicTable;
|
||||||
|
@TableField("dynamic_column")
|
||||||
|
@ApiModelProperty(value = "动态表字段英文名称(128)")
|
||||||
|
private String dynamicColumn;
|
||||||
|
@TableField("indicator_dic_id")
|
||||||
|
@ApiModelProperty(value = "指标类型(32)")
|
||||||
|
private Integer indicatorDicId;
|
||||||
|
//理论上这个字段应该是字典表
|
||||||
|
@TableField("scene_id")
|
||||||
|
@ApiModelProperty(value = "关联技能(32)")
|
||||||
|
private Integer sceneId;
|
||||||
|
@TableField("app_dic_p_id")
|
||||||
|
@ApiModelProperty(value = "关联应用模块(32)")
|
||||||
|
private Integer appDicPId;
|
||||||
|
@TableField("app_dic_c_id")
|
||||||
|
@ApiModelProperty(value = "关联功能(32)")
|
||||||
|
private Integer appDicCId;
|
||||||
|
@TableField("search_table")
|
||||||
|
@ApiModelProperty(value = "关联表名称(255)")
|
||||||
|
private String searchTable;
|
||||||
|
@TableField("search_column")
|
||||||
|
@ApiModelProperty(value = "关联表字段名称(255)")
|
||||||
|
private String searchColumn;
|
||||||
|
@TableField("indicator_code")
|
||||||
|
@ApiModelProperty(value = "代码值(32)")
|
||||||
|
private String indicatorCode;
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.indicator.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.common.entity.base.Base;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName(value = "p_indicator_label_tmp")
|
||||||
|
public class IndicatorLabel extends Base {
|
||||||
|
@TableField("indicator_id")
|
||||||
|
@ApiModelProperty(value = "指标ID(32)")
|
||||||
|
private Integer indicatorId;
|
||||||
|
@TableField("label_id")
|
||||||
|
@ApiModelProperty(value = "标签ID(32)")
|
||||||
|
private Integer labelId;
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.indicator.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.common.entity.base.Base;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName(value = "p_indicator_label")
|
||||||
|
public class Label extends Base {
|
||||||
|
@TableField("table_name")
|
||||||
|
@ApiModelProperty(value = "表名称(128)",required = true)
|
||||||
|
private String tableName;
|
||||||
|
@TableField("label_name")
|
||||||
|
@ApiModelProperty(value = "标签名称(128)",required = true)
|
||||||
|
private String labelName;
|
||||||
|
@TableField("label_level")
|
||||||
|
@ApiModelProperty(value = "标签等级(32)")
|
||||||
|
private Integer labelLevel;
|
||||||
|
@TableField("parent_id")
|
||||||
|
@ApiModelProperty(value = "父级ID(32)")
|
||||||
|
private Integer parentId;
|
||||||
|
@TableField("column_name")
|
||||||
|
@ApiModelProperty(value = "字段名称(128)")
|
||||||
|
private String columnName;
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.indicator.exception;
|
||||||
|
|
||||||
|
import com.common.info.CodeMsg;
|
||||||
|
import com.indicator.info.Result;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@ControllerAdvice
|
||||||
|
public class GlobalException {
|
||||||
|
@ExceptionHandler(RuntimeException.class)
|
||||||
|
@ResponseBody
|
||||||
|
public Result handlerException(RuntimeException e) {
|
||||||
|
Result result = new Result();
|
||||||
|
result.setCode(CodeMsg.FAILURE.getCode());
|
||||||
|
result.setMsg("参数错误");
|
||||||
|
result.setData(e.getMessage());
|
||||||
|
result.setTotal(0L);
|
||||||
|
log.error("-------- GlobalException Result :"+result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.indicator.filter;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.common.entity.User;
|
||||||
|
import com.common.info.CodeMsg;
|
||||||
|
import com.indicator.info.Result;
|
||||||
|
import com.indicator.repository.UserRepository;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.method.HandlerMethod;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class TokenInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
|
private UserRepository userRepository;
|
||||||
|
private String[] whiteList = {"/openapi/"};
|
||||||
|
|
||||||
|
public TokenInterceptor(UserRepository userRepository){
|
||||||
|
this.userRepository = userRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void errorFilter(HttpServletResponse response){
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
response.setContentType("application/json; charset=utf-8");
|
||||||
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
response.setHeader("Access-Control-Allow-Headers", "*");
|
||||||
|
|
||||||
|
Result result = new Result();
|
||||||
|
result.setCode(CodeMsg.AUTH_FAILURE.getCode());
|
||||||
|
result.setMsg(CodeMsg.AUTH_FAILURE.getMessage());
|
||||||
|
PrintWriter out = null;
|
||||||
|
try {
|
||||||
|
out = response.getWriter();
|
||||||
|
out.write(JSONObject.toJSONString(result));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}finally {
|
||||||
|
if(out != null){
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||||
|
// 如果不是映射到方法直接通过
|
||||||
|
if (!(handler instanceof HandlerMethod)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String url : whiteList) {
|
||||||
|
if(request.getRequestURL().toString().contains(url)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//他们校验的居然不是token串,而是去后台校验一个用户id ???
|
||||||
|
String tmpId = request.getHeader("userId");
|
||||||
|
if(tmpId!=null){
|
||||||
|
Integer userId = Integer.valueOf(tmpId);
|
||||||
|
log.info("获取到用户信息 userId : " + userId);
|
||||||
|
if(userId!=null){
|
||||||
|
User user = userRepository.lambdaQuery().eq(User::getId,userId).one();
|
||||||
|
if(user!=null){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
errorFilter(response);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
errorFilter(response);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
errorFilter(response);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.indicator.info;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Join {
|
||||||
|
@ApiModelProperty(value = "字段内容,前后端可以为空")
|
||||||
|
private String columnValue;
|
||||||
|
@ApiModelProperty(value = "表名称,前端可以为空")
|
||||||
|
private String tableName;
|
||||||
|
@ApiModelProperty(value = "实体表过滤字段列表,前端可以为空")
|
||||||
|
private String[] columnNames;
|
||||||
|
@ApiModelProperty(value = "重命名列表,前端可以为空")
|
||||||
|
private String[] renameDic;
|
||||||
|
@ApiModelProperty(value = "(字典过滤条件)字典字段列表,前端可以为空")
|
||||||
|
private String[] columnDic;
|
||||||
|
@ApiModelProperty(value = "合并键值对集合(表名-关联列名),前端可以为空")
|
||||||
|
private String[] leftJoinDic;
|
||||||
|
@ApiModelProperty(value = "时间过滤字段,默认为create_time,不为空的时候覆盖create_time,前端可以为空")
|
||||||
|
private String timeName;
|
||||||
|
@ApiModelProperty(value = "开始时间,时间格式为 :yyyy-MM-dd HH:mm:ss,前端可以为空")
|
||||||
|
private String startTime;
|
||||||
|
@ApiModelProperty(value = "结束时间,时间格式为 :yyyy-MM-dd HH:mm:ss,前端可以为空")
|
||||||
|
private String endTime;
|
||||||
|
@ApiModelProperty(value = "排序字段,默认为create_time,前端可以为空")
|
||||||
|
private String orderBy;
|
||||||
|
@ApiModelProperty(value = "排序类型,默认为desc,备注(desc:降序 asc:升序),前端可以为空")
|
||||||
|
private String descOrAsc;
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.indicator.info;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Result {
|
||||||
|
@ApiModelProperty(value = "返回码,200表示成功,其它表示失败")
|
||||||
|
private Integer code;
|
||||||
|
@ApiModelProperty(value = "返回成功、失败信息")
|
||||||
|
private String msg;
|
||||||
|
@ApiModelProperty(value = "返回接口对接数据信息")
|
||||||
|
private Object data;
|
||||||
|
@ApiModelProperty(value = "返回总条数")
|
||||||
|
private Long total;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.indicator.info;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Search {
|
||||||
|
@ApiModelProperty(value = "字段内容,前后端可以为空")
|
||||||
|
private String value;
|
||||||
|
@ApiModelProperty(value = "当前页码,(小于等于1) = 1, 页码从1开始,2为第2页",required = true)
|
||||||
|
private Integer currentPage;
|
||||||
|
@ApiModelProperty(value = "每页返回行数(每页展示最大多少行)",required = true)
|
||||||
|
private Integer pageSize;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.indicator.init;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.context.ApplicationContextInitializer;
|
||||||
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class CustomInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||||
|
log.info("-----------1、 Spring Boot 启动前初始化, 暂时不做处理!");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.indicator.init;
|
||||||
|
|
||||||
|
import com.common.info.Parameter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.Connection;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class FinallyInitializer implements ApplicationRunner {
|
||||||
|
@Resource
|
||||||
|
private DataSource dataSource;
|
||||||
|
@Resource
|
||||||
|
private Environment environment;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
log.info("-----------2、 Spring Boot 启动后初始化 -----------");
|
||||||
|
log.info("-----------初始化数据库连接池 jdbc url : "+environment.getProperty("c3p0.jdbcUrl"));
|
||||||
|
Connection conn = null;
|
||||||
|
try {
|
||||||
|
conn = dataSource.getConnection();
|
||||||
|
Parameter.TABLE_SCHEMA = environment.getProperty("parameter.table_schema");
|
||||||
|
log.info("----------- End 数据库连接池 Success -----------");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("初始化 dataSource.getConnection() 异常");
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
if(conn != null) conn.close();
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("初始化 conn.close() 异常");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.indicator.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.common.entity.dic.AppDic;
|
||||||
|
|
||||||
|
public interface AppDicMapper extends BaseMapper<AppDic> {
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.indicator.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.common.entity.dic.IndicatorDic;
|
||||||
|
|
||||||
|
public interface IndicatorDicMapper extends BaseMapper<IndicatorDic> {
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.indicator.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.indicator.entity.IndicatorLabel;
|
||||||
|
|
||||||
|
public interface IndicatorLabelMapper extends BaseMapper<IndicatorLabel> {
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.indicator.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.indicator.entity.Indicator;
|
||||||
|
import com.indicator.vo.IndicatorVo;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
|
||||||
|
public interface IndicatorMapper extends BaseMapper<Indicator> {
|
||||||
|
@Select("select * from (" +
|
||||||
|
"select t.*, dic_0.scene_name scene_cn , dic_1.indicator_type indicator_dic_cn , dic_2.app_type app_dic_p_cn , dic_3.app_type app_dic_c_cn " +
|
||||||
|
"from p_indicator t " +
|
||||||
|
"left join p_scene dic_0 on t.scene_id=dic_0.id " +
|
||||||
|
"left join indicator_dic dic_1 on t.indicator_dic_id=dic_1.id " +
|
||||||
|
"left join app_dic dic_2 on t.app_dic_p_id=dic_2.id " +
|
||||||
|
"left join app_dic dic_3 on t.app_dic_c_id=dic_3.id) join_table " +
|
||||||
|
"where dynamic_column like CONCAT('%', #{value}, '%') " +
|
||||||
|
"or scene_cn like CONCAT('%', #{value}, '%') " +
|
||||||
|
"or indicator_dic_cn like CONCAT('%', #{value}, '%') " +
|
||||||
|
"or app_dic_p_cn like CONCAT('%', #{value}, '%') " +
|
||||||
|
"or app_dic_c_cn like CONCAT('%', #{value}, '%') " +
|
||||||
|
"order by create_time desc"
|
||||||
|
)
|
||||||
|
Page<IndicatorVo> getIndicatorPage(Page<IndicatorVo> page, @Param("value") String value);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.indicator.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.indicator.entity.Label;
|
||||||
|
|
||||||
|
public interface LabelMapper extends BaseMapper<Label> {
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.indicator.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.common.entity.Scene;
|
||||||
|
|
||||||
|
public interface SceneMapper extends BaseMapper<Scene> {
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.indicator.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.common.entity.User;
|
||||||
|
|
||||||
|
public interface UserMapper extends BaseMapper<User> {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.indicator.repository;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.common.entity.dic.AppDic;
|
||||||
|
import com.indicator.mapper.AppDicMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AppDicRepository extends ServiceImpl<AppDicMapper, AppDic> {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.indicator.repository;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.common.entity.dic.IndicatorDic;
|
||||||
|
import com.indicator.mapper.IndicatorDicMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class IndicatorDicRepository extends ServiceImpl<IndicatorDicMapper, IndicatorDic> {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.indicator.repository;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.indicator.entity.IndicatorLabel;
|
||||||
|
import com.indicator.mapper.IndicatorLabelMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class IndicatorLabelRepository extends ServiceImpl<IndicatorLabelMapper, IndicatorLabel> {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.indicator.repository;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.indicator.entity.Indicator;
|
||||||
|
import com.indicator.mapper.IndicatorMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class IndicatorRepository extends ServiceImpl<IndicatorMapper, Indicator> {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.indicator.repository;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.indicator.entity.Label;
|
||||||
|
import com.indicator.mapper.LabelMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class LabelRepository extends ServiceImpl<LabelMapper, Label> {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.indicator.repository;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.common.entity.Scene;
|
||||||
|
import com.indicator.mapper.SceneMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SceneRepository extends ServiceImpl<SceneMapper, Scene> {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.indicator.repository;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.common.entity.User;
|
||||||
|
import com.indicator.mapper.UserMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserRepository extends ServiceImpl<UserMapper, User> {
|
||||||
|
}
|
|
@ -0,0 +1,151 @@
|
||||||
|
package com.indicator.service;
|
||||||
|
|
||||||
|
import com.indicator.entity.Indicator;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class DynamicTableService {
|
||||||
|
@Resource
|
||||||
|
private DataSource dataSource;
|
||||||
|
|
||||||
|
public static String getTableName(Indicator indicator){
|
||||||
|
String tablename = "indicator_"+indicator.getSceneId()
|
||||||
|
+"_"+indicator.getIndicatorDicId()
|
||||||
|
+"_"+indicator.getAppDicPId()
|
||||||
|
+"_"+indicator.getAppDicCId()
|
||||||
|
;
|
||||||
|
return tablename;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void executeSave(Indicator indicator) {
|
||||||
|
Connection conn = null;
|
||||||
|
Statement stm = null;
|
||||||
|
try {
|
||||||
|
String tableName = getTableName(indicator);
|
||||||
|
conn = dataSource.getConnection();
|
||||||
|
stm = conn.createStatement();
|
||||||
|
log.info("---------- 创建表 table name :"+tableName);
|
||||||
|
String create_sql = "create table if not exists "+tableName+" (id int4 generated always as identity primary key,"+indicator.getDynamicColumn()+" varchar(255))";
|
||||||
|
log.info("---------- 创建表 sql:"+create_sql);
|
||||||
|
String add_sql = "alter table "+tableName+" add column if not exists "+indicator.getDynamicColumn()+" varchar(255)";
|
||||||
|
log.info("---------- 添加字段 sql:"+add_sql);
|
||||||
|
// String comment_id_sql = "comment on column "+tableName+".id is 'ID序号'";
|
||||||
|
// String comment_column_sql = "comment on column "+tableName+"."+indicator.getDynamicColumn()+" is '"+indicator.getDynamicColumnCh()+"'";
|
||||||
|
// log.info("---------- 添加ID备注 sql:"+comment_id_sql);
|
||||||
|
// log.info("---------- 添加column备注 sql:"+comment_column_sql);
|
||||||
|
|
||||||
|
stm.executeUpdate(create_sql);
|
||||||
|
stm.executeUpdate(add_sql);
|
||||||
|
// stm.executeUpdate(comment_id_sql);
|
||||||
|
// stm.executeUpdate(comment_column_sql);
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new RuntimeException("执行sql失败",e);
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
if(stm != null) stm.close();
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new RuntimeException("stm.close() 异常!");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if(conn != null) conn.close();
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new RuntimeException("conn.close() 异常!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void executeUpdate0(Indicator indicator,Indicator oldIndicator) throws Exception{
|
||||||
|
deleteTable(oldIndicator);
|
||||||
|
executeSave(indicator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void executeUpdate1(Indicator indicator,Indicator oldIndicator) {
|
||||||
|
Connection conn = null;
|
||||||
|
Statement stm = null;
|
||||||
|
try {
|
||||||
|
String tableName = getTableName(indicator);
|
||||||
|
conn = dataSource.getConnection();
|
||||||
|
stm = conn.createStatement();
|
||||||
|
log.info("---------- 更新字段表名称 table name :"+tableName);
|
||||||
|
String alter_sql = "alter table "+tableName+" rename "+oldIndicator.getDynamicColumn()+" to "+indicator.getDynamicColumn();
|
||||||
|
log.info("---------- 更新字段名称 sql:"+alter_sql);
|
||||||
|
stm.executeUpdate(alter_sql);
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new RuntimeException("执行sql失败",e);
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
if(stm != null) stm.close();
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new RuntimeException("stm.close() 异常!");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if(conn != null) conn.close();
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new RuntimeException("conn.close() 异常!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteTable(Indicator indicator) {
|
||||||
|
Connection conn = null;
|
||||||
|
Statement stm = null;
|
||||||
|
String tableName = null;
|
||||||
|
try {
|
||||||
|
Set<String> set = new LinkedHashSet();
|
||||||
|
List<String> columnList = new ArrayList();
|
||||||
|
tableName = getTableName(indicator);
|
||||||
|
conn = dataSource.getConnection();
|
||||||
|
stm = conn.createStatement();
|
||||||
|
|
||||||
|
DatabaseMetaData metaData = conn.getMetaData();
|
||||||
|
ResultSet resultSet = metaData.getColumns(null,null,tableName,null);
|
||||||
|
while (resultSet.next()) {
|
||||||
|
set.add(resultSet.getString("COLUMN_NAME"));
|
||||||
|
}
|
||||||
|
for (String column : set) {
|
||||||
|
columnList.add(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
String alter_sql = "alter table "+tableName+" drop column if exists "+indicator.getDynamicColumn();
|
||||||
|
String drop_sql = "drop table if exists "+tableName;
|
||||||
|
|
||||||
|
if(columnList.size()>2){
|
||||||
|
log.info("---------- 删除表字段 sql:"+alter_sql);
|
||||||
|
stm.executeUpdate(alter_sql);
|
||||||
|
}else {
|
||||||
|
log.info("---------- 删除表 sql:"+drop_sql);
|
||||||
|
stm.executeUpdate(drop_sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new RuntimeException("删除动态表失败,table name : "+tableName,e);
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
if(stm != null) stm.close();
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new RuntimeException("stm.close() 异常!");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if(conn != null) conn.close();
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new RuntimeException("conn.close() 异常!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,180 @@
|
||||||
|
package com.indicator.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONException;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.indicator.entity.Label;
|
||||||
|
import com.indicator.repository.LabelRepository;
|
||||||
|
import com.indicator.tool.TreeTool;
|
||||||
|
import com.indicator.vo.DynamicTable;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class SearchService {
|
||||||
|
@Resource
|
||||||
|
private DataSource dataSource;
|
||||||
|
@Resource
|
||||||
|
private LabelRepository labelRepository;
|
||||||
|
|
||||||
|
|
||||||
|
public List<String> getTableNames() throws Exception{
|
||||||
|
Connection conn = null;
|
||||||
|
ResultSet result = null;
|
||||||
|
try {
|
||||||
|
conn = dataSource.getConnection();
|
||||||
|
DatabaseMetaData metaData = conn.getMetaData();
|
||||||
|
Set<String> set = new LinkedHashSet();
|
||||||
|
result = metaData.getTables(null, null, null, new String[]{"TABLE"});
|
||||||
|
while (result.next()) {
|
||||||
|
set.add(result.getString("table_name"));
|
||||||
|
}
|
||||||
|
List<String> list = new ArrayList();
|
||||||
|
for (String column : set) {
|
||||||
|
list.add(column);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new Exception("获取数据库列表失败!",e);
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
if(result != null) result.close();
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new Exception("获取数据库列表失败,result.close() 异常!");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if(conn != null) conn.close();
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new Exception("获取数据库列表失败,conn.close() 异常!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getColumns(String tableName) throws Exception{
|
||||||
|
Connection conn = null;
|
||||||
|
ResultSet result = null;
|
||||||
|
try {
|
||||||
|
Set<String> set = new LinkedHashSet();
|
||||||
|
conn = dataSource.getConnection();
|
||||||
|
DatabaseMetaData metaData = conn.getMetaData();
|
||||||
|
result = metaData.getColumns(null,null,tableName,null);
|
||||||
|
while (result.next()) {
|
||||||
|
//COLUMN_NAME:column name and size TYPE_NAME:data type name
|
||||||
|
set.add(result.getString("column_name"));
|
||||||
|
}
|
||||||
|
List<String> list = new ArrayList();
|
||||||
|
for (String column : set) {
|
||||||
|
list.add(column);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new Exception("获取数据库列表失败!",e);
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
if(result != null) result.close();
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new Exception("获取数据库列表失败,result.close() 异常!");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if(conn != null) conn.close();
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new Exception("获取数据库列表失败,conn.close() 异常!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DynamicTable> getTableInfo() throws Exception{
|
||||||
|
List<String> allTableNames = getTableNames();
|
||||||
|
List<String> tableNames = new ArrayList();
|
||||||
|
for (String tableName : allTableNames) {
|
||||||
|
if(tableName.startsWith("indicator_") && !tableName.endsWith("_dic")){
|
||||||
|
tableNames.add(tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<DynamicTable> list = new ArrayList();
|
||||||
|
Connection conn = null;
|
||||||
|
try {
|
||||||
|
conn = dataSource.getConnection();
|
||||||
|
|
||||||
|
for (String tableName : tableNames) {
|
||||||
|
DynamicTable dynamicTable = new DynamicTable();
|
||||||
|
|
||||||
|
JSONArray columnArray = TreeTool.listToTree(JSONArray
|
||||||
|
.parseArray(JSON.toJSONString(labelRepository.lambdaQuery()
|
||||||
|
.eq(Label::getTableName,tableName).list())),"id","parentId","children");
|
||||||
|
List<JSONObject> lableList = TreeTool.processArray(columnArray,new ArrayList());
|
||||||
|
|
||||||
|
|
||||||
|
StringBuffer columns = new StringBuffer();
|
||||||
|
List<String> columnList = new ArrayList();
|
||||||
|
for (JSONObject jsonObject : lableList) {
|
||||||
|
columnList.add(jsonObject.get("columnName").toString());
|
||||||
|
}
|
||||||
|
for (int i = 0; i < columnList.size(); i++) {
|
||||||
|
if(i == columnList.size()-1){
|
||||||
|
columns.append(columnList.get(i)+" from ");
|
||||||
|
}else {
|
||||||
|
columns.append(columnList.get(i)+",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String sql = "select "+columns+tableName;
|
||||||
|
log.info("---- sql : "+sql);
|
||||||
|
|
||||||
|
List<List<String>> lists = new ArrayList();
|
||||||
|
PreparedStatement stm = conn.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
||||||
|
stm.setFetchSize(10000);
|
||||||
|
stm.setFetchDirection(ResultSet.FETCH_FORWARD);
|
||||||
|
ResultSet rs = stm.executeQuery();
|
||||||
|
while (rs.next()) {
|
||||||
|
List<String> values = new ArrayList();
|
||||||
|
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
|
||||||
|
String dataStr = rs.getString(i);
|
||||||
|
if(dataStr == null){
|
||||||
|
values.add("");
|
||||||
|
}else{
|
||||||
|
String tmpData = (dataStr+"").trim().replace("\n","\\n").replace("\t","\\t");
|
||||||
|
if("null".equals(tmpData)) {
|
||||||
|
values.add("");
|
||||||
|
}else{
|
||||||
|
values.add(tmpData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lists.add(values);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
stm.close();
|
||||||
|
|
||||||
|
dynamicTable.setTableNameEn(tableName);
|
||||||
|
dynamicTable.setLabelArray(columnArray);
|
||||||
|
dynamicTable.setColumnList(columnList);
|
||||||
|
dynamicTable.setValueList(lists);
|
||||||
|
list.add(dynamicTable);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new Exception("获取动态表信息失败!",e);
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
if(conn != null) conn.close();
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new Exception("获取动态表信息失败,conn.close() 异常!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.indicator.tool;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONException;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TreeTool {
|
||||||
|
|
||||||
|
public static List<JSONObject> processArray(JSONArray array, List<JSONObject> list) throws JSONException {
|
||||||
|
for (int i = 0; i < array.size(); i++) {
|
||||||
|
JSONObject jsonObject = array.getJSONObject(i);
|
||||||
|
|
||||||
|
if (jsonObject.get("children") != null) {
|
||||||
|
JSONArray childrenArray = jsonObject.getJSONArray("children");
|
||||||
|
processArray(childrenArray,list);
|
||||||
|
}else {
|
||||||
|
list.add(jsonObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JSONArray listToTree(JSONArray arr,String id,String pid,String child){
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
JSONObject hash = new JSONObject();
|
||||||
|
//将数组转为Object的形式,key为数组中的id
|
||||||
|
for(int i=0;i<arr.size();i++){
|
||||||
|
JSONObject json = (JSONObject) arr.get(i);
|
||||||
|
hash.put(json.getString(id), json);
|
||||||
|
}
|
||||||
|
//遍历结果集
|
||||||
|
for(int j=0;j<arr.size();j++){
|
||||||
|
//单条记录
|
||||||
|
JSONObject val = (JSONObject) arr.get(j);
|
||||||
|
//在hash中取出key为单条记录中pid的值
|
||||||
|
JSONObject obj = (JSONObject) hash.get(val.get(pid));
|
||||||
|
//若是记录的pid存在,则说明它有父节点,将她添加到孩子节点的集合中
|
||||||
|
if(obj!=null){
|
||||||
|
//检查是否有child属性
|
||||||
|
if(obj.get(child)!=null){
|
||||||
|
JSONArray ch = (JSONArray) obj.get(child);
|
||||||
|
ch.add(val);
|
||||||
|
obj.put(child, ch);
|
||||||
|
}else{
|
||||||
|
JSONArray ch = new JSONArray();
|
||||||
|
ch.add(val);
|
||||||
|
obj.put(child, ch);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
array.add(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.indicator.vo;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DynamicTable {
|
||||||
|
private String tableNameEn;
|
||||||
|
private String tableNameCn;
|
||||||
|
private String sceneName;
|
||||||
|
private JSONArray labelArray;
|
||||||
|
private List<String> columnList;
|
||||||
|
private List<List<String>> valueList;
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.indicator.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.indicator.entity.Indicator;
|
||||||
|
import com.indicator.entity.Label;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class IndicatorVo extends Indicator {
|
||||||
|
@TableField(exist=false)
|
||||||
|
@ApiModelProperty(value = "关联技能中文名称")
|
||||||
|
private String sceneCn;
|
||||||
|
@TableField(exist=false)
|
||||||
|
@ApiModelProperty(value = "指标类型中文名称")
|
||||||
|
private String indicatorDicCn;
|
||||||
|
@TableField(exist=false)
|
||||||
|
@ApiModelProperty(value = "关联应用模块中文")
|
||||||
|
private String appDicPCn;
|
||||||
|
@TableField(exist=false)
|
||||||
|
@ApiModelProperty(value = "关联功能中文")
|
||||||
|
private String appDicCCn;
|
||||||
|
@TableField(exist=false)
|
||||||
|
@ApiModelProperty(value = "标签名称(128)",required = true)
|
||||||
|
private List<Label> lableList;
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.indicator.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Login {
|
||||||
|
@NotBlank(message = "用户不能为空")
|
||||||
|
private String userName;//操作人名称
|
||||||
|
@NotBlank(message = "密码不能为空")
|
||||||
|
private String passWord;//操作人密码
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
server:
|
||||||
|
port: 8601
|
||||||
|
# ssl:
|
||||||
|
# key-store: classpath:Serverkeystore.p12
|
||||||
|
# key-store-type: PKCS12
|
||||||
|
# key-store-password: 123456
|
||||||
|
# key-alias: serverKey
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: szr-indicator-service
|
||||||
|
mvc:
|
||||||
|
pathmatch:
|
||||||
|
matching-strategy: ant_path_matcher
|
||||||
|
# cloud:
|
||||||
|
# nacos:
|
||||||
|
# discovery:
|
||||||
|
# server-addr: 47.92.242.82:8848
|
||||||
|
# namespace: c9447fc7-e026-4c7f-9fbf-6d3b04a4da05
|
||||||
|
# group: DEFAULT_GROUP
|
||||||
|
# config:
|
||||||
|
# server-addr: 47.92.242.82:8848
|
||||||
|
# namespace: c9447fc7-e026-4c7f-9fbf-6d3b04a4da05
|
||||||
|
# group: DEFAULT_GROUP
|
||||||
|
# prefix: ${spring.application.name}
|
||||||
|
# file-extension: yaml
|
||||||
|
# refresh-enabled: true
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
server-addr: localhost:8848
|
||||||
|
namespace: test
|
||||||
|
group: DEFAULT_GROUP
|
||||||
|
config:
|
||||||
|
server-addr: localhost:8848
|
||||||
|
namespace: test
|
||||||
|
group: DEFAULT_GROUP
|
||||||
|
prefix: ${spring.application.name}
|
||||||
|
file-extension: yaml
|
||||||
|
refresh-enabled: true
|
||||||
|
|
||||||
|
feign:
|
||||||
|
client:
|
||||||
|
config:
|
||||||
|
feign-provider:
|
||||||
|
loggerLevel: full
|
||||||
|
default:
|
||||||
|
connect-timeout: 10000
|
||||||
|
read-timeout: 10000
|
||||||
|
|
||||||
|
custom-initializer: com.indicator.init.CustomInitializer
|
||||||
|
|
||||||
|
mybatis-plus:
|
||||||
|
configuration:
|
||||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|
||||||
|
c3p0:
|
||||||
|
# jdbcUrl: jdbc:mysql://82.157.153.250:3306/hp_db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
|
||||||
|
# driverClass: com.mysql.cj.jdbc.Driver
|
||||||
|
# user: hp
|
||||||
|
# password: Hp1949..
|
||||||
|
jdbcUrl: jdbc:postgresql://localhost:5432/postgres
|
||||||
|
driverClass: org.postgresql.Driver
|
||||||
|
user: postgres
|
||||||
|
password: postgres
|
||||||
|
minPoolSize: 2
|
||||||
|
maxPoolSize: 10
|
||||||
|
maxIdleTime: 6000
|
||||||
|
breakAfterAcquireFailure: false
|
||||||
|
testConnectionOnCheckout: false
|
||||||
|
idleConnectionTestPeriod: 60
|
||||||
|
|
||||||
|
# https://localhost:8601/doc.html
|
||||||
|
knife4j:
|
||||||
|
enable: true
|
||||||
|
basic:
|
||||||
|
enable: true
|
||||||
|
username: admin
|
||||||
|
password: admin@123
|
||||||
|
|
||||||
|
parameter:
|
||||||
|
table_schema: public
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<property name="log_dir" value="/szr/logs/zbsz" />
|
||||||
|
<property name="maxHistory" value="30"/>
|
||||||
|
<property name="logPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5level %logger %line -%msg%n"/>
|
||||||
|
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${logPattern}</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="info" class="ch.qos.logback.core.rolling.RollingFileAppender" >
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/info.log</fileNamePattern>
|
||||||
|
<maxHistory>${maxHistory}</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${logPattern}</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>ERROR</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/error.log</fileNamePattern>
|
||||||
|
<maxHistory>${maxHistory}</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${logPattern}</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="stdout"/>
|
||||||
|
<appender-ref ref="info" />
|
||||||
|
<appender-ref ref="error"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.indicator;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONException;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.indicator.entity.Indicator;
|
||||||
|
import com.indicator.entity.Label;
|
||||||
|
import com.indicator.mapper.IndicatorMapper;
|
||||||
|
import com.indicator.repository.IndicatorRepository;
|
||||||
|
import com.indicator.repository.LabelRepository;
|
||||||
|
import com.indicator.service.SearchService;
|
||||||
|
import com.indicator.tool.TreeTool;
|
||||||
|
import com.indicator.vo.IndicatorVo;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
@Slf4j
|
||||||
|
public class IndicatorTest {
|
||||||
|
@Resource
|
||||||
|
private IndicatorRepository indicatorRepository;
|
||||||
|
@Resource
|
||||||
|
private SearchService searchService;
|
||||||
|
@Resource
|
||||||
|
private IndicatorMapper indicatorMapper;
|
||||||
|
@Resource
|
||||||
|
private LabelRepository labelRepository;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLabel(){
|
||||||
|
List<Label> list = labelRepository.list();
|
||||||
|
JSONArray array = JSONArray.parseArray(JSON.toJSONString(list));
|
||||||
|
|
||||||
|
JSONArray tmpArray = TreeTool.listToTree(array,"id","parentId","children");
|
||||||
|
System.out.println(JSON.toJSONString(tmpArray));
|
||||||
|
System.out.println("----------------------");
|
||||||
|
System.out.println(TreeTool.processArray(tmpArray,new ArrayList()));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testgetIndicatorById(){
|
||||||
|
System.out.println(indicatorRepository.getById(75));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIndicatorPage(){
|
||||||
|
Page<IndicatorVo> query = new Page(1, 2);
|
||||||
|
Page<IndicatorVo> page = indicatorMapper.getIndicatorPage(query,"");
|
||||||
|
System.out.println("-------- : "+page.getPages());
|
||||||
|
System.out.println("-------- : "+page.getTotal());
|
||||||
|
System.out.println("-------- : "+page.hasNext());
|
||||||
|
System.out.println("-------- : "+page.hasPrevious());
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testPage(){
|
||||||
|
Page<Indicator> page = new Page(1, 2);
|
||||||
|
indicatorRepository.page(page);
|
||||||
|
List<Indicator> list = page.getRecords();
|
||||||
|
System.out.println("-------- : "+list);
|
||||||
|
System.out.println("-------- : "+page.getPages());
|
||||||
|
System.out.println("-------- : "+page.getTotal());
|
||||||
|
System.out.println("-------- : "+page.hasNext());
|
||||||
|
System.out.println("-------- : "+page.hasPrevious());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchTable() throws Exception{
|
||||||
|
System.out.println(searchService.getTableNames());
|
||||||
|
System.out.println(searchService.getColumns("p_indicator"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.indicator;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONException;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class TmpTest {
|
||||||
|
|
||||||
|
private String getStr(){
|
||||||
|
if(true) throw new RuntimeException("测试");
|
||||||
|
return "123";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test03(){
|
||||||
|
System.out.println("xxx"+getStr());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test02(){
|
||||||
|
Map<String,String> map1 = new LinkedHashMap<>();
|
||||||
|
map1.put("1","a");
|
||||||
|
Map<String,String> map2 = new LinkedHashMap<>();
|
||||||
|
map2.put("1","a");
|
||||||
|
Map<String,String> map3 = new LinkedHashMap<>();
|
||||||
|
map3.put("2","b");
|
||||||
|
System.out.println(map1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 要知道这个答案,就涉及到Java缓冲区和堆的问题。
|
||||||
|
* java中Integer类型对于-128-127之间的数是缓冲区取的,所以用等号比较是一致的。但对于不在这区间的数字是在堆中new出来的。所以地址空间不一样,也就不相等。
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void test01(){
|
||||||
|
Integer a1 = Integer.valueOf(60); //danielinbiti
|
||||||
|
Integer b1 = 60;
|
||||||
|
System.out.println("1:="+(a1 == b1));
|
||||||
|
|
||||||
|
|
||||||
|
Integer a2 = 60;
|
||||||
|
Integer b2 = 60;
|
||||||
|
System.out.println("2:="+(a2 == b2));
|
||||||
|
|
||||||
|
|
||||||
|
Integer a3 = new Integer(60);
|
||||||
|
Integer b3 = 60;
|
||||||
|
System.out.println("3:="+(a3 == b3));
|
||||||
|
|
||||||
|
Integer a4 = 129;
|
||||||
|
Integer b4 = 129;
|
||||||
|
System.out.println("4:="+(a4 == b4));
|
||||||
|
System.out.println(a4.equals(b4));
|
||||||
|
System.out.println(a4==129);
|
||||||
|
|
||||||
|
System.out.println(129 == 129);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
cd f:\soft\nacos\nacos
|
||||||
|
f:
|
||||||
|
call bin\startup.cmd -m standalone
|
||||||
|
|
|
@ -0,0 +1,145 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.szr</groupId>
|
||||||
|
<artifactId>center</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>common</module>
|
||||||
|
<module>indicator</module>
|
||||||
|
<module>test</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven-compiler-plugin.version>3.6.2</maven-compiler-plugin.version>
|
||||||
|
<maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
|
||||||
|
<jdk.version>11</jdk.version>
|
||||||
|
|
||||||
|
<!-- common包 -->
|
||||||
|
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||||
|
<lombok.version>1.18.22</lombok.version>
|
||||||
|
<fastjson2.version>2.0.10</fastjson2.version>
|
||||||
|
<junit.version>4.13.2</junit.version>
|
||||||
|
|
||||||
|
<!-- spring-boot 2.3.12.RELEASE-->
|
||||||
|
<springboot.version>2.7.12</springboot.version>
|
||||||
|
<spring.cloud.version>2021.0.7</spring.cloud.version>
|
||||||
|
<cxf.version>3.2.6</cxf.version>
|
||||||
|
<jackson.version>2.13.2</jackson.version>
|
||||||
|
<knife4j.version>4.1.0</knife4j.version>
|
||||||
|
<swagger.ui.version>2.10.5</swagger.ui.version>
|
||||||
|
<spring.cloud.version>2021.0.8</spring.cloud.version>
|
||||||
|
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
|
||||||
|
<spring.plugin.version>2.7.17</spring.plugin.version>
|
||||||
|
<!-- jdbc -->
|
||||||
|
<mybatis.plus.version>3.5.5</mybatis.plus.version>
|
||||||
|
<c3p0.version>0.9.5.5</c3p0.version>
|
||||||
|
<mysql.version>8.0.28</mysql.version>
|
||||||
|
<postgresql.version>42.3.8</postgresql.version>
|
||||||
|
<!--project -->
|
||||||
|
<project.version>1.0</project.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<!--基础 包 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.szr</groupId>
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--data 包 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 测试 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>${junit.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<!--模块依赖包 -->
|
||||||
|
<dependency>
|
||||||
|
<!-- Import dependency management from Spring Boot -->
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${springboot.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
<!--cloud-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring.cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- alibaba -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud-alibaba.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<source>${jdk.version}</source>
|
||||||
|
<target>${jdk.version}</target>
|
||||||
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${spring.plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<!--开启过滤,用指定的参数替换directory下的文件中的参数-->
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>central</id>
|
||||||
|
<url>https://maven.aliyun.com/repository/central</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>public</id>
|
||||||
|
<url>https://maven.aliyun.com/repository/public</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,63 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.szr</groupId>
|
||||||
|
<artifactId>center</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>test</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>${swagger.ui.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
|
||||||
|
<version>${knife4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-loadbalancer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
<artifactId>fastjson2</artifactId>
|
||||||
|
<version>${fastjson2.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.test;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
|
@EnableFeignClients
|
||||||
|
@EnableDiscoveryClient
|
||||||
|
@SpringBootApplication
|
||||||
|
public class TestRun {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(TestRun.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.test.other;
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@FeignClient(value = "szr-indicator-service",configuration = FeignConfiguration.class)
|
||||||
|
public interface ClientController {
|
||||||
|
@ApiOperation(value = "查询指标动态表")
|
||||||
|
@GetMapping("/indicator/search_indicator_tables")
|
||||||
|
// @GetMapping("/openapi/test")
|
||||||
|
public String getIndicatorTables();
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.test.other;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
import feign.RequestInterceptor;
|
||||||
|
import feign.RequestTemplate;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class FeignConfiguration implements RequestInterceptor {
|
||||||
|
@Override
|
||||||
|
public void apply(RequestTemplate template) {
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
if (attributes == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
Enumeration<String> headerNames = request.getHeaderNames();
|
||||||
|
if (headerNames != null) {
|
||||||
|
while (headerNames.hasMoreElements()) {
|
||||||
|
String name = headerNames.nextElement();
|
||||||
|
//新请求会导致长度改变,过滤
|
||||||
|
if ("content-length".equalsIgnoreCase(name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//防止传递格式修改,过滤
|
||||||
|
if ("accept-encoding".equalsIgnoreCase(name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String value = request.getHeader(name);
|
||||||
|
template.header(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.test.other;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Result {
|
||||||
|
@ApiModelProperty(value = "返回码,200表示成功,其它表示失败")
|
||||||
|
private Integer code;
|
||||||
|
@ApiModelProperty(value = "返回成功、失败信息")
|
||||||
|
private String msg;
|
||||||
|
@ApiModelProperty(value = "返回接口对接数据信息")
|
||||||
|
private Object data;
|
||||||
|
@ApiModelProperty(value = "返回总条数")
|
||||||
|
private Long total;
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.test.other;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* http://localhost:8601/doc.html
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@Import(BeanValidatorPluginsConfiguration.class)
|
||||||
|
@EnableSwagger2WebMvc
|
||||||
|
public class Swagger2Config implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Docket createRestApi() {
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.apiInfo(new ApiInfoBuilder()
|
||||||
|
.title("指标设置 API")
|
||||||
|
.description("test")
|
||||||
|
.version("V-1.0")
|
||||||
|
.build())
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("com.test.run"))
|
||||||
|
// .paths(PathSelectors.regex("TestRun"))
|
||||||
|
.paths(PathSelectors.any())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.test.run;
|
||||||
|
|
||||||
|
import com.test.other.ClientController;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/test")
|
||||||
|
public class TestController {
|
||||||
|
@Resource
|
||||||
|
private ClientController client;
|
||||||
|
|
||||||
|
@ApiOperation(value = "查询指标动态表")
|
||||||
|
@GetMapping("/getTables")
|
||||||
|
public String getIndicatorTables() {
|
||||||
|
log.info("---"+client.getIndicatorTables());
|
||||||
|
// System.out.println("xxx");
|
||||||
|
return client.getIndicatorTables().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
server:
|
||||||
|
port: 8602
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: test-service
|
||||||
|
mvc:
|
||||||
|
pathmatch:
|
||||||
|
matching-strategy: ant_path_matcher
|
||||||
|
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
server-addr: localhost:8848
|
||||||
|
namespace: test
|
||||||
|
group: DEFAULT_GROUP
|
Loading…
Reference in New Issue