大屏页面初始化
This commit is contained in:
@@ -12,12 +12,6 @@ public class routeController {
|
||||
/**
|
||||
* 路由跳转
|
||||
*/
|
||||
@GetMapping({"/", "/login", "/bigScreen", "/dashboard"})
|
||||
public String forwardToIndex() {
|
||||
return "forward:/index.html";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/**/{path:[^.]*}")
|
||||
public String redirect(@PathVariable String path) {
|
||||
return "forward:/index.html";
|
||||
|
||||
@@ -1,22 +1,45 @@
|
||||
package com.mini.mybigscreen.Config;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.mini.mybigscreen.Model.Result;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
@Component
|
||||
public class LoginInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session == null) {
|
||||
response.sendRedirect("/login");
|
||||
if (ObjectUtils.isEmpty(session)) {
|
||||
String json = objectMapper.writeValueAsString(Result.unauthorized());
|
||||
try (PrintWriter writer = response.getWriter()) {
|
||||
writer.write(json);
|
||||
writer.flush();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
String token = (String) session.getAttribute("token");
|
||||
if (StringUtils.isEmpty(token)){
|
||||
String json = objectMapper.writeValueAsString(Result.unauthorized());
|
||||
try (PrintWriter writer = response.getWriter()) {
|
||||
writer.write(json);
|
||||
writer.flush();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,37 +2,143 @@ package com.mini.mybigscreen.Model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 通用响应结果类
|
||||
*/
|
||||
@Data
|
||||
public class Result<T> implements Serializable {
|
||||
|
||||
// 序列化版本号,避免序列化/反序列化异常
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
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;
|
||||
private Result() {}
|
||||
|
||||
private Result(Integer code, String msg, T data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
// 成功返回(无数据)
|
||||
/**
|
||||
* 成功返回(无数据,默认code=200,msg=操作成功)
|
||||
*/
|
||||
public static <T> Result<T> success() {
|
||||
return success(null);
|
||||
return new Result<>(200, "操作成功", 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;
|
||||
/**
|
||||
* 成功返回(带数据,默认code=200,msg=操作成功)
|
||||
*/
|
||||
public static <T> Result<T> success(T data) {
|
||||
return new Result<>(200, "操作成功", data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回(自定义msg,默认code=200,无数据)
|
||||
*/
|
||||
public static <T> Result<T> successMsg(String msg) {
|
||||
return new Result<>(200, msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回(自定义msg+数据,默认code=200)
|
||||
*/
|
||||
public static <T> Result<T> successMsg(String msg, T data) {
|
||||
return new Result<>(200, msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回(默认code=500,自定义msg,无数据)
|
||||
*/
|
||||
public static <T> Result<T> error(String msg) {
|
||||
return new Result<>(500, msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回(自定义code+msg,无数据)
|
||||
*/
|
||||
public static <T> Result<T> error(Integer code, String msg) {
|
||||
return new Result<>(code, msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回(自定义code+msg+数据,按需使用)
|
||||
*/
|
||||
public static <T> Result<T> error(Integer code, String msg, T data) {
|
||||
return new Result<>(code, msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义响应结果(全参数)
|
||||
*/
|
||||
public static <T> Result<T> custom(Integer code, String msg, T data) {
|
||||
return new Result<>(code, msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅通过状态码返回(默认msg为空,无数据)
|
||||
* @param code 状态码
|
||||
* @return 响应结果
|
||||
*/
|
||||
public static <T> Result<T> byCode(Integer code) {
|
||||
return new Result<>(code, "", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅通过状态码+提示信息返回(无数据)
|
||||
* @param code 状态码
|
||||
* @param msg 提示信息
|
||||
* @return 响应结果
|
||||
*/
|
||||
public static <T> Result<T> byCode(Integer code, String msg) {
|
||||
return new Result<>(code, msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅通过状态码+数据返回(默认msg为空)
|
||||
* @param code 状态码
|
||||
* @param data 业务数据
|
||||
* @return 响应结果
|
||||
*/
|
||||
public static <T> Result<T> byCode(Integer code, T data) {
|
||||
return new Result<>(code, "", data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 快捷返回400参数错误(无数据)
|
||||
*/
|
||||
public static <T> Result<T> badRequest() {
|
||||
return new Result<>(400, "参数错误", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 快捷返回401未授权(无数据)
|
||||
*/
|
||||
public static <T> Result<T> unauthorized() {
|
||||
return new Result<>(401, "未授权", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 快捷返回403禁止访问(无数据)
|
||||
*/
|
||||
public static <T> Result<T> forbidden() {
|
||||
return new Result<>(403, "禁止访问", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 快捷返回404资源不存在(无数据)
|
||||
*/
|
||||
public static <T> Result<T> notFound() {
|
||||
return new Result<>(404, "资源不存在", null);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mini.mybigscreen.biz.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.mini.mybigscreen.biz.domain.ErpAccount;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,6 +11,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
* @author gaoxq
|
||||
* @since 2026-02-27
|
||||
*/
|
||||
public interface ErpAccountMapper extends BaseMapper<ErpAccount> {
|
||||
public interface ErpAccountMapper extends MPJBaseMapper<ErpAccount> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mini.mybigscreen.biz.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.mini.mybigscreen.biz.domain.ErpCategory;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,6 +11,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
* @author gaoxq
|
||||
* @since 2026-02-27
|
||||
*/
|
||||
public interface ErpCategoryMapper extends BaseMapper<ErpCategory> {
|
||||
public interface ErpCategoryMapper extends MPJBaseMapper<ErpCategory> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mini.mybigscreen.biz.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.mini.mybigscreen.biz.domain.ErpTransactionFlow;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,6 +11,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
* @author gaoxq
|
||||
* @since 2026-02-27
|
||||
*/
|
||||
public interface ErpTransactionFlowMapper extends BaseMapper<ErpTransactionFlow> {
|
||||
public interface ErpTransactionFlowMapper extends MPJBaseMapper<ErpTransactionFlow> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.mini.mybigscreen.biz.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.mini.mybigscreen.biz.domain.HomeMenu;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,6 +12,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
* @author gaoxq
|
||||
* @since 2026-03-01
|
||||
*/
|
||||
public interface HomeMenuMapper extends BaseMapper<HomeMenu> {
|
||||
public interface HomeMenuMapper extends MPJBaseMapper<HomeMenu> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mini.mybigscreen.biz.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.mini.mybigscreen.biz.domain.HomeModule;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,6 +11,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
* @author gaoxq
|
||||
* @since 2026-02-27
|
||||
*/
|
||||
public interface HomeModuleMapper extends BaseMapper<HomeModule> {
|
||||
public interface HomeModuleMapper extends MPJBaseMapper<HomeModule> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mini.mybigscreen.biz.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.mini.mybigscreen.biz.domain.HomeModuleUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,6 +11,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
* @author gaoxq
|
||||
* @since 2026-02-27
|
||||
*/
|
||||
public interface HomeModuleUserMapper extends BaseMapper<HomeModuleUser> {
|
||||
public interface HomeModuleUserMapper extends MPJBaseMapper<HomeModuleUser> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mini.mybigscreen.biz.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.mini.mybigscreen.biz.domain.HomeUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,6 +11,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
* @author gaoxq
|
||||
* @since 2026-02-28
|
||||
*/
|
||||
public interface HomeUserMapper extends BaseMapper<HomeUser> {
|
||||
public interface HomeUserMapper extends MPJBaseMapper<HomeUser> {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user