大屏项目初始化
This commit is contained in:
18
src/main/java/com/mini/mybigscreen/Auth/routeController.java
Normal file
18
src/main/java/com/mini/mybigscreen/Auth/routeController.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.mini.mybigscreen.Auth;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
public class routeController {
|
||||
|
||||
|
||||
/**
|
||||
* 路由跳转
|
||||
*/
|
||||
@GetMapping({"/", "/login", "/dashboard"})
|
||||
public String forwardToIndex() {
|
||||
return "forward:/index.html";
|
||||
}
|
||||
|
||||
}
|
||||
32
src/main/java/com/mini/mybigscreen/Auth/userController.java
Normal file
32
src/main/java/com/mini/mybigscreen/Auth/userController.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.mini.mybigscreen.Auth;
|
||||
|
||||
import com.mini.mybigscreen.Model.LoginRequest;
|
||||
import com.mini.mybigscreen.Model.Result;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class userController {
|
||||
|
||||
|
||||
/**
|
||||
* 系统登录
|
||||
*/
|
||||
@PostMapping("/userLogin")
|
||||
public Result<?> getUserInfo(@RequestBody LoginRequest loginRequest, HttpServletRequest request) {
|
||||
String username = loginRequest.getUsername();
|
||||
String password = loginRequest.getPassword();
|
||||
if ("admin".equals(username) && "123456".equals(password)) {
|
||||
String token = "admin-token-" + System.currentTimeMillis();
|
||||
HttpSession session = request.getSession(true);
|
||||
session.setAttribute("loginUser", username);
|
||||
session.setAttribute("token", token);
|
||||
return Result.success(token);
|
||||
} else {
|
||||
return Result.error("账号或密码错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/main/java/com/mini/mybigscreen/Config/CorsConfig.java
Normal file
25
src/main/java/com/mini/mybigscreen/Config/CorsConfig.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.mini.mybigscreen.Config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
// 允许所有路径跨域
|
||||
registry.addMapping("/**")
|
||||
.allowedOriginPatterns("*")
|
||||
// 允许的请求方法
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
||||
// 允许的请求头
|
||||
.allowedHeaders("*")
|
||||
// 允许携带Cookie
|
||||
.allowCredentials(true)
|
||||
// 预检请求有效期(秒)
|
||||
.maxAge(3600);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mini.mybigscreen.Config;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
|
||||
@Component
|
||||
public class LoginInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session == null) {
|
||||
response.sendRedirect(request.getContextPath() + "/index.html");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
29
src/main/java/com/mini/mybigscreen/Config/WebConfig.java
Normal file
29
src/main/java/com/mini/mybigscreen/Config/WebConfig.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.mini.mybigscreen.Config;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Resource
|
||||
private LoginInterceptor loginInterceptor;
|
||||
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 注册登录拦截器,拦截所有请求,排除登录接口
|
||||
registry.addInterceptor(loginInterceptor)
|
||||
.addPathPatterns("/**") // 拦截所有路径
|
||||
.excludePathPatterns(
|
||||
"/",
|
||||
"/index.html",
|
||||
"/userLogin"
|
||||
)
|
||||
.excludePathPatterns("/static/**")
|
||||
.excludePathPatterns("/assets/**")
|
||||
; // 排除静态资源(前端打包后的文件)
|
||||
}
|
||||
}
|
||||
12
src/main/java/com/mini/mybigscreen/Model/LoginRequest.java
Normal file
12
src/main/java/com/mini/mybigscreen/Model/LoginRequest.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.mini.mybigscreen.Model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class LoginRequest implements Serializable {
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
}
|
||||
38
src/main/java/com/mini/mybigscreen/Model/Result.java
Normal file
38
src/main/java/com/mini/mybigscreen/Model/Result.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.mini.mybigscreen.Model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class Result<T> implements Serializable {
|
||||
|
||||
private Integer code;
|
||||
// 提示信息
|
||||
private String msg;
|
||||
// 数据体
|
||||
private T data;
|
||||
|
||||
// 成功返回(带数据)
|
||||
public static <T> Result<T> success(T data) {
|
||||
Result<T> result = new Result<>();
|
||||
result.setCode(200);
|
||||
result.setMsg("操作成功");
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 成功返回(无数据)
|
||||
public static <T> Result<T> success() {
|
||||
return success(null);
|
||||
}
|
||||
|
||||
// 失败返回
|
||||
public static <T> Result<T> error(String msg) {
|
||||
Result<T> result = new Result<>();
|
||||
result.setCode(500);
|
||||
result.setMsg(msg);
|
||||
result.setData(null);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mini.mybigscreen;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.mini.mybigscreen.biz.mapper")
|
||||
public class MyBigScreenApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MyBigScreenApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mini.mybigscreen.biz.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 业务项目信息表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author gaoxq
|
||||
* @since 2026-02-24
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/biz/itemInfo")
|
||||
public class ItemInfoController {
|
||||
|
||||
}
|
||||
188
src/main/java/com/mini/mybigscreen/biz/domain/ItemInfo.java
Normal file
188
src/main/java/com/mini/mybigscreen/biz/domain/ItemInfo.java
Normal file
@@ -0,0 +1,188 @@
|
||||
package com.mini.mybigscreen.biz.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 业务项目信息表
|
||||
* </p>
|
||||
*
|
||||
* @author gaoxq
|
||||
* @since 2026-02-24
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("biz_item_info")
|
||||
public class ItemInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
@TableField("item_name")
|
||||
private String itemName;
|
||||
|
||||
/**
|
||||
* 项目编号
|
||||
*/
|
||||
@TableField("item_code")
|
||||
private String itemCode;
|
||||
|
||||
/**
|
||||
* 备注描述
|
||||
*/
|
||||
@TableField("title")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
@TableField("seq")
|
||||
private Long seq;
|
||||
|
||||
/**
|
||||
* 请求日期
|
||||
*/
|
||||
@TableField("ym")
|
||||
private String ym;
|
||||
|
||||
/**
|
||||
* 指标周期
|
||||
*/
|
||||
@TableField("cycle")
|
||||
private String cycle;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
@TableField("req_param")
|
||||
private String reqParam;
|
||||
|
||||
/**
|
||||
* x轴名称
|
||||
*/
|
||||
@TableField("x_axis")
|
||||
private String xAxis;
|
||||
|
||||
/**
|
||||
* 指标01
|
||||
*/
|
||||
@TableField("index_01")
|
||||
private String index01;
|
||||
|
||||
/**
|
||||
* 指标02
|
||||
*/
|
||||
@TableField("index_02")
|
||||
private String index02;
|
||||
|
||||
/**
|
||||
* 指标03
|
||||
*/
|
||||
@TableField("index_03")
|
||||
private String index03;
|
||||
|
||||
/**
|
||||
* 指标04
|
||||
*/
|
||||
@TableField("index_04")
|
||||
private String index04;
|
||||
|
||||
/**
|
||||
* 指标05
|
||||
*/
|
||||
@TableField("index_05")
|
||||
private String index05;
|
||||
|
||||
/**
|
||||
* 指标06
|
||||
*/
|
||||
@TableField("index_06")
|
||||
private String index06;
|
||||
|
||||
/**
|
||||
* 指标07
|
||||
*/
|
||||
@TableField("index_07")
|
||||
private String index07;
|
||||
|
||||
/**
|
||||
* 指标08
|
||||
*/
|
||||
@TableField("index_08")
|
||||
private String index08;
|
||||
|
||||
/**
|
||||
* 指标09
|
||||
*/
|
||||
@TableField("index_09")
|
||||
private String index09;
|
||||
|
||||
/**
|
||||
* 指标10
|
||||
*/
|
||||
@TableField("index_10")
|
||||
private String index10;
|
||||
|
||||
/**
|
||||
* 指标11
|
||||
*/
|
||||
@TableField("index_11")
|
||||
private String index11;
|
||||
|
||||
/**
|
||||
* 指标12
|
||||
*/
|
||||
@TableField("index_12")
|
||||
private String index12;
|
||||
|
||||
/**
|
||||
* 指标13
|
||||
*/
|
||||
@TableField("index_13")
|
||||
private String index13;
|
||||
|
||||
/**
|
||||
* 指标14
|
||||
*/
|
||||
@TableField("index_14")
|
||||
private String index14;
|
||||
|
||||
/**
|
||||
* 指标15
|
||||
*/
|
||||
@TableField("index_15")
|
||||
private String index15;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标识(1-未删,0-已删)
|
||||
*/
|
||||
@TableField("is_deleted")
|
||||
private String isDeleted;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mini.mybigscreen.biz.mapper;
|
||||
|
||||
import com.mini.mybigscreen.biz.domain.ItemInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 业务项目信息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author gaoxq
|
||||
* @since 2026-02-24
|
||||
*/
|
||||
public interface ItemInfoMapper extends BaseMapper<ItemInfo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mini.mybigscreen.biz.service;
|
||||
|
||||
import com.mini.mybigscreen.biz.domain.ItemInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 业务项目信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author gaoxq
|
||||
* @since 2026-02-24
|
||||
*/
|
||||
public interface ItemInfoService extends IService<ItemInfo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mini.mybigscreen.biz.service.impl;
|
||||
|
||||
import com.mini.mybigscreen.biz.domain.ItemInfo;
|
||||
import com.mini.mybigscreen.biz.mapper.ItemInfoMapper;
|
||||
import com.mini.mybigscreen.biz.service.ItemInfoService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 业务项目信息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author gaoxq
|
||||
* @since 2026-02-24
|
||||
*/
|
||||
@Service
|
||||
public class ItemInfoServiceImpl extends ServiceImpl<ItemInfoMapper, ItemInfo> implements ItemInfoService {
|
||||
|
||||
}
|
||||
54
src/main/java/com/mini/mybigscreen/mybatis/demo.java
Normal file
54
src/main/java/com/mini/mybigscreen/mybatis/demo.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.mini.mybigscreen.mybatis;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.config.OutputFile;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class demo {
|
||||
|
||||
public static void main(String[] args) {
|
||||
FastAutoGenerator.create("jdbc:mysql://192.168.31.189:33069/work?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC", "dream", "info_dream")
|
||||
.globalConfig(builder -> {
|
||||
builder.author("gaoxq")
|
||||
.outputDir(System.getProperty("user.dir") + "/src/main/java")
|
||||
.disableOpenDir();
|
||||
})
|
||||
.packageConfig(builder -> {
|
||||
builder.parent("com.mini.mybigscreen")
|
||||
.moduleName("biz")
|
||||
.entity("domain")
|
||||
.mapper("mapper")
|
||||
.xml("mapper.xml")
|
||||
.service("service")
|
||||
.serviceImpl("service.impl")
|
||||
.controller("controller")
|
||||
.pathInfo(Collections.singletonMap(OutputFile.xml, System.getProperty("user.dir") + "/src/main/resources/mapper"));
|
||||
})
|
||||
.strategyConfig(builder -> {
|
||||
builder.addInclude("biz_item_info")
|
||||
.addTablePrefix("biz_")
|
||||
.entityBuilder()
|
||||
.enableLombok()
|
||||
.naming(NamingStrategy.underline_to_camel)
|
||||
.columnNaming(NamingStrategy.underline_to_camel)
|
||||
.idType(IdType.AUTO)
|
||||
.enableTableFieldAnnotation()
|
||||
.enableFileOverride()
|
||||
.controllerBuilder()
|
||||
.enableRestStyle()
|
||||
.serviceBuilder()
|
||||
.formatServiceFileName("%sService")
|
||||
.formatServiceImplFileName("%sServiceImpl")
|
||||
.mapperBuilder()
|
||||
.enableBaseResultMap()
|
||||
.enableBaseColumnList()
|
||||
.enableFileOverride(); // 开启mapper接口和xml文件覆盖
|
||||
})
|
||||
.templateEngine(new FreemarkerTemplateEngine())
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
17
src/main/resources/application.properties
Normal file
17
src/main/resources/application.properties
Normal file
@@ -0,0 +1,17 @@
|
||||
spring.application.name=my-bigScreen
|
||||
server.port=31001
|
||||
server.servlet.context-path=/
|
||||
server.compression.enabled=true
|
||||
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json
|
||||
server.tomcat.max-connections=200
|
||||
server.tomcat.threads.max=100
|
||||
server.tomcat.threads.min-spare=10
|
||||
spring.servlet.multipart.enabled=true
|
||||
spring.servlet.multipart.max-file-size=200MB
|
||||
spring.servlet.multipart.max-request-size=1000MB
|
||||
spring.servlet.multipart.file-size-threshold=10MB
|
||||
## MySQL
|
||||
spring.datasource.url=jdbc:mysql://192.168.31.189:33069/work?useSSL=false&serverTimezone=UTC&characterEncoding=utf8
|
||||
spring.datasource.username=dream
|
||||
spring.datasource.password=info_dream
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
41
src/main/resources/mapper/ItemInfoMapper.xml
Normal file
41
src/main/resources/mapper/ItemInfoMapper.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.mini.mybigscreen.biz.mapper.ItemInfoMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.mini.mybigscreen.biz.domain.ItemInfo">
|
||||
<id column="id" property="id" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="item_name" property="itemName" />
|
||||
<result column="item_code" property="itemCode" />
|
||||
<result column="title" property="title" />
|
||||
<result column="seq" property="seq" />
|
||||
<result column="ym" property="ym" />
|
||||
<result column="cycle" property="cycle" />
|
||||
<result column="req_param" property="reqParam" />
|
||||
<result column="x_axis" property="xAxis" />
|
||||
<result column="index_01" property="index01" />
|
||||
<result column="index_02" property="index02" />
|
||||
<result column="index_03" property="index03" />
|
||||
<result column="index_04" property="index04" />
|
||||
<result column="index_05" property="index05" />
|
||||
<result column="index_06" property="index06" />
|
||||
<result column="index_07" property="index07" />
|
||||
<result column="index_08" property="index08" />
|
||||
<result column="index_09" property="index09" />
|
||||
<result column="index_10" property="index10" />
|
||||
<result column="index_11" property="index11" />
|
||||
<result column="index_12" property="index12" />
|
||||
<result column="index_13" property="index13" />
|
||||
<result column="index_14" property="index14" />
|
||||
<result column="index_15" property="index15" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="is_deleted" property="isDeleted" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
create_time, id, item_name, item_code, title, seq, ym, cycle, req_param, x_axis, index_01, index_02, index_03, index_04, index_05, index_06, index_07, index_08, index_09, index_10, index_11, index_12, index_13, index_14, index_15, update_time, is_deleted
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mini.mybigscreen;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class MyBigScreenApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user