1.初始化版本,2.引入thirdpart模块,引入canteen模块,初始化菜品分类,spu

This commit is contained in:
zjf committed 2024-12-06 16:54:30 +08:00
commit aff77150d6
1595 files changed
+168833

No files matched your search

@@ -0,0 +1,41 @@
/*
* Copyright (c) 2018-2025, pjcloud All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: pjcloud
*/
package com.bsd.pjcloud.bi;
import com.bsd.pjcloud.common.feign.annotation.EnablePjcloudFeignClients;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* @author pjcloud
* @date 2022-04-06
* <p>
*/
@EnablePjcloudFeignClients
@EnableDiscoveryClient
@SpringBootApplication(scanBasePackages = { "org.jeecg.modules.jmreport", "com.bsd.pjcloud.bi" },
exclude = MongoAutoConfiguration.class)
public class PjcloudJimuApplication {
public static void main(String[] args) {
SpringApplication.run(PjcloudJimuApplication.class, args);
}
}
@@ -0,0 +1,91 @@
package com.bsd.pjcloud.bi.config;
import cn.hutool.core.io.IoUtil;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponseWrapper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import java.io.CharArrayWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.Charset;
/**
* @author pjcloud
* @date 2024/11/26
* <p>
* 删除 积木报表的 header 避免 iframe 嵌套 , 造成页面显示异常
*/
@Component
public class HtmlEnhanceFilter extends OncePerRequestFilter {
@Value("classpath:/templates/enhance.ftl")
private Resource resource;
/**
* do 过滤器内部
*
* @param request 请求
* @param response 响应
* @param filterChain Filter Chain (筛选链)
* @throws ServletException Servlet 异常
* @throws IOException io异常
*/
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
// 不是首页直接跳过
if (!request.getRequestURI().equals("/jmreport/list")) {
filterChain.doFilter(request, response);
return;
}
// 包装响应对象
EditedResponseWrapper responseWrapper = new EditedResponseWrapper(response);
// 执行链并捕获响应内容
filterChain.doFilter(request, responseWrapper);
// 获取原始 HTML 内容
String originalHtml = responseWrapper.toString();
// 在 HTML 内容中插入自定义 JS
String enhancedHtml = originalHtml.replace("</body>", IoUtil.read(resource.getInputStream(), Charset.defaultCharset()) + "</body>");
// 将增强后的内容写回响应
response.getWriter().write(enhancedHtml);
}
/**
* 可编辑响应流包装器
*
* @author pjcloud
* @date 2024/11/26
*/
static class EditedResponseWrapper extends HttpServletResponseWrapper {
private CharArrayWriter charArrayWriter = new CharArrayWriter();
public EditedResponseWrapper(HttpServletResponse response) {
super(response);
}
@Override
public PrintWriter getWriter() {
return new PrintWriter(charArrayWriter);
}
@Override
public String toString() {
return charArrayWriter.toString();
}
}
}
@@ -0,0 +1,66 @@
package com.bsd.pjcloud.bi.config;
import cn.hutool.core.util.CharUtil;
import cn.hutool.core.util.StrUtil;
import com.bsd.pjcloud.admin.api.feign.RemoteTokenService;
import com.bsd.pjcloud.common.core.constant.CommonConstants;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.core.util.RetOps;
import lombok.RequiredArgsConstructor;
import org.jeecg.modules.jmreport.api.JmReportTokenServiceI;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @author pjcloud
* @date 2022/4/6
* <p>
* 积木安全控制
*/
@Component
@RequiredArgsConstructor
public class JimuReportTokenService implements JmReportTokenServiceI {
private final RemoteTokenService tokenService;
@Override
public String getUsername(String token) {
// 分割出 PIGX 的租户信息
String tenant = StrUtil.subBefore(token, CharUtil.UNDERLINE, false);
String tokenStr = StrUtil.subAfter(token, CharUtil.UNDERLINE, false);
// @formatter:off
return RetOps.of(tokenService.queryToken(tokenStr, tenant ))
.getDataIf(RetOps.CODE_SUCCESS)
.map(o -> (String)o.get("principalName"))
.orElse(null);
// @formatter:off
}
@Override public String[] getRoles(String s) {
return new String[]{"admin"};
}
@Override
public Map<String, Object> getUserInfo(String token) {
String username = this.getUsername(token);
Map<String, Object> map = new HashMap<>(4);
map.put("principalName", username);
map.put("access_token", token);
// 将所有信息存放至map 解析sql会根据map的键值解析,可自定义其他值
return map;
}
@Override
public Boolean verifyToken(String token) {
// 分割出 PIGX 的租户信息
String tenant = StrUtil.subBefore(token, CharUtil.UNDERLINE, false);
String tokenStr = StrUtil.subAfter(token, CharUtil.UNDERLINE, false);
R<Map<String, Object>> result = tokenService.queryToken(tokenStr,tenant );
if (CommonConstants.SUCCESS.equals(result.getCode())) {
return true;
}
return false;
}
}
@@ -0,0 +1,21 @@
server:
port: 5008
undertow:
buffer-size: 1MB
spring:
application:
name: @artifactId@
cloud:
nacos:
username: @nacos.username@
password: @nacos.password@
discovery:
server-addr: ${NACOS_HOST:pjcloud-register}:${NACOS_PORT:8848}
service: @artifactId@
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
config:
import:
- optional:nacos:application-@profiles.active@.yml
- optional:nacos:${spring.application.name}-@profiles.active@.yml
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2018-2025, pjcloud All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the pig4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: pjcloud
-->
<!--
小技巧: 在根pom里面设置统一存放路径,统一管理方便维护
<properties>
<log-path>/Users/pjcloud</log-path>
</properties>
1. 其他模块加日志输出,直接copy本文件放在resources 目录即可
2. 注意修改 <property name="${log-path}/log.path" value=""/> 的value模块
-->
<configuration debug="false" scan="false">
<property name="log.path" value="logs/${project.artifactId}"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- Console log output -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- Log file debug output -->
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
</encoder>
</appender>
<!-- Log file error output -->
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>
<!--nacos 心跳 INFO 屏蔽-->
<logger name="com.alibaba.nacos" level="OFF">
<appender-ref ref="error"/>
</logger>
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
<root level="INFO">
<appender-ref ref="console"/>
<appender-ref ref="debug"/>
<appender-ref ref="error"/>
</root>
</configuration>
@@ -0,0 +1,5 @@
<script>
document.addEventListener("DOMContentLoaded", function () {
document.querySelector("#app > div.layout > div:nth-child(1)").remove()
});
</script>