新增查看页面
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
package com.jeesite.modules.app.Api.model;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ApiResult<T> implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 提示信息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
*/
|
||||
private T result;
|
||||
|
||||
/* ---------------- 构造方法 ---------------- */
|
||||
|
||||
public ApiResult() {
|
||||
}
|
||||
|
||||
public ApiResult(int code, String message, T data) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.result = data;
|
||||
}
|
||||
|
||||
|
||||
/* ---------------- 静态工厂方法 ---------------- */
|
||||
|
||||
/**
|
||||
* 成功,仅返回状态码
|
||||
*/
|
||||
public static <T> ApiResult<T> success() {
|
||||
return new ApiResult<>(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功,返回数据
|
||||
*/
|
||||
public static <T> ApiResult<T> success(T data) {
|
||||
return new ApiResult<>(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage(), data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功,自定义提示
|
||||
*/
|
||||
public static <T> ApiResult<T> success(String message, T data) {
|
||||
return new ApiResult<>(ResultCodeEnum.SUCCESS.getCode(), message, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败,默认提示
|
||||
*/
|
||||
public static <T> ApiResult<T> error() {
|
||||
return new ApiResult<>(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMessage(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败,自定义状态码与提示
|
||||
*/
|
||||
public static <T> ApiResult<T> error(int code, String message) {
|
||||
return new ApiResult<>(code, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败,使用枚举
|
||||
*/
|
||||
public static <T> ApiResult<T> error(ResultCodeEnum codeEnum) {
|
||||
return new ApiResult<>(codeEnum.getCode(), codeEnum.getMessage(), null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.jeesite.modules.app.Api.model;
|
||||
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ResultCodeEnum {
|
||||
|
||||
SUCCESS(200, "Success"),
|
||||
FAIL(500, "Fail"),
|
||||
BAD_REQUEST(400, "Bad Request"),
|
||||
UNAUTHORIZED(401, "Unauthorized"),
|
||||
NOT_FOUND(404, "Not Found");
|
||||
|
||||
private final int code;
|
||||
private final String message;
|
||||
|
||||
ResultCodeEnum(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.jeesite.modules.app.Api.web;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.modules.app.Api.model.ApiResult;
|
||||
import com.jeesite.modules.app.Api.model.ResultCodeEnum;
|
||||
import com.jeesite.modules.biz.entity.BizAreaSource;
|
||||
import com.jeesite.modules.biz.service.BizAreaSourceService;
|
||||
import com.jeesite.modules.sys.entity.DictData;
|
||||
import com.jeesite.modules.sys.utils.DictUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/cApi/myWork")
|
||||
public class cApiStart {
|
||||
|
||||
@Resource
|
||||
private BizAreaSourceService bizAreaSourceService;
|
||||
|
||||
private String API_TOKEN = Global.getConfig("biz.api.Token", "");
|
||||
|
||||
|
||||
/**
|
||||
* 字典列表获取
|
||||
*/
|
||||
@RequestMapping(value = "dictList")
|
||||
@ResponseBody
|
||||
public ApiResult<?> getDictList(String token, String dictType) {
|
||||
if (!API_TOKEN.equals(token)) {
|
||||
return ApiResult.error(ResultCodeEnum.FAIL.getCode(), "Token无效");
|
||||
}
|
||||
try {
|
||||
List<DictData> dataList = DictUtils.getDictList(dictType);
|
||||
return ApiResult.success(dataList);
|
||||
} catch (Exception e) {
|
||||
return ApiResult.error(ResultCodeEnum.FAIL.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 区域树形列表
|
||||
*/
|
||||
@RequestMapping(value = "areaTree")
|
||||
@ResponseBody
|
||||
public ApiResult<?> getAreaTree(String token) {
|
||||
if (!API_TOKEN.equals(token)) {
|
||||
return ApiResult.error(ResultCodeEnum.FAIL.getCode(), "Token无效");
|
||||
}
|
||||
try {
|
||||
BizAreaSource bizAreaSource = new BizAreaSource();
|
||||
bizAreaSource.setAreaLevel(3);
|
||||
bizAreaSource.setAreaStatus("1");
|
||||
List<BizAreaSource> areaSourceList = bizAreaSourceService.findList(bizAreaSource);
|
||||
List<Map<String, Object>> treeData = new ArrayList<>();
|
||||
Map<String, Map<String, Object>> nodeMap = new HashMap<>();
|
||||
for (BizAreaSource area : areaSourceList) {
|
||||
Map<String, Object> node = new HashMap<>();
|
||||
node.put("id", area.getAreaCode());
|
||||
node.put("name", area.getAreaName());
|
||||
node.put("disabled", false);
|
||||
node.put("children", new ArrayList<Map<String, Object>>());
|
||||
nodeMap.put(area.getAreaCode(), node);
|
||||
}
|
||||
for (BizAreaSource area : areaSourceList) {
|
||||
Map<String, Object> currentNode = nodeMap.get(area.getAreaCode());
|
||||
String parentCode = area.getPareaCode(); // 当前节点的父编码
|
||||
if (nodeMap.containsKey(parentCode)) {
|
||||
Map<String, Object> parentNode = nodeMap.get(parentCode);
|
||||
List<Map<String, Object>> children = (List<Map<String, Object>>) parentNode.get("children");
|
||||
children.add(currentNode);
|
||||
} else {
|
||||
if (parentCode.equals("0")) {
|
||||
treeData.add(currentNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ApiResult.success(treeData);
|
||||
} catch (Exception e) {
|
||||
return ApiResult.error(ResultCodeEnum.FAIL.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -494,22 +494,8 @@ shiro:
|
||||
# URI 权限过滤器定义(自定义添加参数时,请不要移除 ${adminPath}/** = user,否则会导致权限异常)
|
||||
# 提示:填写过滤规则,请注意先后顺序,从上到下,先匹配先受用规则,匹配成功后不再继续匹配。
|
||||
filterChainDefinitions: |
|
||||
${adminPath}/cApi/** = anon
|
||||
${adminPath}/** = user
|
||||
|
||||
# # URI 权限过滤器定义(以下参考,必须登录user可访问的地址和不需要登录anon可访问地址)
|
||||
# filterChainDefinitions: |
|
||||
# /ReportServer/** = user
|
||||
# ${adminPath}/file/** = anon
|
||||
# ${adminPath}/cms/* = anon
|
||||
# ${adminPath}/cms/site/select = anon
|
||||
# ${adminPath}/cms/site/* = anon
|
||||
# ${adminPath}/cms/category/treeData = anon
|
||||
# ${adminPath}/cms/category/* = anon
|
||||
# ${adminPath}/cms/article/* = anon
|
||||
# ${adminPath}/cms/link/* = anon
|
||||
# ${adminPath}/sys/corpAdmin/treeData = anon
|
||||
# ${adminPath}/${spring.application.name}/swagger/** = anon
|
||||
# ${adminPath}/** = user
|
||||
|
||||
# Session 相关
|
||||
session:
|
||||
@@ -659,31 +645,6 @@ web:
|
||||
${frontPath}/**
|
||||
excludePathPatterns: ~
|
||||
|
||||
# # 静态文件后缀,过滤静态文件,以提高访问性能。
|
||||
# staticFile: .css,.js,.map,.png,.jpg,.gif,.jpeg,.webp,.bmp,.ico,.swf,.psd,.htc,.crx,.xpi,.exe,.ipa,.apk,.otf,.eot,.svg,.ttf,.woff,.woff2
|
||||
#
|
||||
# # 静态文件后缀,排除的url路径,指定哪些uri路径不进行静态文件过滤。
|
||||
# staticFileExcludeUri: /druid/
|
||||
#
|
||||
# # 静态资源路径前缀,可做 CDN 加速优化,默认前面增加 ctxPath 前缀,如果前面写 “//” 两个斜杠 或 包含 “://” 不加 ctxPath。
|
||||
# staticPrefix: /static
|
||||
#
|
||||
# # 严格模式(更严格的数据安全验证)
|
||||
# strictMode: false
|
||||
#
|
||||
# # 所有请求信息将进行xss过滤,这里列出不被xss过滤的地址
|
||||
# xssFilterExcludeUri: /ureport/,/visual/
|
||||
#
|
||||
# # 自定义正则表达式验证(主键、登录名)
|
||||
# validator:
|
||||
# id: '[a-zA-Z0-9_\-/#\u4e00-\u9fa5]{0,64}'
|
||||
# user.loginCode: '[a-zA-Z0-9_\u4e00-\u9fa5]{4,20}'
|
||||
#
|
||||
# # 默认不启用(为兼用旧版保留,建议使用 CORS)
|
||||
# jsonp:
|
||||
# enabled: false
|
||||
# callback: __callback
|
||||
|
||||
# 核心模块的Web功能开启(其它微服务时设为false)
|
||||
core:
|
||||
enabled: true
|
||||
@@ -698,7 +659,7 @@ springdoc:
|
||||
# 错误页面500.html是否输出错误信息(正式环境,为提供安全性可设置为false)
|
||||
error:
|
||||
page:
|
||||
printErrorInfo: true
|
||||
printErrorInfo: false
|
||||
|
||||
#======================================#
|
||||
#======== FileUpload settings =========#
|
||||
@@ -711,22 +672,22 @@ file:
|
||||
# # 文件上传根路径,设置路径中不允许包含“userfiles”,在指定目录中系统会自动创建userfiles目录,如果不设置默认为contextPath路径
|
||||
baseDir: /ogsapp/files
|
||||
maxFileSize: '500*1024*1024'
|
||||
# # 是否开启分片上传
|
||||
# chunked: true
|
||||
# # 分片大小,单位字节(50M)
|
||||
# chunkSize: '50*1024*1024'
|
||||
# # 最大上传线程数
|
||||
# threads: 3
|
||||
# # 是否启用检查点(支持断点续传,上传)
|
||||
# checkpoint: true
|
||||
# isFileStreamDown: true
|
||||
# # 是否开启分片上传
|
||||
# chunked: true
|
||||
# # 分片大小,单位字节(50M)
|
||||
# chunkSize: '50*1024*1024'
|
||||
# # 最大上传线程数
|
||||
# threads: 3
|
||||
# # 是否启用检查点(支持断点续传,上传)
|
||||
# checkpoint: true
|
||||
# isFileStreamDown: true
|
||||
|
||||
#
|
||||
# # 上传文件的相对路径(支持:yyyy、MM、dd、HH、mm、ss、E、bizType、corpCode、userCode、userType、userCache中的key)
|
||||
# uploadPath: '{yyyy}{MM}/'
|
||||
# uploadPath: '{yyyy}{MM}/'
|
||||
#
|
||||
# # 上传单个文件最大字节(500M),在这之上还有 > Tomcat限制 > Nginx限制,等,此设置会覆盖 spring.http.multipart.maxFileSize 设置
|
||||
# maxFileSize: '500*1024*1024'
|
||||
# maxFileSize: '500*1024*1024'
|
||||
#
|
||||
# # 设置允许上传的文件后缀(全局设置)
|
||||
# imageAllowSuffixes: .gif,.bmp,.jpeg,.jpg,.ico,.png,.tif,.tiff,.webp,
|
||||
|
||||
Reference in New Issue
Block a user