编写工单内容 70%
This commit is contained in:
parent
62b3b1f435
commit
12d2403f4e
|
@ -15,11 +15,28 @@
|
|||
|
||||
<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>
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package com.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName(value = "dic_target")
|
||||
public class DicTarget extends Base{
|
||||
@TableField("type")
|
||||
@ApiModelProperty(value = "指标类型")
|
||||
private String type;
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
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")
|
||||
@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;
|
||||
}
|
|
@ -3,8 +3,10 @@ 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;
|
||||
|
@ -50,9 +52,13 @@ public class User {
|
|||
@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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.common.entity;
|
||||
package com.common.entity.base;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
@ -16,6 +16,7 @@ public class Base {
|
|||
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;
|
|
@ -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 String parentId;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
--generated always 默认从0开始
|
||||
drop table if exists indicator_dic;
|
||||
create table indicator_dic (
|
||||
id int4 not null generated always as identity( minvalue 0 no maxvalue start 0 no cycle),
|
||||
indicator_type varchar(255) 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) values ('基础指标',current_timestamp);
|
||||
insert into indicator_dic(indicator_type, create_time) values ('逻辑指标',current_timestamp);
|
||||
insert into indicator_dic(indicator_type, create_time) values ('统计指标',current_timestamp);
|
14
zbsz/pom.xml
14
zbsz/pom.xml
|
@ -20,20 +20,6 @@
|
|||
<artifactId>common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 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>
|
||||
<!-- jdbc 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.mchange</groupId>
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package com.zbsz;
|
||||
|
||||
import com.zbsz.init.CustomInitializer;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.zbsz.mapper")
|
||||
public class Run {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication application = new SpringApplication(Run.class);
|
||||
application.addInitializers(new CustomInitializer());
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.zbsz.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.zbsz.mapper")
|
||||
public class PageConfig {
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL));
|
||||
return interceptor;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.zbsz.config;
|
||||
|
||||
import com.zbsz.filter.JwtInterceptor;
|
||||
import com.zbsz.filter.TokenInterceptor;
|
||||
import com.zbsz.service.UserService;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
@ -14,6 +15,8 @@ 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
|
||||
|
@ -22,6 +25,8 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
|||
@Import(BeanValidatorPluginsConfiguration.class)
|
||||
@EnableSwagger2WebMvc
|
||||
public class Swagger2Config implements WebMvcConfigurer {
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
|
@ -41,7 +46,7 @@ public class Swagger2Config implements WebMvcConfigurer {
|
|||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
//添加拦截器
|
||||
registry.addInterceptor(new JwtInterceptor())
|
||||
registry.addInterceptor(new TokenInterceptor(userService))
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns("/doc.html")
|
||||
.excludePathPatterns("/swagger-resources/**")
|
||||
|
@ -54,10 +59,4 @@ public class Swagger2Config implements WebMvcConfigurer {
|
|||
.excludePathPatterns("/openapi/*");//白名单
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JwtInterceptor authenticationInterceptor() {
|
||||
return new JwtInterceptor();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
package com.zbsz.controller;
|
||||
|
||||
import com.common.entity.Scene;
|
||||
import com.common.entity.dic.IndicatorDic;
|
||||
import com.common.entity.dic.AppDic;
|
||||
import com.common.info.CodeMsg;
|
||||
import com.zbsz.info.Result;
|
||||
import com.zbsz.service.IndicatorDicService;
|
||||
import com.zbsz.service.AppDicService;
|
||||
import com.zbsz.service.SceneService;
|
||||
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;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/indicator")
|
||||
@Api(tags = "服务接口")
|
||||
public class IndicatorController {
|
||||
@Resource
|
||||
private SceneService sceneService;
|
||||
@Resource
|
||||
private IndicatorDicService indicatorDicService;
|
||||
@Resource
|
||||
private AppDicService appDicService;
|
||||
|
||||
/**
|
||||
* 关联场景查询
|
||||
* @return Result
|
||||
*/
|
||||
@ApiOperation(value = "获取关联场景",notes = "获取关联场景列表信息")
|
||||
@GetMapping("get_scenes")
|
||||
public Result getScenes(@RequestHeader(value = "userId",required = true)String token) {
|
||||
Result result = new Result();
|
||||
try {
|
||||
List<Scene> list = sceneService.list();
|
||||
result.setCode(CodeMsg.SUCCESS.getCode());
|
||||
result.setMsg(CodeMsg.SUCCESS.getMessage());
|
||||
result.setData(list);
|
||||
if(list!=null){
|
||||
result.setTotal((long) list.size());
|
||||
}else {
|
||||
result.setTotal(0L);
|
||||
}
|
||||
log.error("-------- 获取关联场景成功 ");
|
||||
}catch (Exception e){
|
||||
log.error("-------- 获取关联场景异常 : "+e.getMessage(),e);
|
||||
result.setCode(CodeMsg.FAILURE.getCode());
|
||||
result.setMsg(e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标类型查询
|
||||
* @return Result
|
||||
*/
|
||||
@ApiOperation(value = "获取指标类型",notes = "获取指标类型列表信息")
|
||||
@GetMapping("get_indicator_dic")
|
||||
public Result getIndicatorDic(@RequestHeader(value = "userId",required = true)String token) {
|
||||
Result result = new Result();
|
||||
try {
|
||||
List<IndicatorDic> list = indicatorDicService.list();
|
||||
result.setCode(CodeMsg.SUCCESS.getCode());
|
||||
result.setMsg(CodeMsg.SUCCESS.getMessage());
|
||||
result.setData(list);
|
||||
if(list!=null){
|
||||
result.setTotal((long) list.size());
|
||||
}else {
|
||||
result.setTotal(0L);
|
||||
}
|
||||
log.error("-------- 获取指标类型成功 ");
|
||||
}catch (Exception e){
|
||||
log.error("-------- 获取指标类型异常 : "+e.getMessage(),e);
|
||||
result.setCode(CodeMsg.FAILURE.getCode());
|
||||
result.setMsg(e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联应用模块类型查询
|
||||
* @return Result
|
||||
*/
|
||||
@ApiOperation(value = "获取关联应用模块类型",notes = "获取关联应用模块类型列表信息")
|
||||
@GetMapping("get_app_dic")
|
||||
public Result getModuleDic(@RequestHeader(value = "userId",required = true)String token) {
|
||||
Result result = new Result();
|
||||
try {
|
||||
List<AppDic> list = appDicService.list();
|
||||
result.setCode(CodeMsg.SUCCESS.getCode());
|
||||
result.setMsg(CodeMsg.SUCCESS.getMessage());
|
||||
result.setData(list);
|
||||
if(list!=null){
|
||||
result.setTotal((long) list.size());
|
||||
}else {
|
||||
result.setTotal(0L);
|
||||
}
|
||||
log.error("-------- 获取关联应用模块成功 ");
|
||||
}catch (Exception e){
|
||||
log.error("-------- 获取关联应用模块异常 : "+e.getMessage(),e);
|
||||
result.setCode(CodeMsg.FAILURE.getCode());
|
||||
result.setMsg(e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.zbsz.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("indicator_id")
|
||||
@ApiModelProperty(value = "指标编号")
|
||||
private String indicatorId;
|
||||
@TableField("indicator_name")
|
||||
@ApiModelProperty(value = "指标名称")
|
||||
private String indicatorName;
|
||||
@TableField("indicator_dic_id")
|
||||
@ApiModelProperty(value = "指标类型")
|
||||
private Integer indicatorDicId;
|
||||
|
||||
//理论上这个字段应该是字典表
|
||||
@TableField("scene_id")
|
||||
@ApiModelProperty(value = "场景类型")
|
||||
private Integer sceneId;
|
||||
@TableField("app_dic_id")
|
||||
@ApiModelProperty(value = "应用类型")
|
||||
private Integer appDicId;
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package com.zbsz.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.common.entity.Base;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName(value = "zb_t_target")
|
||||
public class Target extends Base {
|
||||
@TableField("target_id")
|
||||
@ApiModelProperty(value = "指标编号")
|
||||
private String targetId;
|
||||
@TableField("target_name")
|
||||
@ApiModelProperty(value = "指标名称")
|
||||
private String targetName;
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package com.zbsz.filter;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.common.entity.User;
|
||||
import com.common.info.CodeMsg;
|
||||
import com.zbsz.info.Result;
|
||||
import com.zbsz.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@Slf4j
|
||||
public class JwtInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
//判断然后进行用户拦截
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
// 如果不是映射到方法直接通过
|
||||
if (!(handler instanceof HandlerMethod)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//他们校验的居然不是token串,而是去后台校验一个用户id ???
|
||||
String userId = request.getHeader("userId");
|
||||
log.info("获取到用户信息 userId : " + userId);
|
||||
User user = userService.lambdaQuery().eq(User::getUserId,userId).one();
|
||||
|
||||
if(user!=null){
|
||||
return true;
|
||||
}else{
|
||||
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();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package com.zbsz.filter;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.common.entity.User;
|
||||
import com.common.info.CodeMsg;
|
||||
import com.zbsz.info.Result;
|
||||
import com.zbsz.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@Slf4j
|
||||
public class TokenInterceptor implements HandlerInterceptor {
|
||||
|
||||
private UserService userService;
|
||||
|
||||
public TokenInterceptor(UserService userService){
|
||||
this.userService=userService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//他们校验的居然不是token串,而是去后台校验一个用户id ???
|
||||
String userId = request.getHeader("userId");
|
||||
log.info("获取到用户信息 userId : " + userId);
|
||||
if(userId!=null){
|
||||
User user = userService.lambdaQuery().eq(User::getUserId,userId).one();
|
||||
if(user!=null){
|
||||
return true;
|
||||
}else{
|
||||
errorFilter(response);
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
errorFilter(response);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.zbsz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.common.entity.dic.AppDic;
|
||||
|
||||
public interface AppDicMapper extends BaseMapper<AppDic> {
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package com.zbsz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.common.entity.DicTarget;
|
||||
|
||||
public interface DicTargetMapper extends BaseMapper<DicTarget> {
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.zbsz.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.zbsz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.common.entity.Scene;
|
||||
|
||||
public interface SceneMapper extends BaseMapper<Scene> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.zbsz.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.entity.dic.AppDic;
|
||||
import com.zbsz.mapper.AppDicMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AppDicService extends ServiceImpl<AppDicMapper, AppDic> {
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package com.zbsz.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.entity.DicTarget;
|
||||
import com.zbsz.mapper.DicTargetMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class DicTargetService extends ServiceImpl<DicTargetMapper, DicTarget> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.zbsz.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.entity.dic.IndicatorDic;
|
||||
import com.zbsz.mapper.IndicatorDicMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class IndicatorDicService extends ServiceImpl<IndicatorDicMapper, IndicatorDic> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.zbsz.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.entity.Scene;
|
||||
import com.zbsz.mapper.SceneMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SceneService extends ServiceImpl<SceneMapper, Scene> {
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.zbsz;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.common.entity.dic.IndicatorDic;
|
||||
import com.zbsz.service.IndicatorDicService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
public class IndicatorTest {
|
||||
@Resource
|
||||
private IndicatorDicService indicatorDicService;
|
||||
@Test
|
||||
public void testPage(){
|
||||
Page<IndicatorDic> page = new Page(1, 2);
|
||||
indicatorDicService.page(page);
|
||||
List<IndicatorDic> list = page.getRecords();
|
||||
for (IndicatorDic indicatorDic : list) {
|
||||
System.out.println("|||||||||| : "+ JSON.toJSON(indicatorDic));
|
||||
System.out.println("-- : "+indicatorDic.getId());
|
||||
System.out.println("-- : "+indicatorDic.getIndicatorType());
|
||||
System.out.println("-- : "+indicatorDic.getCreateTime());
|
||||
}
|
||||
System.out.println("-------- : "+page.getPages());
|
||||
System.out.println("-------- : "+page.getTotal());
|
||||
System.out.println("-------- : "+page.hasNext());
|
||||
System.out.println("-------- : "+page.hasPrevious());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue