Compare commits
25 Commits
73b5efeb8f
..
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 0bc66b5808 | |||
| 6d8185cc70 | |||
| 13cb08621f | |||
| fdff54a6cf | |||
| 6e475bea03 | |||
| a3c54249dc | |||
| 2cd60270b9 | |||
| b2b1a1bdf9 | |||
| da1f9a64d4 | |||
| 27dbea9b6f | |||
| ce1d0a2a8a | |||
| 5d88684820 | |||
| 1e2ec82c18 | |||
| 08138f1f04 | |||
| 9d188d304b | |||
| 1aa8b8d4e4 | |||
| 32a41bde6d | |||
| 9b050c9dc5 | |||
| 32a3d1918c | |||
| ab2f615067 | |||
| 10099a1d5a | |||
| 4cbd925544 | |||
| b2f310b81d | |||
| 1bcb805d65 | |||
| 770aeff4d7 |
@@ -42,4 +42,3 @@ ehthumbs.db
|
||||
Thumbs.db
|
||||
/file/
|
||||
/websoft-modules.log
|
||||
/tmp/
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"version": 2,
|
||||
"sessions": {
|
||||
"8b8cdf8cb3404efeac18615f9f419cb1": [
|
||||
{
|
||||
"expertId": "SeniorDeveloper",
|
||||
"name": "吴八哥",
|
||||
"profession": "高级开发工程师",
|
||||
"avatarUrl": "https://acc-1258344699.cos.accelerate.myqcloud.com/workbuddy/experts/avatars/02-Engineering/SeniorDeveloper/SeniorDeveloper.png",
|
||||
"promptUrl": "https://acc-1258344699.cos.accelerate.myqcloud.com/workbuddy/experts/experts/02-Engineering/SeniorDeveloper/SeniorDeveloper_zh.md",
|
||||
"usedAt": 1776323986694,
|
||||
"industryId": "02-Engineering"
|
||||
}
|
||||
]
|
||||
},
|
||||
"lastUpdated": 1776324781452
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
# 2026-07-18
|
||||
|
||||
## 生产日志报错分析(cms-api)
|
||||
|
||||
用户贴了一段 cms-api 容器日志,三类信息,结论如下:
|
||||
|
||||
1. **`Table 'modules.sys_user' doesn't exist`(真 bug,影响功能)**
|
||||
- 根因:部署的 MySQL 库名是 `modules`(`application-prod.yml`/`application-cms.yml` 中 `jdbc:mysql://.../modules`),而 `common.system.entity.User` 实体 `@TableName("sys_user")`,且 cms 模块多处使用 `UserService`(`CmsNavigationController`、`CmsArticleController`、`LeadReferralServiceImpl` 等)。`modules` 库里缺 `sys_user` 系统表 → 任何依赖查 `sys_user` 的请求抛 `SQLSyntaxErrorException` → 500。
|
||||
- 性质:数据库初始化/迁移遗漏,**不是代码逻辑 bug**(代码正确,库缺表)。仓库内无 `sys_user` 建表 SQL,说明系统基础表由外部初始化脚本/主 server 工程提供。
|
||||
- 修复方向:在 `modules` 库执行系统基础 schema(建 `sys_user` 等系统表)。需找到对应 init SQL。
|
||||
|
||||
2. **`参数类型转换异常: 参数名=id, 传入值=resolveDomain/getByDomain/submitForm/.../NaN`(噪音,不影响)**
|
||||
- 来源:`BaseController.handleMethodArgumentTypeMismatch`(`@ExceptionHandler(MethodArgumentTypeMismatchException)`),扫描器/爬虫用方法名字符串(resolveDomain、submitForm 等)和 NaN 探测 `id`(Integer) 参数,被拦截并返回友好错误。属公网 API 被扫描,无功能影响。建议:改用 logger 替代 `System.err.println`,必要时加限流/WAF。
|
||||
|
||||
3. **`定时任务需要查询所有租户的超时订单 list = 0`(正常,不影响)**
|
||||
- 来源:`OrderCancelServiceImpl.findExpiredUnpaidOrders` 的 `System.out.println`,表示当前无超时未支付订单。正常运维日志。
|
||||
|
||||
## 修复:sys_ 系统表改指 gxwebsoft_core schema
|
||||
|
||||
用户确认架构意图:系统表(sys_ 前缀)本就在中央库 `gxwebsoft_core`(与 `modules` 同实例 `1Panel-mysql-Bqdt`),pwl 模块 Mapper XML 早就在用 `gxwebsoft_core.sys_user`/`gxwebsoft_core.sys_dict_data`。原报错是实体 `@TableName("sys_xxx")` 默认落到数据源默认库 `modules` 导致表缺失。
|
||||
|
||||
已用脚本批量修改(精确、白名单防误伤):
|
||||
- 33 个实体 `@TableName("sys_xxx")` → `"gxwebsoft_core.sys_xxx"`(全部在 `common/system/entity`)。
|
||||
- 19 个 Mapper XML 里 `FROM/JOIN` 后的 `sys_` 表名加 `gxwebsoft_core.` 前缀(31 处,全在 `common/system/mapper/xml`)。
|
||||
- 其他模块(pwl/shop/app)对 sys_ 表的引用本来就是 `gxwebsoft_core.` 开头,未动。
|
||||
- `MybatisPlusConfig` 无全局表前缀,无冲突。
|
||||
|
||||
校验:裸 `@TableName("sys_`=0、裸 `FROM/JOIN sys_`=0、重复前缀=0。`UserInfo`/`EmailRecord`/`Payment` 等 sys_ 实体也已覆盖。
|
||||
|
||||
注意点(已告知用户):
|
||||
- 需重新编译/重启 cms-api 容器生效。
|
||||
- 确认 `modules` 库的连接账号对 `gxwebsoft_core` 有读写权限,且 `gxwebsoft_core` 里确实建齐了这些 sys_ 表。
|
||||
- 多租户插件会给查询加 `tenant_id`,表结构/字段不变则行为不变。
|
||||
|
||||
## 生成 gxwebsoft_core 缺失系统表检查 SQL
|
||||
|
||||
从实体 `@TableName` 精确提取共 **31 张** `sys_` 表,生成 `docs/check_gxwebsoft_core_sys_tables.sql`。
|
||||
含四种查法:① 只列缺失表(结果空=齐全)② 逐张 EXISTS/MISSING 状态 ③ 期望31/实际/缺失数量统计 ④ 确认 gxwebsoft_core 库存在+账号有权限。基于 `information_schema.tables` 比对,无副作用只读。
|
||||
@@ -1,19 +0,0 @@
|
||||
# 2026-07-19 工作日志
|
||||
|
||||
## cms-api phone 字段超长报错修复
|
||||
- **问题**: cms-api 容器报 `com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Data too long for column 'phone' at row 1`
|
||||
- **根因**: 公开接口 `/api/cms/cms-contact-lead/submit` (官网联系表单,无需登录) 前端传入超长/带分隔符的手机号,直接写入 MySQL 触发截断异常
|
||||
- **影响**: 用户提交联系表单失败,销售线索丢失;公开接口易被刷
|
||||
- **修复**:
|
||||
1. `CmsContactLead.java` 实体加 JSR-303 校验: name/phone 加 @NotBlank+@Size+@Pattern,company/delivery/need/source/ip 加 @Size
|
||||
2. `CmsContactLeadServiceImpl.submit()` 加 `sanitizePhone()` 清洗逻辑: 去空格/横线/括号,仅保留 + 和数字
|
||||
3. 新增 SQL 迁移: `docs/sql/2026-07-19_cms_contact_lead_phone_resize.sql`,phone 扩到 VARCHAR(32),同步放宽 name/company/need
|
||||
|
||||
## 关联问题(未修复,需前端处理)
|
||||
- 日志中 `参数类型转换异常: 参数名=id, 传入值=NaN, 期望类型=Integer`:前端 JS 把 NaN 拼到 URL 调用 `@GetMapping("/{id}")`,需前端判空
|
||||
- `定时任务需要查询所有租户的超时订单 list = 0`:正常 INFO 日志,非错误
|
||||
|
||||
## 修改的文件
|
||||
- src/main/java/com/gxwebsoft/cms/entity/CmsContactLead.java
|
||||
- src/main/java/com/gxwebsoft/cms/service/impl/CmsContactLeadServiceImpl.java
|
||||
- docs/sql/2026-07-19_cms_contact_lead_phone_resize.sql (新增)
|
||||
@@ -1,16 +0,0 @@
|
||||
# 项目长期记忆
|
||||
|
||||
## 项目技术栈
|
||||
- Spring Boot 2.x + Spring Security 5.7.11 + MyBatis-Plus 3.4.1 + Druid + MySQL
|
||||
- 验证框架: JSR-303 (javax.validation),通过 spring-boot-starter-web 间接引入,无需额外声明
|
||||
- 多租户架构: 表普遍有 tenant_id 字段,定时任务需遍历所有租户
|
||||
- SQL 迁移文件惯例: docs/sql/YYYY-MM-DD_描述.sql
|
||||
- 实体软删除: @TableLogic + deleted 字段
|
||||
- 部署方式: Docker (cms-api 容器)
|
||||
|
||||
## 已知问题与修复
|
||||
- 2026-07-19: cms-api 报 `Data too long for column 'phone'`
|
||||
- 根因: 公开接口 /api/cms/cms-contact-lead/submit 前端传入超长/带分隔符手机号
|
||||
- 修复: CmsContactLead 实体加 @NotBlank/@Size/@Pattern;Service 加 sanitizePhone 清洗
|
||||
- SQL: docs/sql/2026-07-19_cms_contact_lead_phone_resize.sql (phone 扩到 VARCHAR(32))
|
||||
- 前端 bug: id=NaN 传入后端,需前端判空 (Number.isNaN)
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
# 汇吉采标书购买平台
|
||||
|
||||
汇吉采标书购买平台是一站式代理平台的交易出口:企业账号在此注册、通过资质审核后购买标书,平台内完成订单与支付,并把购买记录推送回一站式平台。
|
||||
|
||||
## 核心实体
|
||||
|
||||
**标书项目 (Bid Project)**:
|
||||
一条采购项目,同时也是可购买下载的标书,二者是**同一实体**(甲方确认:一个项目即一本标书)。携带项目编号、名称/分类、招标人、中标公司、中标金额与中标公告信息,以及标书价格(信息服务费)、标书附件、开售/停售时间与售卖方式。
|
||||
_Avoid_: 项目(单用), 标书(单用), tender
|
||||
|
||||
**企业账号 (Enterprise Account)**:
|
||||
买家账号,用企业名称+密码登录,须通过资质审核才能购买标书。
|
||||
_Avoid_: 用户, 会员, buyer, hjc_user
|
||||
|
||||
**资质认证 (Qualification)**:
|
||||
企业注册后提交、由平台审核的资质材料,状态为 待审核/已通过/已驳回(含驳回原因)。未通过不可下单。
|
||||
_Avoid_: 认证
|
||||
|
||||
**订单 (Order)**:
|
||||
企业购买标书的记录,含标书信息/数量/金额/购买企业,需支付后完成。
|
||||
_Avoid_: 交易, purchase
|
||||
|
||||
**信息服务费 (Service Fee)**:
|
||||
购买标书支付的金额,即「标书价格」。平台对每一本标书设定。
|
||||
_Avoid_: 标书价格, 标书费
|
||||
|
||||
## 与一站式平台的关系
|
||||
|
||||
**一站式代理平台 (One-stop Platform)**:
|
||||
上游系统,向本平台推送中标公告数据,并接收本平台推送的购买记录/订单落盘。
|
||||
_Avoid_: 甲方, 上游
|
||||
|
||||
**中标公告 (Award Announcement)**:
|
||||
项目流程走到「发布中标公告」时由一站式平台推送的公告数据,含招标人/中标公司/中标金额/公告正文/公告附件。
|
||||
_Avoid_: 公告, bulletin
|
||||
|
||||
**售卖方式 (Selling Method)**:
|
||||
标书的售卖渠道标识:1 公司财务 / 2 公众号 / 3 交易中心 / 4 政采云。
|
||||
_Avoid_: 渠道
|
||||
|
||||
**推送 (Push)**:
|
||||
本平台与一站式平台之间交换数据的动作:接收中标公告(入),并在订单支付成功后推送购买记录(出)。
|
||||
_Avoid_: 同步, 对接
|
||||
@@ -284,5 +284,3 @@ docker run -d -p 9200:9200 websoft-api
|
||||
---
|
||||
|
||||
⭐ 如果这个项目对您有帮助,请给我们一个星标!
|
||||
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
package com.wechat.pay.java.core.exception;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.wechat.pay.java.core.http.HttpRequest;
|
||||
import com.wechat.pay.java.core.util.GsonUtil;
|
||||
|
||||
/** 发送HTTP请求成功,返回异常时抛出。例如返回状态码小于200或大于等于300、返回体参数不完整。 */
|
||||
public class ServiceException extends WechatPayException {
|
||||
|
||||
private static final long serialVersionUID = -7174975090366956652L;
|
||||
|
||||
private final HttpRequest httpRequest;
|
||||
private final int httpStatusCode;
|
||||
private final String responseBody;
|
||||
private String errorCode;
|
||||
private String errorMessage;
|
||||
|
||||
/**
|
||||
* 返回状态码小于200或大于300调用
|
||||
*
|
||||
* @param httpRequest http请求
|
||||
* @param httpStatusCode http状态码
|
||||
* @param responseBody http返回体
|
||||
*/
|
||||
public ServiceException(HttpRequest httpRequest, int httpStatusCode, String responseBody) {
|
||||
super(
|
||||
String.format(
|
||||
"Wrong HttpStatusCode[%d]%nhttpResponseBody[%.1024s]\tHttpRequest[%s]",
|
||||
httpStatusCode, responseBody, httpRequest));
|
||||
this.httpRequest = httpRequest;
|
||||
this.httpStatusCode = httpStatusCode;
|
||||
this.responseBody = responseBody;
|
||||
if (responseBody != null && !responseBody.isEmpty()) {
|
||||
JsonObject jsonObject = GsonUtil.getGson().fromJson(responseBody, JsonObject.class);
|
||||
JsonElement code = jsonObject.get("code");
|
||||
JsonElement message = jsonObject.get("message");
|
||||
this.errorCode = code == null ? null : code.getAsString();
|
||||
this.errorMessage = message == null ? null : message.getAsString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取序列化版本UID
|
||||
*
|
||||
* @return UID
|
||||
*/
|
||||
public static long getSerialVersionUID() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取HTTP请求
|
||||
*
|
||||
* @return HTTP请求
|
||||
*/
|
||||
public HttpRequest getHttpRequest() {
|
||||
return httpRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取HTTP返回体
|
||||
*
|
||||
* @return HTTP返回体
|
||||
*/
|
||||
public String getResponseBody() {
|
||||
return responseBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取HTTP状态码
|
||||
*
|
||||
* @return HTTP状态码
|
||||
*/
|
||||
public int getHttpStatusCode() {
|
||||
return httpStatusCode;
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
package com.wechat.pay.java.core.http;
|
||||
|
||||
import static com.wechat.pay.java.core.http.Constant.ACCEPT;
|
||||
import static com.wechat.pay.java.core.http.Constant.AUTHORIZATION;
|
||||
import static com.wechat.pay.java.core.http.Constant.OS;
|
||||
import static com.wechat.pay.java.core.http.Constant.REQUEST_ID;
|
||||
import static com.wechat.pay.java.core.http.Constant.USER_AGENT;
|
||||
import static com.wechat.pay.java.core.http.Constant.USER_AGENT_FORMAT;
|
||||
import static com.wechat.pay.java.core.http.Constant.VERSION;
|
||||
import static com.wechat.pay.java.core.http.Constant.WECHAT_PAY_SERIAL;
|
||||
import static java.net.HttpURLConnection.HTTP_MULT_CHOICE;
|
||||
import static java.net.HttpURLConnection.HTTP_OK;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.wechat.pay.java.core.auth.Credential;
|
||||
import com.wechat.pay.java.core.auth.Validator;
|
||||
import com.wechat.pay.java.core.exception.MalformedMessageException;
|
||||
import com.wechat.pay.java.core.exception.ServiceException;
|
||||
import com.wechat.pay.java.core.exception.ValidationException;
|
||||
import com.wechat.pay.java.core.http.HttpRequest.Builder;
|
||||
import java.io.InputStream;
|
||||
|
||||
/** 请求客户端抽象基类 */
|
||||
public abstract class AbstractHttpClient implements HttpClient {
|
||||
|
||||
protected final Credential credential;
|
||||
protected final Validator validator;
|
||||
|
||||
public AbstractHttpClient(Credential credential, Validator validator) {
|
||||
this.credential = requireNonNull(credential);
|
||||
this.validator = requireNonNull(validator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> HttpResponse<T> execute(HttpRequest httpRequest, Class<T> responseClass) {
|
||||
HttpRequest innerRequest =
|
||||
new Builder()
|
||||
.url(httpRequest.getUrl())
|
||||
.httpMethod(httpRequest.getHttpMethod())
|
||||
.headers(httpRequest.getHeaders())
|
||||
.addHeader(AUTHORIZATION, getAuthorization(httpRequest))
|
||||
.addHeader(USER_AGENT, getUserAgent())
|
||||
.addHeader(WECHAT_PAY_SERIAL, getWechatPaySerial())
|
||||
.body(httpRequest.getBody())
|
||||
.build();
|
||||
OriginalResponse originalResponse = innerExecute(innerRequest);
|
||||
validateResponse(originalResponse);
|
||||
return assembleHttpResponse(originalResponse, responseClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream download(String url) {
|
||||
HttpRequest originRequest =
|
||||
new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(url).build();
|
||||
HttpRequest httpRequest =
|
||||
new HttpRequest.Builder()
|
||||
.url(url)
|
||||
.httpMethod(HttpMethod.GET)
|
||||
.addHeader(AUTHORIZATION, getAuthorization(originRequest))
|
||||
.addHeader(ACCEPT, "*/*")
|
||||
.addHeader(USER_AGENT, getUserAgent())
|
||||
.addHeader(WECHAT_PAY_SERIAL, getWechatPaySerial())
|
||||
.build();
|
||||
return innerDownload(httpRequest);
|
||||
}
|
||||
|
||||
protected abstract InputStream innerDownload(HttpRequest httpRequest);
|
||||
|
||||
protected abstract OriginalResponse innerExecute(HttpRequest httpRequest);
|
||||
|
||||
private void validateResponse(OriginalResponse originalResponse) {
|
||||
|
||||
if (isInvalidHttpCode(originalResponse.getStatusCode())) {
|
||||
throw new ServiceException(
|
||||
originalResponse.getRequest(),
|
||||
originalResponse.getStatusCode(),
|
||||
originalResponse.getBody());
|
||||
}
|
||||
|
||||
if (originalResponse.getBody() != null
|
||||
&& !originalResponse.getBody().isEmpty()
|
||||
&& !MediaType.APPLICATION_JSON.equalsWith(originalResponse.getContentType())) {
|
||||
throw new MalformedMessageException(
|
||||
String.format(
|
||||
"Unsupported content-type[%s]%nhttpRequest[%s]",
|
||||
originalResponse.getContentType(), originalResponse.getRequest()));
|
||||
}
|
||||
|
||||
if (!validator.validate(originalResponse.getHeaders(), originalResponse.getBody())) {
|
||||
String requestId = originalResponse.getHeaders().getHeader(REQUEST_ID);
|
||||
throw new ValidationException(
|
||||
String.format(
|
||||
"Validate response failed,the WechatPay signature is incorrect.%n"
|
||||
+ "Request-ID[%s]\tresponseHeader[%s]\tresponseBody[%.1024s]",
|
||||
requestId, originalResponse.getHeaders(), originalResponse.getBody()));
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isInvalidHttpCode(int httpCode) {
|
||||
return httpCode < HTTP_OK || httpCode >= HTTP_MULT_CHOICE;
|
||||
}
|
||||
|
||||
private <T> HttpResponse<T> assembleHttpResponse(
|
||||
OriginalResponse originalResponse, Class<T> responseClass) {
|
||||
return new HttpResponse.Builder<T>()
|
||||
.originalResponse(originalResponse)
|
||||
.serviceResponseType(responseClass)
|
||||
.build();
|
||||
}
|
||||
|
||||
private String getSignBody(RequestBody requestBody) {
|
||||
if (requestBody == null) {
|
||||
return "";
|
||||
}
|
||||
if (requestBody instanceof JsonRequestBody) {
|
||||
return ((JsonRequestBody) requestBody).getBody();
|
||||
}
|
||||
if (requestBody instanceof FileRequestBody) {
|
||||
return ((FileRequestBody) requestBody).getMeta();
|
||||
}
|
||||
throw new UnsupportedOperationException(
|
||||
String.format("Unsupported RequestBody Type[%s]", requestBody.getClass().getName()));
|
||||
}
|
||||
|
||||
private String getUserAgent() {
|
||||
return String.format(
|
||||
USER_AGENT_FORMAT,
|
||||
getClass().getPackage().getImplementationVersion(),
|
||||
OS,
|
||||
VERSION == null ? "Unknown" : VERSION,
|
||||
credential.getClass().getSimpleName(),
|
||||
validator.getClass().getSimpleName(),
|
||||
getHttpClientInfo());
|
||||
}
|
||||
|
||||
private String getWechatPaySerial() {
|
||||
return this.validator.getSerialNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取http客户端信息,用于User-Agent。 格式:客户端名称/版本 示例:okhttp3/4.9.3
|
||||
*
|
||||
* @return 客户端信息
|
||||
*/
|
||||
protected abstract String getHttpClientInfo();
|
||||
|
||||
private String getAuthorization(HttpRequest request) {
|
||||
return credential.getAuthorization(
|
||||
request.getUri(), request.getHttpMethod().name(), getSignBody(request.getBody()));
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
# ShopDealerReferee 绑定接口规则与索引建议
|
||||
|
||||
接口:`POST /api/shop/shop-dealer-referee`
|
||||
|
||||
## 业务规则(后端)
|
||||
|
||||
- 邀请人(dealerId)必须存在且有效:以 `shop_dealer_user` 记录存在且 `is_delete=0` 为准
|
||||
- 当前用户(userId)仅从 token 获取;若 body.userId 存在且与 token 不一致则拒绝
|
||||
- 禁止自己绑定自己:`dealerId == userId`
|
||||
- 仅首次绑定生效:若已存在(同一 tenant、同一 user、`level=1`)则直接返回成功(幂等,不改绑)
|
||||
- 记录溯源字段:`source`、`scene`
|
||||
|
||||
## 并发幂等(数据库建议)
|
||||
|
||||
建议在 `shop_dealer_referee` 增加溯源字段,并加唯一索引保证并发下不重复写入:
|
||||
|
||||
```sql
|
||||
ALTER TABLE shop_dealer_referee
|
||||
ADD COLUMN source VARCHAR(32) NULL COMMENT '来源(如 goods_share)',
|
||||
ADD COLUMN scene VARCHAR(255) NULL COMMENT '场景参数(溯源统计)';
|
||||
|
||||
-- 约束:同一 tenant 下,一个用户每个 level 只能有一条推荐关系
|
||||
ALTER TABLE shop_dealer_referee
|
||||
ADD UNIQUE KEY uk_shop_dealer_referee_tenant_user_level (tenant_id, user_id, level);
|
||||
```
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
# 套票(冻结/可用、分期释放)功能开发计划
|
||||
|
||||
## 目标
|
||||
- 为“买N送M(例如买1送4)、起售(例如20桶起售)、按月释放(例如每月释放10桶)、可用未用完叠加”的套票/权益,提供后端可配置、可发放、可释放、可消费的能力。
|
||||
|
||||
## 核心概念
|
||||
- 套票模板:按商品(goodsId)配置买赠规则、起售/起送、释放规则(每期释放数或释放期数)、首期释放时机。
|
||||
- 用户套票账户:记录总量、可用量、冻结量、已用量、已释放量;绑定订单(用于幂等与追溯)。
|
||||
- 释放计划:每期一条,到期后把冻结转可用(可用未用完自然叠加)。
|
||||
- 变更流水:发放/释放/消费等都记录流水,便于对账与排查。
|
||||
|
||||
## 关键默认规则(可在模板里改)
|
||||
- 仅赠送量进入套票账户(默认不包含“购买量”本身);如需“买20送80=总100”,可在模板设置 `includeBuyQty=true`。
|
||||
- 首期释放:默认“支付成功当日/当刻”释放(`firstReleaseMode=0`);如需“下个月同日释放”,设 `firstReleaseMode=1`。
|
||||
- 每期释放:默认按 `monthlyReleaseQty`;如配置了 `releasePeriods`,则平均分摊并处理余数。
|
||||
|
||||
## 开发步骤(建议按顺序)
|
||||
1. 需求确认与接入点确认(订单哪个节点发放、桶票如何消费/核销、退款是否回滚、释放日期规则)。
|
||||
2. 数据表设计与SQL输出(模板/账户/释放计划/流水)。
|
||||
3. 实现套票模板后台CRUD接口。
|
||||
4. 支付成功接入:在订单支付成功后发放套票账户+生成释放计划(幂等)。
|
||||
5. 定时任务释放:扫描到期释放计划,执行“冻结->可用”转账(幂等)。
|
||||
6. 消费扣减:对用户可用量做扣减(支持跨多套票账户FIFO扣减),并落流水。
|
||||
7. 测试与验收:至少覆盖(买赠计算、分期拆分、叠加逻辑、幂等、并发扣减)。
|
||||
|
||||
## 待确认点(不确认也可先按默认实现)
|
||||
- 套票数量=赠送量?还是(购买量+赠送量)?
|
||||
- “释放日期”是按支付时间的“日”还是固定每月某一天?(31号跨月如何处理?)
|
||||
- 退款/取消:是否回滚未使用的可用/冻结?已释放但未用如何处理?
|
||||
- 消费场景:在哪个业务点扣减(下单抵扣/提货核销/线下核销)?
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
-- 套票(冻结/可用、分期释放)相关表
|
||||
-- 说明:项目使用了 MyBatis-Plus 的 tenant 拦截;表内显式保留 tenant_id 字段并建议建立联合唯一索引。
|
||||
|
||||
-- 1) 套票模板(按商品配置)
|
||||
CREATE TABLE IF NOT EXISTS shop_ticket_template (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
goods_id INT NOT NULL,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
|
||||
enabled TINYINT(1) NOT NULL DEFAULT 1,
|
||||
unit_name VARCHAR(20) NOT NULL DEFAULT '桶',
|
||||
|
||||
-- 起售/起送
|
||||
min_buy_qty INT NOT NULL DEFAULT 1,
|
||||
start_send_qty INT NOT NULL DEFAULT 1,
|
||||
|
||||
-- 买赠:买1送4 => gift_multiplier=4
|
||||
gift_multiplier INT NOT NULL DEFAULT 0,
|
||||
-- 是否把购买量也计入套票总量(默认仅计入赠送量)
|
||||
include_buy_qty TINYINT(1) NOT NULL DEFAULT 0,
|
||||
|
||||
-- 释放规则:二选一
|
||||
-- A) 每期释放数量(默认每月释放10)
|
||||
monthly_release_qty INT NOT NULL DEFAULT 10,
|
||||
-- B) 总共释放多少期(若配置>0,则按期数平均分摊)
|
||||
release_periods INT NULL,
|
||||
|
||||
-- 首期释放时机:0=支付成功当刻;1=下个月同日
|
||||
first_release_mode INT NOT NULL DEFAULT 0,
|
||||
|
||||
comments VARCHAR(255) NULL,
|
||||
sort_number INT NOT NULL DEFAULT 0,
|
||||
user_id INT NULL,
|
||||
|
||||
deleted INT NOT NULL DEFAULT 0,
|
||||
tenant_id INT NOT NULL,
|
||||
create_time DATETIME NULL,
|
||||
update_time DATETIME NULL,
|
||||
|
||||
UNIQUE KEY uk_ticket_template_tenant_goods (tenant_id, goods_id),
|
||||
KEY idx_ticket_template_tenant (tenant_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 2) 用户套票账户(一次购买通常生成一条)
|
||||
CREATE TABLE IF NOT EXISTS shop_user_ticket (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
template_id INT NOT NULL,
|
||||
goods_id INT NOT NULL,
|
||||
|
||||
user_id INT NOT NULL,
|
||||
order_id INT NULL,
|
||||
order_no VARCHAR(64) NULL,
|
||||
order_goods_id INT NULL,
|
||||
|
||||
total_qty INT NOT NULL DEFAULT 0,
|
||||
available_qty INT NOT NULL DEFAULT 0,
|
||||
frozen_qty INT NOT NULL DEFAULT 0,
|
||||
used_qty INT NOT NULL DEFAULT 0,
|
||||
released_qty INT NOT NULL DEFAULT 0,
|
||||
|
||||
status INT NOT NULL DEFAULT 0,
|
||||
|
||||
deleted INT NOT NULL DEFAULT 0,
|
||||
tenant_id INT NOT NULL,
|
||||
create_time DATETIME NULL,
|
||||
update_time DATETIME NULL,
|
||||
|
||||
KEY idx_user_ticket_user (tenant_id, user_id),
|
||||
KEY idx_user_ticket_order (tenant_id, order_no),
|
||||
UNIQUE KEY uk_user_ticket_order_goods (tenant_id, template_id, order_no, order_goods_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 3) 释放计划/释放记录(每期一条,幂等执行)
|
||||
CREATE TABLE IF NOT EXISTS shop_user_ticket_release (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_ticket_id BIGINT NOT NULL,
|
||||
user_id INT NOT NULL,
|
||||
period_no INT NOT NULL,
|
||||
|
||||
release_qty INT NOT NULL,
|
||||
release_time DATETIME NOT NULL,
|
||||
|
||||
status INT NOT NULL DEFAULT 0, -- 0待释放 1已释放 2作废
|
||||
released_time DATETIME NULL,
|
||||
|
||||
tenant_id INT NOT NULL,
|
||||
create_time DATETIME NULL,
|
||||
update_time DATETIME NULL,
|
||||
|
||||
UNIQUE KEY uk_ticket_release_period (tenant_id, user_ticket_id, period_no),
|
||||
KEY idx_ticket_release_due (status, release_time),
|
||||
KEY idx_ticket_release_user (tenant_id, user_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 4) 套票变更流水(发放/释放/消费/回滚等)
|
||||
CREATE TABLE IF NOT EXISTS shop_user_ticket_log (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_ticket_id BIGINT NOT NULL,
|
||||
user_id INT NOT NULL,
|
||||
|
||||
change_type INT NOT NULL, -- 10发放 20释放 30消费 40回滚/退款
|
||||
change_available INT NOT NULL DEFAULT 0,
|
||||
change_frozen INT NOT NULL DEFAULT 0,
|
||||
change_used INT NOT NULL DEFAULT 0,
|
||||
|
||||
available_after INT NOT NULL DEFAULT 0,
|
||||
frozen_after INT NOT NULL DEFAULT 0,
|
||||
used_after INT NOT NULL DEFAULT 0,
|
||||
|
||||
order_id INT NULL,
|
||||
order_no VARCHAR(64) NULL,
|
||||
remark VARCHAR(255) NULL,
|
||||
|
||||
tenant_id INT NOT NULL,
|
||||
create_time DATETIME NULL,
|
||||
update_time DATETIME NULL,
|
||||
|
||||
KEY idx_ticket_log_user (tenant_id, user_id),
|
||||
KEY idx_ticket_log_ticket (tenant_id, user_ticket_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# 一站式推送鉴权:appKey + timestamp + sign,password 不进报文
|
||||
|
||||
汇吉采 → 一站式平台的订单推送采用 `appKey + timestamp + sign` 请求头鉴权,`sign = MD5(appKey + password + timestamp)`(小写),`password` 只作为密钥参与签名、不放入任何报文字段;一站式侧校验 appKey 匹配、timestamp 与本地时间差 ≤ ±10 分钟(防重放)、以及重算 MD5 与 sign 不区分大小写比对。原始需求文字要求把 `password` 明文加入请求头,会泄露共享密钥,本方案保留其 appKey/password/年月日时分/MD5 全部要素,仅把 password 降级为纯签名密钥,是相对原始字面的有意偏离;若一站式平台已按原始明文方案实现,兼容退路见 `docs/一站式平台推送-接口鉴权规范.md` 附录 A。理由:这是对外契约,改动成本高,且偏离点是刻意且必须记录,否则后人会「修复」回明文方案。
|
||||
@@ -0,0 +1,5 @@
|
||||
# 项目与标书为同一实体:一个项目一本标书
|
||||
|
||||
**Supersedes**: 早先「项目/标书两个实体、1 项目:N 标书」的假设——甲方已明确**项目与标书是一个东西,一个项目即一本标书**,故撤销该假设。
|
||||
|
||||
项目(Project)与标书(BidDocument)建模为**同一个实体**(`标书项目`),单表承载。一站式推送的公告类字段(公告标题/招标人/中标公司/中标金额/公告正文/公告附件)与销售类字段(标书价格/附件/开售/停售/售卖方式/needSell)都落在这一张表上,由「推送入库 + 管理后台手工增删改查」双路填充。理由:既然甲方确认一个项目仅对应一本标书,两实体之间的 1:N 关系已不存在,拆表只会增加复杂度而无对应业务收益;等未来确实出现「一项目多标书」再演进(届时把标书款从主表抽出即可,主表结构无须预埋)。
|
||||
@@ -0,0 +1,12 @@
|
||||
# H5 端(公众号内)支付采用微信 JSAPI 直接唤起
|
||||
|
||||
汇吉采移动端 H5(`hjc-h5`,在微信「公众号」内打开)的支付采用**微信 JSAPI**(`PaymentType.WECHAT` + `openid`),由后端 `WechatJsapiStrategy` 用 `wechatpay-java` 的 `JsapiServiceExtension.prepayWithRequestPayment` 直接返回前端 `wx.chooseWXPay` 所需的 `appId/timeStamp/nonceStr/package/signType/paySign`;无 `openid`(非公众号环境)时**回退 Native 扫码**展示 `codeUrl`。
|
||||
|
||||
选择理由:公众号内直接「唤起支付」免去另开微信扫二维码的操作,转化率与体验均优于 Native 扫码;后端支付组件(`PaymentRequest.openId`、`PaymentResponse.wechatJsapi`、`PaymentChannel.WECHAT_JSAPI`、`WechatPayType.JSAPI`)早已为 JSAPI 预留,只差一个策略实现,改造成本低。
|
||||
|
||||
代价/偏离:
|
||||
- **需要用户 openid**,因此引入微信**网页授权**(静默 `snsapi_base`):`/hjc/wechat/authorize` 生成授权地址,`/hjc/wechat/oauth/callback` 用 `code` 换 `openid` 后回跳 H5 并附带 `openid`。
|
||||
- **需要 `wx.config` 签名**:新增 `/hjc/wechat/jsapi-sign`(基于 `jsapi_ticket` 做 SHA1 签名),公众号配置(appId/appSecret)存于 Redis `cache{tenantId}:setting:wx-official`。
|
||||
- **不改 Native 扫码逻辑**:两者共用同一商户号/回调地址;`PaymentServiceImpl.getPaymentStrategy` 在 `WECHAT` 类型下按 `openid` 有无分流 JSAPI/Native,未破坏既有 Native 调用方。
|
||||
|
||||
兼容与说明:本方案是「带 openid 走 JSAPI,否则 Native」的弹性分流,非公众号环境(如普通浏览器/开发联调)仍可扫码支付,便于无真实公众号配置时验证。
|
||||
@@ -1,61 +0,0 @@
|
||||
# AI 模块(Ollama + RAG + 订单分析)
|
||||
|
||||
## 1. 配置
|
||||
|
||||
见 `src/main/resources/application.yml`:
|
||||
|
||||
- `ai.ollama.base-url`:主地址(例如 `https://ai-api.websoft.top`)
|
||||
- `ai.ollama.fallback-url`:备用地址(例如 `http://47.119.165.234:11434`)
|
||||
- `ai.ollama.chat-model`:对话模型(`qwen3.5:cloud`)
|
||||
- `ai.ollama.embed-model`:向量模型(`qwen3-embedding:4b`)
|
||||
|
||||
## 2. 建表(知识库)
|
||||
|
||||
执行:`docs/ai/ai_kb_tables.sql`
|
||||
|
||||
## 3. API
|
||||
|
||||
说明:所有接口默认需要登录(`@PreAuthorize("isAuthenticated()")`),并且要求能够拿到 `tenantId`(header 或登录用户)。
|
||||
|
||||
### 3.1 对话
|
||||
|
||||
- `GET /api/ai/models`:获取 Ollama 模型列表
|
||||
- `POST /api/ai/chat`:非流式对话
|
||||
- `POST /api/ai/chat/stream`:流式对话(SSE)
|
||||
- `GET /api/ai/chat/stream?prompt=...`:流式对话(SSE,适配 EventSource)
|
||||
|
||||
请求示例(非流式):
|
||||
```json
|
||||
{
|
||||
"prompt": "帮我写一个退款流程说明"
|
||||
}
|
||||
```
|
||||
|
||||
### 3.2 知识库(RAG)
|
||||
|
||||
- `POST /api/ai/kb/upload`:上传文档入库(建议 txt/md/html)
|
||||
- `POST /api/ai/kb/sync/cms`:同步 CMS 已发布文章到知识库(当前租户)
|
||||
- `POST /api/ai/kb/query`:仅检索 topK
|
||||
- `POST /api/ai/kb/ask`:检索 + 生成答案(答案要求引用 chunk_id)
|
||||
|
||||
请求示例(ask):
|
||||
```json
|
||||
{
|
||||
"question": "怎么开具发票?",
|
||||
"topK": 5
|
||||
}
|
||||
```
|
||||
|
||||
### 3.3 商城订单分析(按租户/按天)
|
||||
|
||||
- `POST /api/ai/analytics/query`:返回按天指标数据
|
||||
- `POST /api/ai/analytics/ask`:基于指标数据生成分析结论
|
||||
|
||||
请求示例(ask):
|
||||
```json
|
||||
{
|
||||
"question": "最近30天支付率有没有明显下滑?请给出原因排查建议。",
|
||||
"startDate": "2026-02-01",
|
||||
"endDate": "2026-02-27"
|
||||
}
|
||||
```
|
||||
@@ -1,39 +0,0 @@
|
||||
-- AI 知识库(RAG)建表脚本(MySQL)
|
||||
-- 说明:本项目使用 MyBatis-Plus 默认命名规则(AiKbDocument -> ai_kb_document)。
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `ai_kb_document` (
|
||||
`document_id` INT NOT NULL AUTO_INCREMENT COMMENT '文档ID',
|
||||
`title` VARCHAR(255) NULL COMMENT '标题',
|
||||
`source_type` VARCHAR(32) NULL COMMENT '来源类型:upload/cms',
|
||||
`source_id` INT NULL COMMENT '来源ID(如 cms.article_id)',
|
||||
`source_ref` VARCHAR(255) NULL COMMENT '来源引用(如文件名、文章 code)',
|
||||
`content_hash` CHAR(64) NULL COMMENT '内容hash(SHA-256),用于增量同步',
|
||||
`status` TINYINT NULL DEFAULT 0 COMMENT '状态',
|
||||
`deleted` TINYINT NULL DEFAULT 0 COMMENT '逻辑删除:0否1是',
|
||||
`tenant_id` INT NOT NULL COMMENT '租户ID',
|
||||
`update_time` DATETIME NULL COMMENT '更新时间',
|
||||
`create_time` DATETIME NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`document_id`),
|
||||
KEY `idx_ai_kb_document_tenant` (`tenant_id`),
|
||||
KEY `idx_ai_kb_document_source` (`tenant_id`, `source_type`, `source_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='AI 知识库文档';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `ai_kb_chunk` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT COMMENT '自增ID',
|
||||
`document_id` INT NOT NULL COMMENT '文档ID',
|
||||
`chunk_id` VARCHAR(64) NOT NULL COMMENT 'chunk 唯一ID(用于引用)',
|
||||
`chunk_index` INT NULL COMMENT 'chunk 序号',
|
||||
`title` VARCHAR(255) NULL COMMENT '标题(冗余,便于展示)',
|
||||
`content` LONGTEXT NULL COMMENT 'chunk 文本',
|
||||
`content_hash` CHAR(64) NULL COMMENT 'chunk 内容hash',
|
||||
`embedding` LONGTEXT NULL COMMENT 'embedding(JSON数组)',
|
||||
`embedding_norm` DOUBLE NULL COMMENT 'embedding L2 范数',
|
||||
`deleted` TINYINT NULL DEFAULT 0 COMMENT '逻辑删除:0否1是',
|
||||
`tenant_id` INT NOT NULL COMMENT '租户ID',
|
||||
`create_time` DATETIME NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_ai_kb_chunk_chunk_id` (`chunk_id`),
|
||||
KEY `idx_ai_kb_chunk_tenant` (`tenant_id`),
|
||||
KEY `idx_ai_kb_chunk_document` (`document_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='AI 知识库 chunk';
|
||||
|
||||
@@ -1,230 +0,0 @@
|
||||
# 客资管理系统实施总结
|
||||
|
||||
> 创建时间:2026-04-14
|
||||
> 作者:AI助手
|
||||
> 状态:实施完成
|
||||
|
||||
---
|
||||
|
||||
## 一、需求概述
|
||||
|
||||
根据客户需求,实现一个完整的**客资管理系统**,具备以下功能:
|
||||
|
||||
| 功能 | 描述 |
|
||||
|------|------|
|
||||
| 客资派单 | 管理员可以直接派单客资给业务员 |
|
||||
| 全民推荐 | 任何人都可以推荐客户赚取推荐费 |
|
||||
| 推荐人报备 | 注册用户可以报备客户(推荐人报备) |
|
||||
| 实时跟进 | 实时查看跟进情况和成交状态 |
|
||||
| 多管理员 | 支持多管理员设置 |
|
||||
| 数据统计导出 | 生成统计报表功能 |
|
||||
|
||||
---
|
||||
|
||||
## 二、实施成果
|
||||
|
||||
### 2.1 Java后端 (`/Users/gxwebsoft/JAVA/mp-java`)
|
||||
|
||||
#### 数据库变更
|
||||
**文件**: `docs/sql/customer_lead_system.sql`
|
||||
|
||||
| 表名 | 说明 |
|
||||
|------|------|
|
||||
| `cms_contact_lead` | 扩展现有客资表,添加派单、推荐人等字段 |
|
||||
| `lead_dispatch` | 派单记录表 |
|
||||
| `lead_follow_log` | 跟进记录表 |
|
||||
| `lead_referral` | 推荐人关系表(全民推荐) |
|
||||
| `sys_user_role_extend` | 用户角色扩展表(多管理员) |
|
||||
| `lead_statistics` | 数据统计汇总表 |
|
||||
| `lead_referral_settlement` | 推荐费结算记录表 |
|
||||
| `v_lead_full_info` | 客资完整信息视图 |
|
||||
|
||||
#### 新增实体类
|
||||
| 文件路径 | 说明 |
|
||||
|----------|------|
|
||||
| `cms/entity/CustomerLeadEntity.java` | 客资管理扩展实体 |
|
||||
| `cms/entity/LeadDispatch.java` | 派单记录实体 |
|
||||
| `cms/entity/LeadFollowLog.java` | 跟进记录实体 |
|
||||
| `cms/entity/LeadReferral.java` | 推荐关系实体 |
|
||||
| `cms/entity/LeadStatistics.java` | 统计实体 |
|
||||
| `common/system/entity/UserRoleExtend.java` | 用户角色扩展实体 |
|
||||
|
||||
#### 新增参数类
|
||||
| 文件路径 | 说明 |
|
||||
|----------|------|
|
||||
| `cms/param/CustomerLeadParam.java` | 客资查询参数 |
|
||||
| `cms/param/LeadDispatchParam.java` | 派单请求参数 |
|
||||
| `cms/param/LeadFollowParam.java` | 跟进请求参数 |
|
||||
| `cms/param/LeadReferralParam.java` | 推荐人报备参数 |
|
||||
|
||||
#### 新增Mapper
|
||||
| 文件路径 | 说明 |
|
||||
|----------|------|
|
||||
| `cms/mapper/CustomerLeadMapper.java` | 客资管理Mapper |
|
||||
| `cms/mapper/LeadDispatchMapper.java` | 派单记录Mapper |
|
||||
| `cms/mapper/LeadFollowLogMapper.java` | 跟进记录Mapper |
|
||||
| `cms/mapper/LeadReferralMapper.java` | 推荐关系Mapper |
|
||||
|
||||
#### 新增Service
|
||||
| 文件路径 | 说明 |
|
||||
|----------|------|
|
||||
| `cms/service/CustomerLeadService.java` | 客资管理服务接口 |
|
||||
| `cms/service/impl/CustomerLeadServiceImpl.java` | 客资管理服务实现 |
|
||||
| `cms/service/LeadReferralService.java` | 推荐人服务接口 |
|
||||
| `cms/service/impl/LeadReferralServiceImpl.java` | 推荐人服务实现 |
|
||||
|
||||
#### 新增Controller
|
||||
| 文件路径 | 说明 |
|
||||
|----------|------|
|
||||
| `cms/controller/CustomerLeadController.java` | 客资管理控制器 |
|
||||
| `cms/controller/LeadReferralController.java` | 推荐人控制器 |
|
||||
|
||||
#### API端点
|
||||
| 接口 | 方法 | 说明 |
|
||||
|------|------|------|
|
||||
| `/customer/lead/page` | GET | 分页查询客资列表 |
|
||||
| `/customer/lead/detail/{leadId}` | GET | 获取客资详情 |
|
||||
| `/customer/lead/create` | POST | 创建客资 |
|
||||
| `/customer/lead/update` | PUT | 更新客资信息 |
|
||||
| `/customer/lead/status/{leadId}` | PUT | 更新客资状态 |
|
||||
| `/customer/lead/dispatch` | POST | 派单给业务员 |
|
||||
| `/customer/lead/dispatch/batch` | POST | 批量派单 |
|
||||
| `/customer/lead/follow` | POST | 添加跟进记录 |
|
||||
| `/customer/lead/follow/history/{leadId}` | GET | 获取跟进历史 |
|
||||
| `/customer/lead/statistics` | GET | 获取统计数据 |
|
||||
| `/customer/lead/export` | GET | 导出客资数据 |
|
||||
| `/customer/lead/unassigned` | GET | 获取未分配客资 |
|
||||
| `/lead/referral/anonymous` | POST | 匿名用户报备 |
|
||||
| `/lead/referral/user` | POST | 注册用户报备 |
|
||||
| `/lead/referral/page` | GET | 推荐人推荐记录 |
|
||||
| `/lead/referral/stats/{userId}` | GET | 推荐人统计 |
|
||||
|
||||
---
|
||||
|
||||
### 2.2 Vue后台管理端 (`/Users/gxwebsoft/VUE/mp-vue`)
|
||||
|
||||
#### 新增API
|
||||
| 文件路径 | 说明 |
|
||||
|----------|------|
|
||||
| `api/cms/customerLead/model.ts` | 类型定义 |
|
||||
| `api/cms/customerLead/index.ts` | API接口 |
|
||||
|
||||
#### 新增页面
|
||||
| 文件路径 | 说明 |
|
||||
|----------|------|
|
||||
| `views/cms/customerLead/index.vue` | 客资管理列表页面 |
|
||||
|
||||
**功能特性**:
|
||||
- 客资列表(分页、筛选、搜索)
|
||||
- 统计卡片(总客资、待跟进、已成交、成交金额)
|
||||
- 新增/编辑客资
|
||||
- 派单给业务员(支持批量派单)
|
||||
- 添加跟进记录
|
||||
- 查看跟进历史
|
||||
- 客资详情弹窗
|
||||
|
||||
---
|
||||
|
||||
### 2.3 微信小程序端 (`/Users/gxwebsoft/VUE/template-10582`)
|
||||
|
||||
#### 新增API
|
||||
| 文件路径 | 说明 |
|
||||
|----------|------|
|
||||
| `api/shop/referral.ts` | 推荐人API |
|
||||
|
||||
#### 新增页面
|
||||
| 文件路径 | 说明 |
|
||||
|----------|------|
|
||||
| `dealer/referral/index.config.ts` | 页面配置 |
|
||||
| `dealer/referral/index.tsx` | 推荐人报备页面 |
|
||||
| `dealer/referral/index.scss` | 页面样式 |
|
||||
|
||||
**功能特性**:
|
||||
- 推荐人统计(总推荐、待确认、有效、待结算金额)
|
||||
- 推荐新客户表单
|
||||
- 推荐记录列表
|
||||
- 状态追踪
|
||||
|
||||
#### 首页入口
|
||||
在分销商首页 `/dealer/index.tsx` 添加了「推荐客户」入口
|
||||
|
||||
---
|
||||
|
||||
## 三、数据字典
|
||||
|
||||
### 客资状态
|
||||
| 值 | 文本 | 说明 |
|
||||
|----|------|------|
|
||||
| 0 | 待跟进 | 新客资,未分配或未联系 |
|
||||
| 1 | 跟进中 | 正在跟进 |
|
||||
| 2 | 已成交 | 客户已付款 |
|
||||
| 3 | 无效 | 商机流失 |
|
||||
|
||||
### 客资来源
|
||||
| 值 | 文本 | 说明 |
|
||||
|----|------|------|
|
||||
| form | 表单 | 网站/小程序表单提交 |
|
||||
| website | 网站 | 网站表单 |
|
||||
| miniapp | 小程序 | 小程序表单 |
|
||||
| referral | 推荐人 | 推荐人报备 |
|
||||
| admin | 管理员录入 | 后台手动添加 |
|
||||
|
||||
### 跟进方式
|
||||
| 值 | 文本 | 说明 |
|
||||
|----|------|------|
|
||||
| 1 | 电话 | 电话沟通 |
|
||||
| 2 | 微信 | 微信联系 |
|
||||
| 3 | 上门 | 上门拜访 |
|
||||
| 4 | 短信 | 短信通知 |
|
||||
| 5 | 其他 | 其他方式 |
|
||||
|
||||
### 推荐状态
|
||||
| 值 | 文本 | 说明 |
|
||||
|----|------|------|
|
||||
| 0 | 待确认 | 等待管理员确认 |
|
||||
| 1 | 有效 | 推荐有效 |
|
||||
| 2 | 无效 | 推荐无效 |
|
||||
| 3 | 已结算 | 推荐费已结算 |
|
||||
|
||||
---
|
||||
|
||||
## 四、部署说明
|
||||
|
||||
### 4.1 数据库部署
|
||||
```bash
|
||||
# 执行SQL脚本
|
||||
mysql -u root -p your_database < docs/sql/customer_lead_system.sql
|
||||
```
|
||||
|
||||
### 4.2 后端部署
|
||||
1. 重新编译Java项目
|
||||
2. 部署到应用服务器
|
||||
3. 确保Mapper XML文件正确部署
|
||||
|
||||
### 4.3 前端部署
|
||||
1. Vue后台:`npm run build` 部署dist目录
|
||||
2. 小程序:使用Taro构建并上传
|
||||
|
||||
---
|
||||
|
||||
## 五、后续优化建议
|
||||
|
||||
1. **权限细化**:根据实际业务需求,配置细粒度的按钮权限
|
||||
2. **数据看板**:开发可视化数据大屏
|
||||
3. **消息通知**:接入微信模板消息,实时推送派单/跟进通知
|
||||
4. **小程序入口**:在首页增加「全民推荐」独立入口(非分销商专属)
|
||||
5. **推荐海报**:生成带参数的推广海报,方便分享传播
|
||||
6. **佣金结算**:完善佣金提现流程
|
||||
|
||||
---
|
||||
|
||||
## 六、注意事项
|
||||
|
||||
1. **SQL执行顺序**:先执行数据库变更SQL,再部署后端代码
|
||||
2. **Mapper XML**:需要创建对应的Mapper XML文件
|
||||
3. **权限配置**:在后台管理系统中配置对应的菜单和按钮权限
|
||||
4. **推荐费配置**:可后续在配置表中添加推荐费比例等配置项
|
||||
|
||||
---
|
||||
|
||||
*文档生成时间:2026-04-14*
|
||||
@@ -1,459 +0,0 @@
|
||||
# 客户跟进7步骤后端实现指南
|
||||
|
||||
## 📋 概述
|
||||
|
||||
本指南详细说明如何实现客户跟进7个步骤功能的后端代码,包括数据库设计、Java后端实现和API接口。
|
||||
|
||||
## 🗄️ 数据库设计
|
||||
|
||||
### 1. 修改 credit_mp_customer 表结构
|
||||
|
||||
```sql
|
||||
-- 为第5-7步添加字段(第1-4步基础字段已存在;如未包含审核时间/审核人字段,请先补齐 step1-4 的 approved_at/approved_by)
|
||||
-- 参考:docs/sql/credit_mp_customer_step1_4_approval_columns.sql
|
||||
-- 第5步:合同签订
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_submitted TINYINT DEFAULT 0 COMMENT '是否已提交';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_submitted_at VARCHAR(255) COMMENT '提交时间';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_contracts TEXT COMMENT '合同信息JSON数组';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_need_approval TINYINT DEFAULT 1 COMMENT '是否需要审核';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_approved TINYINT DEFAULT 0 COMMENT '是否审核通过';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_approved_at VARCHAR(255) COMMENT '审核时间';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_approved_by BIGINT COMMENT '审核人ID';
|
||||
|
||||
-- 第6步:订单回款
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_submitted TINYINT DEFAULT 0 COMMENT '是否已提交';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_submitted_at VARCHAR(255) COMMENT '提交时间';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_payment_records TEXT COMMENT '财务录入的回款记录JSON数组';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_expected_payments TEXT COMMENT '预计回款JSON数组';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_need_approval TINYINT DEFAULT 1 COMMENT '是否需要审核';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_approved TINYINT DEFAULT 0 COMMENT '是否审核通过';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_approved_at VARCHAR(255) COMMENT '审核时间';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_approved_by BIGINT COMMENT '审核人ID';
|
||||
|
||||
-- 第7步:电话回访
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_submitted TINYINT DEFAULT 0 COMMENT '是否已提交';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_submitted_at VARCHAR(255) COMMENT '提交时间';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_visit_records TEXT COMMENT '回访记录JSON数组';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_need_approval TINYINT DEFAULT 1 COMMENT '是否需要审核';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_approved TINYINT DEFAULT 0 COMMENT '是否审核通过';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_approved_at VARCHAR(255) COMMENT '审核时间';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_approved_by BIGINT COMMENT '审核人ID';
|
||||
|
||||
-- 添加流程结束相关字段
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_process_ended TINYINT DEFAULT 0 COMMENT '流程是否已结束';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_process_end_time VARCHAR(255) COMMENT '流程结束时间';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_process_end_reason TEXT COMMENT '流程结束原因';
|
||||
```
|
||||
|
||||
### 2. 创建审核记录表(可选)
|
||||
|
||||
```sql
|
||||
CREATE TABLE credit_follow_approval (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
customer_id BIGINT NOT NULL COMMENT '客户ID',
|
||||
step TINYINT NOT NULL COMMENT '步骤号',
|
||||
approved TINYINT NOT NULL COMMENT '是否通过',
|
||||
remark TEXT COMMENT '审核备注',
|
||||
approved_by BIGINT COMMENT '审核人ID',
|
||||
approved_at VARCHAR(255) COMMENT '审核时间',
|
||||
created_at VARCHAR(255) COMMENT '创建时间',
|
||||
INDEX idx_customer_step (customer_id, step),
|
||||
INDEX idx_approved_by (approved_by)
|
||||
) COMMENT='跟进步骤审核记录';
|
||||
```
|
||||
|
||||
## ☕ Java后端实现
|
||||
|
||||
### 1. 实体类修改
|
||||
|
||||
```java
|
||||
// CreditMpCustomer.java 添加字段
|
||||
public class CreditMpCustomer {
|
||||
// ... 现有字段
|
||||
|
||||
// 第5步字段
|
||||
private Integer followStep5Submitted;
|
||||
private String followStep5SubmittedAt;
|
||||
private String followStep5Contracts;
|
||||
private Integer followStep5NeedApproval;
|
||||
private Integer followStep5Approved;
|
||||
private String followStep5ApprovedAt;
|
||||
private Long followStep5ApprovedBy;
|
||||
|
||||
// 第6步字段
|
||||
private Integer followStep6Submitted;
|
||||
private String followStep6SubmittedAt;
|
||||
private String followStep6PaymentRecords;
|
||||
private String followStep6ExpectedPayments;
|
||||
private Integer followStep6NeedApproval;
|
||||
private Integer followStep6Approved;
|
||||
private String followStep6ApprovedAt;
|
||||
private Long followStep6ApprovedBy;
|
||||
|
||||
// 第7步字段
|
||||
private Integer followStep7Submitted;
|
||||
private String followStep7SubmittedAt;
|
||||
private String followStep7VisitRecords;
|
||||
private Integer followStep7NeedApproval;
|
||||
private Integer followStep7Approved;
|
||||
private String followStep7ApprovedAt;
|
||||
private Long followStep7ApprovedBy;
|
||||
|
||||
// 流程结束字段
|
||||
private Integer followProcessEnded;
|
||||
private String followProcessEndTime;
|
||||
private String followProcessEndReason;
|
||||
|
||||
// getter/setter 方法...
|
||||
}
|
||||
```
|
||||
|
||||
### 2. DTO类创建
|
||||
|
||||
```java
|
||||
// FollowStepApprovalDTO.java
|
||||
@Data
|
||||
public class FollowStepApprovalDTO {
|
||||
private Long customerId;
|
||||
private Integer step;
|
||||
private Boolean approved;
|
||||
private String remark;
|
||||
}
|
||||
|
||||
// BatchFollowStepApprovalDTO.java
|
||||
@Data
|
||||
public class BatchFollowStepApprovalDTO {
|
||||
private List<FollowStepApprovalDTO> approvals;
|
||||
}
|
||||
|
||||
// FollowStatisticsDTO.java
|
||||
@Data
|
||||
public class FollowStatisticsDTO {
|
||||
private Integer totalSteps;
|
||||
private Integer completedSteps;
|
||||
private Integer currentStep;
|
||||
private Double progress;
|
||||
private List<FollowStepDetailDTO> stepDetails;
|
||||
}
|
||||
|
||||
// FollowStepDetailDTO.java
|
||||
@Data
|
||||
public class FollowStepDetailDTO {
|
||||
private Integer step;
|
||||
private String title;
|
||||
private String status; // pending, submitted, approved, rejected
|
||||
private String submittedAt;
|
||||
private String approvedAt;
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Service层实现
|
||||
|
||||
```java
|
||||
// CreditMpCustomerServiceImpl.java 添加方法
|
||||
|
||||
@Service
|
||||
public class CreditMpCustomerServiceImpl implements CreditMpCustomerService {
|
||||
|
||||
/**
|
||||
* 审核跟进步骤
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void approveFollowStep(FollowStepApprovalDTO dto) {
|
||||
CreditMpCustomer customer = getById(dto.getCustomerId());
|
||||
if (customer == null) {
|
||||
throw new ServiceException("客户不存在");
|
||||
}
|
||||
|
||||
// 验证步骤是否已提交
|
||||
if (!isStepSubmitted(customer, dto.getStep())) {
|
||||
throw new ServiceException("该步骤尚未提交,无法审核");
|
||||
}
|
||||
|
||||
// 更新审核状态
|
||||
updateStepApproval(customer, dto);
|
||||
|
||||
// 记录审核日志
|
||||
saveApprovalLog(dto);
|
||||
|
||||
// 如果审核通过,更新客户步骤状态
|
||||
if (dto.getApproved()) {
|
||||
updateCustomerStep(customer, dto.getStep());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量审核跟进步骤
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void batchApproveFollowSteps(BatchFollowStepApprovalDTO dto) {
|
||||
for (FollowStepApprovalDTO approval : dto.getApprovals()) {
|
||||
approveFollowStep(approval);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取待审核的跟进步骤列表
|
||||
*/
|
||||
@Override
|
||||
public List<PendingApprovalStepVO> getPendingApprovalSteps(FollowStepQueryDTO query) {
|
||||
return baseMapper.selectPendingApprovalSteps(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户跟进统计
|
||||
*/
|
||||
@Override
|
||||
public FollowStatisticsDTO getFollowStatistics(Long customerId) {
|
||||
CreditMpCustomer customer = getById(customerId);
|
||||
if (customer == null) {
|
||||
throw new ServiceException("客户不存在");
|
||||
}
|
||||
|
||||
FollowStatisticsDTO statistics = new FollowStatisticsDTO();
|
||||
statistics.setTotalSteps(7);
|
||||
|
||||
List<FollowStepDetailDTO> stepDetails = new ArrayList<>();
|
||||
int completedSteps = 0;
|
||||
int currentStep = 1;
|
||||
|
||||
for (int i = 1; i <= 7; i++) {
|
||||
FollowStepDetailDTO detail = getStepDetail(customer, i);
|
||||
stepDetails.add(detail);
|
||||
|
||||
if ("approved".equals(detail.getStatus())) {
|
||||
completedSteps++;
|
||||
currentStep = i + 1;
|
||||
} else if ("submitted".equals(detail.getStatus()) && currentStep == 1) {
|
||||
currentStep = i;
|
||||
}
|
||||
}
|
||||
|
||||
statistics.setCompletedSteps(completedSteps);
|
||||
statistics.setCurrentStep(Math.min(currentStep, 7));
|
||||
statistics.setProgress((double) completedSteps / 7 * 100);
|
||||
statistics.setStepDetails(stepDetails);
|
||||
|
||||
return statistics;
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束客户跟进流程
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void endFollowProcess(Long customerId, String reason) {
|
||||
CreditMpCustomer customer = getById(customerId);
|
||||
if (customer == null) {
|
||||
throw new ServiceException("客户不存在");
|
||||
}
|
||||
|
||||
customer.setFollowProcessEnded(1);
|
||||
customer.setFollowProcessEndTime(DateUtil.formatDateTime(new Date()));
|
||||
customer.setFollowProcessEndReason(reason);
|
||||
|
||||
updateById(customer);
|
||||
}
|
||||
|
||||
// 私有辅助方法...
|
||||
private boolean isStepSubmitted(CreditMpCustomer customer, Integer step) {
|
||||
switch (step) {
|
||||
case 1: return customer.getFollowStep1Submitted() == 1;
|
||||
case 2: return customer.getFollowStep2Submitted() == 1;
|
||||
// ... 其他步骤
|
||||
case 7: return customer.getFollowStep7Submitted() == 1;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateStepApproval(CreditMpCustomer customer, FollowStepApprovalDTO dto) {
|
||||
String currentTime = DateUtil.formatDateTime(new Date());
|
||||
Long currentUserId = SecurityFrameworkUtils.getLoginUserId();
|
||||
|
||||
switch (dto.getStep()) {
|
||||
case 5:
|
||||
customer.setFollowStep5Approved(dto.getApproved() ? 1 : 0);
|
||||
customer.setFollowStep5ApprovedAt(currentTime);
|
||||
customer.setFollowStep5ApprovedBy(currentUserId);
|
||||
break;
|
||||
case 6:
|
||||
customer.setFollowStep6Approved(dto.getApproved() ? 1 : 0);
|
||||
customer.setFollowStep6ApprovedAt(currentTime);
|
||||
customer.setFollowStep6ApprovedBy(currentUserId);
|
||||
break;
|
||||
case 7:
|
||||
customer.setFollowStep7Approved(dto.getApproved() ? 1 : 0);
|
||||
customer.setFollowStep7ApprovedAt(currentTime);
|
||||
customer.setFollowStep7ApprovedBy(currentUserId);
|
||||
break;
|
||||
}
|
||||
|
||||
updateById(customer);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Controller层实现
|
||||
|
||||
```java
|
||||
// CreditMpCustomerController.java 添加接口
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/credit/credit-mp-customer")
|
||||
public class CreditMpCustomerController {
|
||||
|
||||
@PostMapping("/approve-follow-step")
|
||||
@OperLog(title = "审核跟进步骤", businessType = BusinessType.UPDATE)
|
||||
public R<Void> approveFollowStep(@RequestBody FollowStepApprovalDTO dto) {
|
||||
creditMpCustomerService.approveFollowStep(dto);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/batch-approve-follow-steps")
|
||||
@OperLog(title = "批量审核跟进步骤", businessType = BusinessType.UPDATE)
|
||||
public R<Void> batchApproveFollowSteps(@RequestBody BatchFollowStepApprovalDTO dto) {
|
||||
creditMpCustomerService.batchApproveFollowSteps(dto);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/pending-approval-steps")
|
||||
@OperLog(title = "获取待审核跟进步骤", businessType = BusinessType.SELECT)
|
||||
public R<List<PendingApprovalStepVO>> getPendingApprovalSteps(FollowStepQueryDTO query) {
|
||||
List<PendingApprovalStepVO> list = creditMpCustomerService.getPendingApprovalSteps(query);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@GetMapping("/follow-statistics/{customerId}")
|
||||
@OperLog(title = "获取客户跟进统计", businessType = BusinessType.SELECT)
|
||||
public R<FollowStatisticsDTO> getFollowStatistics(@PathVariable Long customerId) {
|
||||
FollowStatisticsDTO statistics = creditMpCustomerService.getFollowStatistics(customerId);
|
||||
return R.ok(statistics);
|
||||
}
|
||||
|
||||
@PostMapping("/end-follow-process")
|
||||
@OperLog(title = "结束客户跟进流程", businessType = BusinessType.UPDATE)
|
||||
public R<Void> endFollowProcess(@RequestBody EndFollowProcessDTO dto) {
|
||||
creditMpCustomerService.endFollowProcess(dto.getCustomerId(), dto.getReason());
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 5. Mapper层SQL
|
||||
|
||||
```xml
|
||||
<!-- CreditMpCustomerMapper.xml 添加查询方法 -->
|
||||
|
||||
<select id="selectPendingApprovalSteps" resultType="com.your.package.PendingApprovalStepVO">
|
||||
SELECT
|
||||
c.id as customerId,
|
||||
c.to_user as customerName,
|
||||
5 as step,
|
||||
'合同签订' as stepTitle,
|
||||
c.follow_step5_submitted_at as submittedAt,
|
||||
u.real_name as submittedBy,
|
||||
c.follow_step5_contracts as content
|
||||
FROM credit_mp_customer c
|
||||
LEFT JOIN sys_user u ON c.user_id = u.user_id
|
||||
WHERE c.follow_step5_submitted = 1
|
||||
AND c.follow_step5_approved = 0
|
||||
AND c.deleted = 0
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
c.id as customerId,
|
||||
c.to_user as customerName,
|
||||
6 as step,
|
||||
'订单回款' as stepTitle,
|
||||
c.follow_step6_submitted_at as submittedAt,
|
||||
u.real_name as submittedBy,
|
||||
c.follow_step6_expected_payments as content
|
||||
FROM credit_mp_customer c
|
||||
LEFT JOIN sys_user u ON c.user_id = u.user_id
|
||||
WHERE c.follow_step6_submitted = 1
|
||||
AND c.follow_step6_approved = 0
|
||||
AND c.deleted = 0
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
c.id as customerId,
|
||||
c.to_user as customerName,
|
||||
7 as step,
|
||||
'电话回访' as stepTitle,
|
||||
c.follow_step7_submitted_at as submittedAt,
|
||||
u.real_name as submittedBy,
|
||||
c.follow_step7_visit_records as content
|
||||
FROM credit_mp_customer c
|
||||
LEFT JOIN sys_user u ON c.user_id = u.user_id
|
||||
WHERE c.follow_step7_submitted = 1
|
||||
AND c.follow_step7_approved = 0
|
||||
AND c.deleted = 0
|
||||
|
||||
<if test="step != null">
|
||||
HAVING step = #{step}
|
||||
</if>
|
||||
<if test="customerId != null">
|
||||
HAVING customerId = #{customerId}
|
||||
</if>
|
||||
ORDER BY submittedAt DESC
|
||||
</select>
|
||||
```
|
||||
|
||||
## 🔧 业务逻辑说明
|
||||
|
||||
### 1. 步骤解锁机制
|
||||
- 第一步始终可用
|
||||
- 后续步骤需要前一步审核通过才能进行
|
||||
- 前端通过 `canEnterStep` 逻辑控制
|
||||
|
||||
### 2. 审核流程
|
||||
- 步骤提交后设置 `needApproval = 1`
|
||||
- 管理员在后台审核
|
||||
- 审核通过后设置 `approved = 1` 并更新时间
|
||||
|
||||
### 3. 数据格式
|
||||
- 所有复杂数据使用JSON格式存储
|
||||
- 文件上传返回URL,存储在JSON数组中
|
||||
- 时间统一使用 `YYYY-MM-DD HH:mm:ss` 格式
|
||||
|
||||
### 4. 权限控制
|
||||
- 销售只能提交和查看自己的客户
|
||||
- 管理员可以审核所有步骤
|
||||
- 财务人员可以录入第6步回款数据
|
||||
|
||||
## 📱 前端集成
|
||||
|
||||
前端代码已经完成,包括:
|
||||
- 7个步骤的完整页面
|
||||
- 步骤状态显示和跳转逻辑
|
||||
- 数据提交和验证
|
||||
- 客户详情页面的汇总显示
|
||||
|
||||
## 🚀 部署步骤
|
||||
|
||||
1. 执行数据库迁移脚本
|
||||
2. 部署Java后端代码
|
||||
3. 更新前端API调用
|
||||
4. 测试完整流程
|
||||
5. 配置权限和审核流程
|
||||
|
||||
## 📝 注意事项
|
||||
|
||||
1. **数据备份**:执行数据库变更前请备份
|
||||
2. **权限配置**:确保各角色权限正确配置
|
||||
3. **文件上传**:确认文件上传服务正常
|
||||
4. **审核流程**:测试审核流程的完整性
|
||||
5. **性能优化**:大量数据时考虑分页和索引优化
|
||||
|
||||
## 🔄 后续扩展
|
||||
|
||||
可以考虑的功能:
|
||||
- 跟进模板和标准化流程
|
||||
- 自动提醒和通知
|
||||
- 数据统计和报表
|
||||
- 跟进效率分析
|
||||
- 客户满意度评估
|
||||
@@ -1,19 +0,0 @@
|
||||
-- 应用配置表
|
||||
CREATE TABLE app_config (
|
||||
config_id INT PRIMARY KEY AUTO_INCREMENT COMMENT '配置ID',
|
||||
website_id INT NOT NULL COMMENT '应用ID',
|
||||
config_key VARCHAR(100) NOT NULL COMMENT '配置键',
|
||||
config_value TEXT NOT NULL COMMENT '配置值(JSON或字符串)',
|
||||
config_type VARCHAR(50) NOT NULL DEFAULT 'general' COMMENT '配置类型:general/api/callback/wechat/payment/git等',
|
||||
is_encrypted TINYINT DEFAULT 0 COMMENT '是否加密 0否 1是',
|
||||
is_secret TINYINT DEFAULT 0 COMMENT '是否敏感信息 0否 1是',
|
||||
description VARCHAR(500) DEFAULT '' COMMENT '配置说明',
|
||||
sort_number INT DEFAULT 0 COMMENT '排序号',
|
||||
tenant_id BIGINT NOT NULL DEFAULT 0 COMMENT '租户id',
|
||||
created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
updated_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
deleted TINYINT DEFAULT 0 COMMENT '是否删除 0否 1是',
|
||||
UNIQUE KEY uk_website_key (website_id, config_key, deleted),
|
||||
INDEX idx_website_type (website_id, config_type),
|
||||
INDEX idx_tenant (tenant_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用配置表';
|
||||
@@ -1,124 +0,0 @@
|
||||
-- =====================================================================
|
||||
-- 检查 gxwebsoft_core 库缺失的系统表(sys_ 前缀)
|
||||
-- 用途:代码已把所有 @TableName / Mapper SQL 指向 gxwebsoft_core.sys_xxx,
|
||||
-- 本脚本用于确认 gxwebsoft_core 库里这 31 张系统表是否都已建好。
|
||||
-- 用法:在能访问 gxwebsoft_core 的 MySQL 连接里执行。
|
||||
-- =====================================================================
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- 方式一(推荐):一次性列出「缺失的表」。结果集为空 = 全部齐全。
|
||||
-- ---------------------------------------------------------------------
|
||||
SELECT t.table_name AS missing_table
|
||||
FROM (
|
||||
SELECT 'sys_company' AS table_name UNION ALL
|
||||
SELECT 'sys_company_comment' UNION ALL
|
||||
SELECT 'sys_company_content' UNION ALL
|
||||
SELECT 'sys_company_git' UNION ALL
|
||||
SELECT 'sys_company_parameter' UNION ALL
|
||||
SELECT 'sys_company_url' UNION ALL
|
||||
SELECT 'sys_dict' UNION ALL
|
||||
SELECT 'sys_dict_data' UNION ALL
|
||||
SELECT 'sys_dictionary' UNION ALL
|
||||
SELECT 'sys_dictionary_data' UNION ALL
|
||||
SELECT 'sys_domain' UNION ALL
|
||||
SELECT 'sys_email_record' UNION ALL
|
||||
SELECT 'sys_file_record' UNION ALL
|
||||
SELECT 'sys_login_record' UNION ALL
|
||||
SELECT 'sys_menu' UNION ALL
|
||||
SELECT 'sys_operation_record' UNION ALL
|
||||
SELECT 'sys_organization' UNION ALL
|
||||
SELECT 'sys_payment' UNION ALL
|
||||
SELECT 'sys_plug' UNION ALL
|
||||
SELECT 'sys_role' UNION ALL
|
||||
SELECT 'sys_role_menu' UNION ALL
|
||||
SELECT 'sys_setting' UNION ALL
|
||||
SELECT 'sys_tenant' UNION ALL
|
||||
SELECT 'sys_user' UNION ALL
|
||||
SELECT 'sys_user_balance_log' UNION ALL
|
||||
SELECT 'sys_user_collection' UNION ALL
|
||||
SELECT 'sys_user_file' UNION ALL
|
||||
SELECT 'sys_user_referee' UNION ALL
|
||||
SELECT 'sys_user_role' UNION ALL
|
||||
SELECT 'sys_user_role_extend' UNION ALL
|
||||
SELECT 'sys_user_verify'
|
||||
) t
|
||||
LEFT JOIN information_schema.tables ist
|
||||
ON ist.table_schema = 'gxwebsoft_core'
|
||||
AND ist.table_name = t.table_name
|
||||
WHERE ist.table_name IS NULL
|
||||
ORDER BY t.table_name;
|
||||
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- 方式二:逐张列出状态(EXISTS / MISSING),一目了然看全貌。
|
||||
-- ---------------------------------------------------------------------
|
||||
SELECT
|
||||
t.table_name,
|
||||
CASE WHEN ist.table_name IS NULL THEN 'MISSING' ELSE 'EXISTS' END AS status
|
||||
FROM (
|
||||
SELECT 'sys_company' AS table_name UNION ALL
|
||||
SELECT 'sys_company_comment' UNION ALL
|
||||
SELECT 'sys_company_content' UNION ALL
|
||||
SELECT 'sys_company_git' UNION ALL
|
||||
SELECT 'sys_company_parameter' UNION ALL
|
||||
SELECT 'sys_company_url' UNION ALL
|
||||
SELECT 'sys_dict' UNION ALL
|
||||
SELECT 'sys_dict_data' UNION ALL
|
||||
SELECT 'sys_dictionary' UNION ALL
|
||||
SELECT 'sys_dictionary_data' UNION ALL
|
||||
SELECT 'sys_domain' UNION ALL
|
||||
SELECT 'sys_email_record' UNION ALL
|
||||
SELECT 'sys_file_record' UNION ALL
|
||||
SELECT 'sys_login_record' UNION ALL
|
||||
SELECT 'sys_menu' UNION ALL
|
||||
SELECT 'sys_operation_record' UNION ALL
|
||||
SELECT 'sys_organization' UNION ALL
|
||||
SELECT 'sys_payment' UNION ALL
|
||||
SELECT 'sys_plug' UNION ALL
|
||||
SELECT 'sys_role' UNION ALL
|
||||
SELECT 'sys_role_menu' UNION ALL
|
||||
SELECT 'sys_setting' UNION ALL
|
||||
SELECT 'sys_tenant' UNION ALL
|
||||
SELECT 'sys_user' UNION ALL
|
||||
SELECT 'sys_user_balance_log' UNION ALL
|
||||
SELECT 'sys_user_collection' UNION ALL
|
||||
SELECT 'sys_user_file' UNION ALL
|
||||
SELECT 'sys_user_referee' UNION ALL
|
||||
SELECT 'sys_user_role' UNION ALL
|
||||
SELECT 'sys_user_role_extend' UNION ALL
|
||||
SELECT 'sys_user_verify'
|
||||
) t
|
||||
LEFT JOIN information_schema.tables ist
|
||||
ON ist.table_schema = 'gxwebsoft_core'
|
||||
AND ist.table_name = t.table_name
|
||||
ORDER BY status DESC, t.table_name;
|
||||
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- 方式三:统计汇总(应有 31 张,看实际存在几张)。
|
||||
-- ---------------------------------------------------------------------
|
||||
SELECT
|
||||
31 AS expected_count,
|
||||
COUNT(*) AS existing_count,
|
||||
31 - COUNT(*) AS missing_count
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'gxwebsoft_core'
|
||||
AND table_name IN (
|
||||
'sys_company','sys_company_comment','sys_company_content','sys_company_git',
|
||||
'sys_company_parameter','sys_company_url','sys_dict','sys_dict_data',
|
||||
'sys_dictionary','sys_dictionary_data','sys_domain','sys_email_record',
|
||||
'sys_file_record','sys_login_record','sys_menu','sys_operation_record',
|
||||
'sys_organization','sys_payment','sys_plug','sys_role','sys_role_menu',
|
||||
'sys_setting','sys_tenant','sys_user','sys_user_balance_log',
|
||||
'sys_user_collection','sys_user_file','sys_user_referee','sys_user_role',
|
||||
'sys_user_role_extend','sys_user_verify'
|
||||
);
|
||||
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- 附:确认连接账号能访问 gxwebsoft_core(库是否存在 + 是否有权限)。
|
||||
-- 若这条查不到结果,说明库不存在或当前账号无权限。
|
||||
-- ---------------------------------------------------------------------
|
||||
SELECT schema_name
|
||||
FROM information_schema.schemata
|
||||
WHERE schema_name = 'gxwebsoft_core';
|
||||
@@ -1,14 +0,0 @@
|
||||
-- 水票配送订单:配送流程字段(需在数据库执行)
|
||||
-- 表:glt_ticket_order
|
||||
|
||||
ALTER TABLE glt_ticket_order2
|
||||
ADD COLUMN delivery_status INT NULL DEFAULT 10 COMMENT '配送状态:10待配送、20配送中、30待客户确认、40已完成',
|
||||
ADD COLUMN send_start_time DATETIME NULL COMMENT '开始配送时间',
|
||||
ADD COLUMN send_end_time DATETIME NULL COMMENT '确认送达时间',
|
||||
ADD COLUMN send_end_img VARCHAR(512) NULL COMMENT '送达拍照留档图片URL',
|
||||
ADD COLUMN receive_confirm_time DATETIME NULL COMMENT '客户确认收货时间',
|
||||
ADD COLUMN receive_confirm_type INT NULL COMMENT '确认方式:10手动、20照片、30超时';
|
||||
|
||||
CREATE INDEX idx_glt_ticket_order_rider_status ON glt_ticket_order (tenant_id, rider_id, delivery_status, deleted);
|
||||
CREATE INDEX idx_glt_ticket_order_user_status ON glt_ticket_order (tenant_id, user_id, delivery_status, deleted);
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
-- credit_user 索引优化(MySQL/InnoDB)
|
||||
--
|
||||
-- 背景:
|
||||
-- - credit_user 列表分页默认排序:sort_number asc, create_time desc
|
||||
-- - 常见过滤:tenant_id(TenantLine 自动追加)、deleted=0、company_id、user_id、create_time 范围
|
||||
-- - 统计/刷新关联数:WHERE deleted=0 AND company_id IN (...) GROUP BY company_id
|
||||
--
|
||||
-- 使用前建议先查看现有索引,避免重复:
|
||||
-- SHOW INDEX FROM credit_user;
|
||||
--
|
||||
-- 注意:
|
||||
-- - 大表加索引会消耗 IO/CPU,建议在低峰执行。
|
||||
-- - MySQL 8 可考虑:ALTER TABLE ... ALGORITHM=INPLACE, LOCK=NONE(视版本/引擎而定)。
|
||||
|
||||
-- 1) 覆盖默认分页排序 + 逻辑删除 + 租户隔离
|
||||
-- 典型:WHERE tenant_id=? AND deleted=0 ORDER BY sort_number, create_time DESC LIMIT ...
|
||||
CREATE INDEX idx_credit_user_tenant_deleted_sort_create_id
|
||||
ON credit_user (tenant_id, deleted, sort_number, create_time, id);
|
||||
|
||||
-- 2) 企业维度查询/统计(也服务于 credit_company 记录数刷新)
|
||||
-- 典型:WHERE tenant_id=? AND company_id=? AND deleted=0 ...
|
||||
-- 典型:WHERE tenant_id=? AND deleted=0 AND company_id IN (...) GROUP BY company_id
|
||||
CREATE INDEX idx_credit_user_tenant_company_deleted
|
||||
ON credit_user (tenant_id, company_id, deleted);
|
||||
|
||||
-- 3) 用户维度查询(后台常按录入人/负责人筛选)
|
||||
-- 典型:WHERE tenant_id=? AND user_id=? AND deleted=0 ...
|
||||
CREATE INDEX idx_credit_user_tenant_user_deleted
|
||||
ON credit_user (tenant_id, user_id, deleted);
|
||||
|
||||
-- 可选:如果你们经常按 type 过滤(0/1),再加这个(否则先别加,避免过多索引影响写入)
|
||||
-- CREATE INDEX idx_credit_user_tenant_type_deleted
|
||||
-- ON credit_user (tenant_id, type, deleted);
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
-- 工单主表
|
||||
CREATE TABLE IF NOT EXISTS `app_ticket` (
|
||||
`ticket_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '工单ID',
|
||||
`ticket_no` VARCHAR(32) NOT NULL COMMENT '工单编号(TK-yyyyMMddHHmmss+4位随机)',
|
||||
`title` VARCHAR(200) NOT NULL COMMENT '工单标题',
|
||||
`content` TEXT NOT NULL COMMENT '工单内容描述',
|
||||
`website_id` BIGINT DEFAULT NULL COMMENT '关联应用ID',
|
||||
`website_name` VARCHAR(100) DEFAULT NULL COMMENT '应用名称(冗余)',
|
||||
`category` VARCHAR(30) NOT NULL DEFAULT 'other' COMMENT '分类: bug/feature/consultation/complaint/other',
|
||||
`priority` VARCHAR(20) NOT NULL DEFAULT 'normal' COMMENT '优先级: low/normal/high/urgent',
|
||||
`status` VARCHAR(20) NOT NULL DEFAULT 'pending' COMMENT '状态: pending/assigned/processing/resolved/closed/rejected',
|
||||
`attachments` TEXT DEFAULT NULL COMMENT '附件JSON数组',
|
||||
`submit_user_id` INT NOT NULL COMMENT '提交人用户ID',
|
||||
`submit_user_name` VARCHAR(50) DEFAULT NULL COMMENT '提交人昵称(冗余)',
|
||||
`submit_user_avatar` VARCHAR(500) DEFAULT NULL COMMENT '提交人头像(冗余)',
|
||||
`assignee_id` INT DEFAULT NULL COMMENT '处理人用户ID',
|
||||
`assignee_name` VARCHAR(50) DEFAULT NULL COMMENT '处理人昵称(冗余)',
|
||||
`assignee_avatar` VARCHAR(500) DEFAULT NULL COMMENT '处理人头像(冗余)',
|
||||
`reply_count` INT NOT NULL DEFAULT 0 COMMENT '回复数量',
|
||||
`resolved_time` DATETIME DEFAULT NULL COMMENT '解决时间',
|
||||
`closed_time` DATETIME DEFAULT NULL COMMENT '关闭时间',
|
||||
`deleted` TINYINT NOT NULL DEFAULT 0 COMMENT '是否删除: 0否 1是',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`ticket_id`),
|
||||
UNIQUE KEY `uk_ticket_no` (`ticket_no`),
|
||||
KEY `idx_submit_user` (`submit_user_id`),
|
||||
KEY `idx_assignee` (`assignee_id`),
|
||||
KEY `idx_website_status` (`website_id`, `status`),
|
||||
KEY `idx_status_create` (`status`, `create_time`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用工单';
|
||||
|
||||
-- 工单回复表
|
||||
CREATE TABLE IF NOT EXISTS `app_ticket_reply` (
|
||||
`reply_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '回复ID',
|
||||
`ticket_id` BIGINT NOT NULL COMMENT '关联工单ID',
|
||||
`content` TEXT NOT NULL COMMENT '回复内容',
|
||||
`attachments` TEXT DEFAULT NULL COMMENT '附件JSON数组',
|
||||
`user_id` INT NOT NULL COMMENT '回复人用户ID',
|
||||
`user_name` VARCHAR(50) DEFAULT NULL COMMENT '回复人昵称(冗余)',
|
||||
`user_avatar` VARCHAR(500) DEFAULT NULL COMMENT '回复人头像(冗余)',
|
||||
`is_staff` TINYINT NOT NULL DEFAULT 0 COMMENT '是否技术人员/客服: 0否 1是',
|
||||
`deleted` TINYINT NOT NULL DEFAULT 0 COMMENT '是否删除: 0否 1是',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`reply_id`),
|
||||
KEY `idx_ticket_id` (`ticket_id`),
|
||||
KEY `idx_user_id` (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工单回复';
|
||||
@@ -1,38 +0,0 @@
|
||||
-- ============================================================
|
||||
-- 修复: cms_contact_lead.phone 字段长度不足导致 "Data too long"
|
||||
-- 错误: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation:
|
||||
-- Data truncation: Data too long for column 'phone' at row 1
|
||||
-- 原因: 公开接口 /api/cms/cms-contact-lead/submit 传入超长/带分隔符的手机号
|
||||
-- (如 "+86 (138) 1234-5678 ext 8888" 或恶意超长 payload)
|
||||
-- 方案:
|
||||
-- 1. 将 phone 字段从原长度(VARCHAR(20)) 扩到 VARCHAR(32),
|
||||
-- 足以容纳国际号码 + 分机号;
|
||||
-- 2. (可选) 同时放宽 name / company 等字段,避免后续再撞同类问题。
|
||||
-- 配合代码侧改动:
|
||||
-- - CmsContactLead 实体加 @Size / @Pattern / @NotBlank 校验
|
||||
-- - CmsContactLeadServiceImpl.submit 加 phone 清洗逻辑
|
||||
-- (去除空格、横线、括号,仅保留 + 和数字)
|
||||
-- 执行环境: 所有部署了 cms-api 的租户库 (cms_contact_lead 为全局表)
|
||||
-- 执行方式: 幂等,可重复执行
|
||||
-- ============================================================
|
||||
|
||||
-- 1. 主修复:扩展 phone 字段到 VARCHAR(32)
|
||||
ALTER TABLE cms_contact_lead
|
||||
MODIFY COLUMN phone VARCHAR(32) DEFAULT NULL COMMENT '手机号';
|
||||
|
||||
-- 2. (可选) 同步放宽 name / company,避免后续同类报错
|
||||
ALTER TABLE cms_contact_lead
|
||||
MODIFY COLUMN name VARCHAR(50) DEFAULT NULL COMMENT '联系人姓名';
|
||||
|
||||
ALTER TABLE cms_contact_lead
|
||||
MODIFY COLUMN company VARCHAR(100) DEFAULT NULL COMMENT '单位/公司名称';
|
||||
|
||||
ALTER TABLE cms_contact_lead
|
||||
MODIFY COLUMN need VARCHAR(1000) DEFAULT NULL COMMENT '需求描述';
|
||||
|
||||
-- 3. 验证字段类型已更新
|
||||
-- 预期: phone VARCHAR(32), name VARCHAR(50), company VARCHAR(100), need VARCHAR(1000)
|
||||
SHOW COLUMNS FROM cms_contact_lead LIKE 'phone';
|
||||
SHOW COLUMNS FROM cms_contact_lead LIKE 'name';
|
||||
SHOW COLUMNS FROM cms_contact_lead LIKE 'company';
|
||||
SHOW COLUMNS FROM cms_contact_lead LIKE 'need';
|
||||
@@ -1,9 +0,0 @@
|
||||
-- 栏目模型「案例(case)」补充:解决后台栏目导航选择模型=case 时后端 NPE 报“操作失败”的问题。
|
||||
-- 后端 CmsNavigationServiceImpl.saveAsync 会按 navigation.getModel() 到 cms_model 查模型信息,
|
||||
-- 若不存在则 model 为 null,随后 model.getSuffix() 抛 NPE。
|
||||
-- 插入该模型后即可与 page/article/product 行为一致(banner/thumb/suffix 可被复用)。
|
||||
-- 说明:saveAsync 已改为 null 安全,即使本行未执行,case 也能正常保存(仅无 suffix)。
|
||||
|
||||
INSERT INTO cms_model (name, model, component, component_detail, banner, suffix, thumb, show_type, disabled, sort_number, status, deleted, create_time, update_time)
|
||||
SELECT '案例', 'case', '/pages/case/index.vue', '/pages/case/[id].vue', NULL, NULL, NULL, 20, 0, 40, 0, 0, NOW(), NOW()
|
||||
WHERE NOT EXISTS (SELECT 1 FROM cms_model WHERE model = 'case');
|
||||
@@ -1,6 +0,0 @@
|
||||
-- 去掉「案例(case)」的 .html 后缀
|
||||
-- 后端 CmsNavigationServiceImpl.saveAsync 第105行会读取 cms_model.suffix 并追加到路径上,
|
||||
-- 若 cms_model 中 case 行的 suffix = '.html' 则路径变成 /case/xxx.html
|
||||
-- 本 SQL 将其置为 NULL,使 case 与 article/product/page 保持一致(无后缀)
|
||||
|
||||
UPDATE cms_model SET suffix = NULL WHERE model = 'case';
|
||||
@@ -1,32 +0,0 @@
|
||||
-- ============================================================
|
||||
-- 新增 cms_navigation.url 字段
|
||||
-- 用途: 存储栏目/导航的自定义链接地址, 与 path(路由地址) 相互独立。
|
||||
-- 后台保存时写入该字段; 网站端导航优先使用 url, 未设置则回退 path。
|
||||
-- 配合代码侧改动:
|
||||
-- - CmsNavigation 实体新增 url 字段 (MyBatis-Plus 自动映射列 url)
|
||||
-- - 网站端 getNavLink 优先使用 url; 外链原样返回, 不追加 navId
|
||||
-- 执行环境: 各租户业务库 (cms_navigation 为全局表)
|
||||
-- 执行方式: 幂等, 可重复执行 (已存在 url 列则跳过)
|
||||
-- ============================================================
|
||||
|
||||
-- 1. 幂等新增 url 列
|
||||
SET @db = DATABASE();
|
||||
SET @exists = (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = @db
|
||||
AND table_name = 'cms_navigation'
|
||||
AND column_name = 'url'
|
||||
);
|
||||
SET @sql = IF(
|
||||
@exists = 0,
|
||||
'ALTER TABLE cms_navigation ADD COLUMN url VARCHAR(500) DEFAULT NULL COMMENT ''自定义链接地址(优先级高于path)''',
|
||||
'SELECT 1 AS skipped'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 2. 验证字段已存在
|
||||
-- 预期: url VARCHAR(500) DEFAULT NULL
|
||||
SHOW COLUMNS FROM cms_navigation LIKE 'url';
|
||||
@@ -1,24 +0,0 @@
|
||||
-- 修复:审核接口(updateStepApproval)会写入 follow_step{1..4}_approved_at / follow_step{1..4}_approved_by
|
||||
-- 若数据库缺少这些列,会触发:Unknown column 'follow_step1_approved_at' in 'field list'
|
||||
--
|
||||
-- 建议先检查:
|
||||
-- SHOW COLUMNS FROM credit_mp_customer LIKE 'follow_step%_approved%';
|
||||
--
|
||||
-- 然后按需执行下面的 ALTER TABLE(如果你的 MySQL 版本支持,也可以改为 ADD COLUMN IF NOT EXISTS)。
|
||||
|
||||
-- 第1步:案件受理
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step1_approved_at VARCHAR(255) NULL COMMENT '第1步审核时间';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step1_approved_by BIGINT NULL COMMENT '第1步审核人ID';
|
||||
|
||||
-- 第2步:材料准备
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step2_approved_at VARCHAR(255) NULL COMMENT '第2步审核时间';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step2_approved_by BIGINT NULL COMMENT '第2步审核人ID';
|
||||
|
||||
-- 第3步:案件办理
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step3_approved_at VARCHAR(255) NULL COMMENT '第3步审核时间';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step3_approved_by BIGINT NULL COMMENT '第3步审核人ID';
|
||||
|
||||
-- 第4步:送达签收
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step4_approved_at VARCHAR(255) NULL COMMENT '第4步审核时间';
|
||||
ALTER TABLE credit_mp_customer ADD COLUMN follow_step4_approved_by BIGINT NULL COMMENT '第4步审核人ID';
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
-- =====================================================
|
||||
-- 客资管理系统数据库变更脚本
|
||||
-- 适用于: mp-java 数据库
|
||||
-- 创建时间: 2026-04-14
|
||||
-- =====================================================
|
||||
|
||||
-- 1. 扩展客资表 - 添加派单、推荐人相关字段
|
||||
ALTER TABLE cms_contact_lead
|
||||
ADD COLUMN assigned_user_id INT DEFAULT NULL COMMENT '被分配的业务员用户ID',
|
||||
ADD COLUMN referrer_user_id INT DEFAULT NULL COMMENT '推荐人用户ID(全民推荐)',
|
||||
ADD COLUMN referral_fee DECIMAL(10,2) DEFAULT 0.00 COMMENT '推荐费金额',
|
||||
ADD COLUMN referral_fee_paid TINYINT DEFAULT 0 COMMENT '推荐费是否已支付 0否 1是',
|
||||
ADD COLUMN referrer_share DECIMAL(5,2) DEFAULT 0.00 COMMENT '推荐人分成比例%',
|
||||
ADD COLUMN dispatch_time DATETIME DEFAULT NULL COMMENT '派单时间',
|
||||
ADD COLUMN dispatch_admin_id INT DEFAULT NULL COMMENT '派单管理员ID',
|
||||
ADD COLUMN follow_count INT DEFAULT 0 COMMENT '跟进次数',
|
||||
ADD COLUMN last_follow_time DATETIME DEFAULT NULL COMMENT '最后跟进时间',
|
||||
ADD COLUMN appointment_time DATETIME DEFAULT NULL COMMENT '预约时间',
|
||||
ADD COLUMN deal_amount DECIMAL(12,2) DEFAULT NULL COMMENT '成交金额',
|
||||
ADD COLUMN deal_time DATETIME DEFAULT NULL COMMENT '成交时间',
|
||||
ADD COLUMN source_type VARCHAR(20) DEFAULT 'form' COMMENT '来源类型: form表单 website网站 miniapp小程序 referral推荐人 admin录入';
|
||||
|
||||
-- 创建索引
|
||||
CREATE INDEX idx_lead_assigned ON cms_contact_lead(assigned_user_id);
|
||||
CREATE INDEX idx_lead_referrer ON cms_contact_lead(referrer_user_id);
|
||||
CREATE INDEX idx_lead_status ON cms_contact_lead(status);
|
||||
CREATE INDEX idx_lead_source ON cms_contact_lead(source_type);
|
||||
|
||||
-- 2. 派单记录表
|
||||
CREATE TABLE IF NOT EXISTS lead_dispatch (
|
||||
dispatch_id INT PRIMARY KEY AUTO_INCREMENT COMMENT '派单ID',
|
||||
lead_id INT NOT NULL COMMENT '客资ID',
|
||||
from_user_id INT DEFAULT NULL COMMENT '原分配用户ID(如果重新分配)',
|
||||
to_user_id INT NOT NULL COMMENT '新分配用户ID(业务员)',
|
||||
admin_id INT NOT NULL COMMENT '执行派单的管理员ID',
|
||||
dispatch_remarks VARCHAR(500) DEFAULT NULL COMMENT '派单备注',
|
||||
dispatch_type TINYINT DEFAULT 1 COMMENT '派单类型: 1新分配 2重新分配 3抢单',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '派单时间',
|
||||
INDEX idx_dispatch_lead (lead_id),
|
||||
INDEX idx_dispatch_to_user (to_user_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客资派单记录表';
|
||||
|
||||
-- 3. 跟进记录表
|
||||
CREATE TABLE IF NOT EXISTS lead_follow_log (
|
||||
follow_id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
lead_id INT NOT NULL COMMENT '客资ID',
|
||||
user_id INT NOT NULL COMMENT '跟进人ID',
|
||||
follow_type TINYINT NOT NULL COMMENT '跟进方式: 1电话 2微信 3上门 4短信 5其他',
|
||||
follow_content VARCHAR(1000) NOT NULL COMMENT '跟进内容',
|
||||
next_follow_time DATETIME DEFAULT NULL COMMENT '下次跟进时间',
|
||||
next_follow_plan VARCHAR(500) DEFAULT NULL COMMENT '下次跟进计划',
|
||||
attachment_urls VARCHAR(1000) DEFAULT NULL COMMENT '附件URLs(JSON数组)',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX idx_follow_lead (lead_id),
|
||||
INDEX idx_follow_user (user_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客资跟进记录表';
|
||||
|
||||
-- 4. 推荐人关系表(全民推荐)
|
||||
CREATE TABLE IF NOT EXISTS lead_referral (
|
||||
referral_id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
referrer_user_id INT NOT NULL COMMENT '推荐人用户ID',
|
||||
referred_lead_id INT NOT NULL COMMENT '被推荐的客资ID',
|
||||
referral_code VARCHAR(32) DEFAULT NULL COMMENT '推荐码(用于匿名推荐)',
|
||||
referral_fee DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '推荐费',
|
||||
referral_status TINYINT DEFAULT 0 COMMENT '推荐状态: 0待确认 1有效 2无效 3已结算',
|
||||
customer_name VARCHAR(100) DEFAULT NULL COMMENT '客户姓名(匿名推荐时存储)',
|
||||
customer_phone VARCHAR(20) DEFAULT NULL COMMENT '客户电话(匿名推荐时存储)',
|
||||
settlement_time DATETIME DEFAULT NULL COMMENT '结算时间',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX idx_referral_referrer (referrer_user_id),
|
||||
INDEX idx_referral_lead (referred_lead_id),
|
||||
INDEX idx_referral_code (referral_code)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客资推荐关系表';
|
||||
|
||||
-- 5. 用户角色扩展表(多管理员支持)
|
||||
CREATE TABLE IF NOT EXISTS gxwebsoft_core.sys_user_role_extend (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
user_id INT NOT NULL COMMENT '用户ID',
|
||||
role_type VARCHAR(20) NOT NULL COMMENT '角色类型: admin管理员 salesman业务员 referrer推荐人',
|
||||
is_primary TINYINT DEFAULT 1 COMMENT '是否主角色 0否 1是',
|
||||
permissions JSON DEFAULT NULL COMMENT '权限配置(JSON)',
|
||||
max_leads INT DEFAULT NULL COMMENT '最大客资分配数(业务员)',
|
||||
commission_rate DECIMAL(5,2) DEFAULT NULL COMMENT '佣金比例%(业务员)',
|
||||
referral_bonus DECIMAL(10,2) DEFAULT NULL COMMENT '推荐奖金%(推荐人)',
|
||||
status TINYINT DEFAULT 1 COMMENT '状态: 0禁用 1启用',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
update_time DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY uk_user_role (user_id, role_type),
|
||||
INDEX idx_user (user_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户角色扩展表';
|
||||
|
||||
-- 6. 数据统计汇总表(定期生成报表用)
|
||||
CREATE TABLE IF NOT EXISTS lead_statistics (
|
||||
stat_id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
stat_date DATE NOT NULL COMMENT '统计日期',
|
||||
user_id INT DEFAULT NULL COMMENT '用户ID(Null表示全站)',
|
||||
role_type VARCHAR(20) DEFAULT NULL COMMENT '角色类型',
|
||||
total_leads INT DEFAULT 0 COMMENT '总客资数',
|
||||
new_leads INT DEFAULT 0 COMMENT '新增客资数',
|
||||
assigned_leads INT DEFAULT 0 COMMENT '已分配客资数',
|
||||
followed_leads INT DEFAULT 0 COMMENT '已跟进客资数',
|
||||
dealed_leads INT DEFAULT 0 COMMENT '已成交客资数',
|
||||
deal_amount DECIMAL(15,2) DEFAULT 0.00 COMMENT '成交总金额',
|
||||
referral_count INT DEFAULT 0 COMMENT '推荐成功数',
|
||||
referral_fee DECIMAL(12,2) DEFAULT 0.00 COMMENT '推荐费总额',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY uk_stat_date_user (stat_date, user_id, role_type),
|
||||
INDEX idx_stat_date (stat_date)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客资数据统计表';
|
||||
|
||||
-- 7. 推荐费结算记录表
|
||||
CREATE TABLE IF NOT EXISTS lead_referral_settlement (
|
||||
settlement_id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
referral_id INT NOT NULL COMMENT '推荐关系ID',
|
||||
referrer_user_id INT NOT NULL COMMENT '推荐人ID',
|
||||
lead_id INT NOT NULL COMMENT '关联客资ID',
|
||||
settlement_amount DECIMAL(10,2) NOT NULL COMMENT '结算金额',
|
||||
settlement_type TINYINT DEFAULT 1 COMMENT '结算方式: 1自动 2手动',
|
||||
settlement_admin_id INT DEFAULT NULL COMMENT '操作管理员ID',
|
||||
settlement_remarks VARCHAR(500) DEFAULT NULL COMMENT '结算备注',
|
||||
status TINYINT DEFAULT 0 COMMENT '状态: 0待确认 1已转账 2已到账',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
confirm_time DATETIME DEFAULT NULL COMMENT '确认时间',
|
||||
INDEX idx_settlement_referrer (referrer_user_id),
|
||||
INDEX idx_settlement_lead (lead_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='推荐费结算记录表';
|
||||
|
||||
-- =====================================================
|
||||
-- 初始化数据
|
||||
-- =====================================================
|
||||
|
||||
-- 插入默认管理员角色扩展
|
||||
INSERT INTO gxwebsoft_core.sys_user_role_extend (user_id, role_type, is_primary, permissions, status)
|
||||
SELECT user_id, 'admin', 1, '{"canDispatch": true, "canManageUsers": true, "canViewStats": true, "canSetCommission": true}', 1
|
||||
FROM gxwebsoft_core.sys_user WHERE status = 0 AND deleted = 0 LIMIT 1;
|
||||
|
||||
-- =====================================================
|
||||
-- 视图: 客资完整信息视图
|
||||
-- =====================================================
|
||||
CREATE OR REPLACE VIEW v_lead_full_info AS
|
||||
SELECT
|
||||
l.lead_id,
|
||||
l.name AS customer_name,
|
||||
l.phone AS customer_phone,
|
||||
l.company,
|
||||
l.need AS requirement,
|
||||
l.status,
|
||||
l.source_type,
|
||||
l.create_time,
|
||||
l.dispatch_time,
|
||||
l.deal_amount,
|
||||
l.deal_time,
|
||||
l.referral_fee,
|
||||
l.referral_fee_paid,
|
||||
au.user_id AS assigned_user_id,
|
||||
au.nickname AS assigned_user_name,
|
||||
au.real_name AS assigned_real_name,
|
||||
au.phone AS assigned_user_phone,
|
||||
ru.user_id AS referrer_user_id,
|
||||
ru.nickname AS referrer_name,
|
||||
ru.phone AS referrer_phone,
|
||||
admin.user_id AS dispatch_admin_id,
|
||||
admin.nickname AS dispatch_admin_name,
|
||||
l.follow_count,
|
||||
l.last_follow_time,
|
||||
l.appointment_time,
|
||||
CASE l.status
|
||||
WHEN 0 THEN '待跟进'
|
||||
WHEN 1 THEN '跟进中'
|
||||
WHEN 2 THEN '已成交'
|
||||
WHEN 3 THEN '无效'
|
||||
ELSE '未知'
|
||||
END AS status_text
|
||||
FROM cms_contact_lead l
|
||||
LEFT JOIN gxwebsoft_core.sys_user au ON l.assigned_user_id = au.user_id
|
||||
LEFT JOIN gxwebsoft_core.sys_user ru ON l.referrer_user_id = ru.user_id
|
||||
LEFT JOIN gxwebsoft_core.sys_user admin ON l.dispatch_admin_id = admin.user_id
|
||||
WHERE l.deleted = 0;
|
||||
@@ -0,0 +1,260 @@
|
||||
# 汇吉采 ↔ 一站式代理平台 对接接口文档
|
||||
|
||||
> 版本:v1.0
|
||||
> 适用:汇吉采标书购买平台(下称「官方网」)与一站式代理平台(下称「一站式」)之间双向数据互通。
|
||||
> 相关:鉴权规则见 `docs/一站式平台推送-接口鉴权规范.md`;建表见 `src/main/resources/sql/hjc_init.sql`。
|
||||
|
||||
---
|
||||
|
||||
## 0. 概述
|
||||
|
||||
| 方向 | 触发时机 | 接口 | 位置 |
|
||||
|---|---|---|---|
|
||||
| **入向**(一站式 → 官方网) | 项目流程走到「发布中标公告」时 | `POST {官方网}/api/hjc/push/project` | 官方网接收标书/中标公告数据,按 `projectNo` upsert 落库 |
|
||||
| **出向**(官方网 → 一站式) | C 端购买标书**支付成功后** / 退款时 | `POST {一站式}/api/biz/createPurchaseDetails` | 官方网把购买记录/订单信息推送到一站式落盘 |
|
||||
|
||||
**共享凭证**(双方约定,不通过网络传输明文密钥):
|
||||
|
||||
| 参数 | 值 | 说明 |
|
||||
|---|---|---|
|
||||
| `appKey` | `HJC_Official_Website` | 调用方标识,明文放请求头 |
|
||||
| `password` | `vQ8$kR3#mW6@xP2!nF` | 签名密钥(Secret),仅参与签名,**不进报文** |
|
||||
|
||||
---
|
||||
|
||||
## 1. 鉴权规范(双向通用)
|
||||
|
||||
请求头携带:
|
||||
|
||||
| Header | 示例 | 说明 |
|
||||
|---|---|---|
|
||||
| `appKey` | `HJC_Official_Website` | 双方一致 |
|
||||
| `timestamp` | `202604080103` | 格式 `yyyyMMddHHmm`(24 小时,北京时区,精确到分) |
|
||||
| `sign` | `9f7c…(32位小写hex)` | 签名值 |
|
||||
|
||||
**签名算法**:`sign = MD5(appKey + password + timestamp)`(无分隔符,小写 32 位)。
|
||||
|
||||
**校验顺序**(任一步不过即拒绝,建议返回 `401`/`400`):
|
||||
1. `appKey == HJC_Official_Website`
|
||||
2. `timestamp` 与接收方服务器当前时间差 **≤ ±10 分钟**(防重放)
|
||||
3. 用约定 `password` 重算 `MD5(appKey+password+timestamp)`,与 `sign` 不区分大小写比对
|
||||
|
||||
> 完整规则、示例(Python/Java)与「明文 password 头」兼容退路见 `docs/一站式平台推送-接口鉴权规范.md`。
|
||||
|
||||
---
|
||||
|
||||
## 2. 入向接口:一站式 → 官方网(接收标书/中标公告)
|
||||
|
||||
### 2.1 接口地址
|
||||
|
||||
```
|
||||
POST {官方网BaseUrl}/api/hjc/push/project
|
||||
```
|
||||
|
||||
> 官方网侧需在 SecurityConfig 放行该路径(已内置,`/api/hjc/push/project` 为公开接口,鉴权由本接口的 appKey/sign 自行校验)。
|
||||
|
||||
### 2.2 请求头
|
||||
|
||||
| Header | 值 |
|
||||
|---|---|
|
||||
| `appKey` | `HJC_Official_Website` |
|
||||
| `timestamp` | `yyyyMMddHHmm` |
|
||||
| `sign` | `MD5(appKey+password+timestamp)` |
|
||||
| `tenantId` | `10626`(官方网当前固定租户,**必传**,作为落库租户) |
|
||||
| `Content-Type` | `application/json` |
|
||||
|
||||
### 2.3 请求体字段
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 | 对应内部字段 |
|
||||
|---|---|---|---|---|
|
||||
| `projectNo` | string | ✔ | 项目编号 | `project_no`(upsert 主键) |
|
||||
| `projectName` | string | ✔ | 项目名称 | `project_name` |
|
||||
| `tenderPrice` | number | | 标书价格/信息服务费 | `tender_price` |
|
||||
| `files` | string(JSON/逗号分隔) | | 标书附件 | `tender_file` |
|
||||
| `tenderOnsaleTime` | string | | 开售时间 `yyyy-MM-dd HH:mm:ss` | `onsale_time` |
|
||||
| `tenderOffsaleTime` | string | | 停售时间 `yyyy-MM-dd HH:mm:ss` | `offsale_time` |
|
||||
| `bulletinName` | string | | 公告标题 | `bulletin_title` |
|
||||
| `customerName` | string | | 招标人 | `tenderer` |
|
||||
| `supplierName` | string | | 中标公司 | `winner_supplier` |
|
||||
| `bidAmount` | number | | 中标金额 | `bid_amount` |
|
||||
| `content` | string | | 公告正文 | `bulletin_content` |
|
||||
| `fileList` | string(JSON/逗号分隔) | | 公告附件 | `bulletin_file_list` |
|
||||
| `needSellTender` | number | | 是否卖标书 0/1 | `need_sell` |
|
||||
| `sellingMethod` | number | | 售卖方式 1公司财务 2公众号 3交易中心 4政采云 | `selling_method` |
|
||||
|
||||
### 2.4 响应
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"message": "接收成功",
|
||||
"data": { "id": 12, "projectNo": "ZB-2026-0001", "projectName": "xxx", "dataSource": "PUSH", "status": 1 }
|
||||
}
|
||||
```
|
||||
- `code == 0` 成功;`code != 0` 失败(如 `message=鉴权失败` / `租户ID不能为空` / `项目编号不能为空`)。
|
||||
|
||||
### 2.5 落库规则(官方网侧)
|
||||
|
||||
- 按 `projectNo` **upsert**:不存在则插入(`tenantId=请求头tenantId`,`status=1` 上架,`dataSource=PUSH`,`saleCount=0`);已存在则更新推送到字段。
|
||||
- 兼容性:`tenderOnsaleTime`/`tenderOffsaleTime` 支持 `yyyy-MM-dd HH:mm:ss`、`yyyyMMddHHmmss`、ISO 带 `T` 三种格式解析;解析失败置空。
|
||||
- 其余标书项目字段(分类、上下架、人工维护数据)仍可在管理后台手工调整。
|
||||
|
||||
---
|
||||
|
||||
## 3. 出向接口:官方网 → 一站式(推送购买记录/订单)
|
||||
|
||||
### 3.1 接口地址
|
||||
|
||||
```
|
||||
POST {一站式BaseUrl}/api/biz/createPurchaseDetails
|
||||
```
|
||||
|
||||
### 3.2 触发时机
|
||||
|
||||
- **支付成功后**(官方网 `PUT /api/hjc/order/mark-paid` 置已付)自动推送,请求状态 `status=PAID`。
|
||||
- **退款时**(官方网 `POST /api/hjc/order/refund` 置已退款)推送,请求状态 `status=REFUNDED`,**必须**携带 `refundTime`(退款时间)与 `refundReason`(退款原因)。
|
||||
- `refundTime`:官方网记录退款动作发生时间(服务器时间),落库 `hjc_order.refund_time`。
|
||||
- `refundReason`:后台退款弹窗填写(≤200 字),落库 `hjc_order.refund_reason`;未填写时取默认「管理员操作退款」。
|
||||
- 推送失败进重试队列后,重试报文的退款时间/原因按订单落库值重建,不会丢失。
|
||||
|
||||
### 3.3 请求头
|
||||
|
||||
| Header | 值 |
|
||||
|---|---|
|
||||
| `appKey` | `HJC_Official_Website` |
|
||||
| `timestamp` | `yyyyMMddHHmm` |
|
||||
| `sign` | `MD5(appKey+password+timestamp)` |
|
||||
| `Content-Type` | `application/json` |
|
||||
|
||||
> `password` 不进请求头;`sign` 每次发送须按新的 `timestamp` 重新计算。
|
||||
|
||||
### 3.4 请求体字段
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| `idempotencyKey` | string | 幂等键,`HJC_ORD_<orderNo>` |
|
||||
| `orderNo` | string | 官方网订单号(一站式去重键) |
|
||||
| `projectNo` | string | 项目编号 |
|
||||
| `projectName` | string | 项目名称 |
|
||||
| `tenderPrice` | number | 标书单价(信息服务费) |
|
||||
| `quantity` | number | 购买数量 |
|
||||
| `totalAmount` | number | 订单总额 |
|
||||
| `buyer.enterpriseName` | string | 购买企业名称 |
|
||||
| `buyer.creditCode` | string | 企业统一社会信用代码 |
|
||||
| `buyer.contactName` | string | 经办人姓名 |
|
||||
| `buyer.contactPhone` | string | 经办人手机号 |
|
||||
| `buyer.contactEmail` | string | 经办人邮箱 |
|
||||
| `paidAt` | string | 支付时间 `yyyy-MM-dd HH:mm:ss` |
|
||||
| `payMethod` | string | `WECHAT_NATIVE` / `ALIPAY` |
|
||||
| `status` | string | `PAID`(已支付)/ `REFUNDED`(已退款) |
|
||||
| `refundTime` | string | **退款时必传**,退款时间 `yyyy-MM-dd HH:mm:ss`(`status=REFUNDED` 时推送,其余状态不出现在报文中) |
|
||||
| `refundReason` | string | **退款时必传**,退款原因(≤255 字符;后台未填写时取默认「管理员操作退款」) |
|
||||
| `invoiceStatus` | string | `NONE` / `APPLIED` / `ISSUED` |
|
||||
|
||||
请求体示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"idempotencyKey": "HJC_ORD_HJC2026080101ABCD",
|
||||
"orderNo": "HJC2026080101ABCD",
|
||||
"projectNo": "ZB-2026-0001",
|
||||
"projectName": "xxx采购项目",
|
||||
"tenderPrice": 500.00,
|
||||
"quantity": 1,
|
||||
"totalAmount": 500.00,
|
||||
"buyer": {
|
||||
"enterpriseName": "某某科技有限公司",
|
||||
"creditCode": "91110XXXX",
|
||||
"contactName": "张三",
|
||||
"contactPhone": "13800000000",
|
||||
"contactEmail": "a@b.com"
|
||||
},
|
||||
"paidAt": "2026-08-01 10:30:00",
|
||||
"payMethod": "WECHAT_NATIVE",
|
||||
"status": "PAID",
|
||||
"invoiceStatus": "NONE"
|
||||
}
|
||||
```
|
||||
|
||||
退款推送请求体示例(`status=REFUNDED`,多出 `refundTime`/`refundReason`):
|
||||
|
||||
```json
|
||||
{
|
||||
"idempotencyKey": "HJC_ORD_HJC2026080101ABCD",
|
||||
"orderNo": "HJC2026080101ABCD",
|
||||
"projectNo": "ZB-2026-0001",
|
||||
"projectName": "xxx采购项目",
|
||||
"tenderPrice": 500.00,
|
||||
"quantity": 1,
|
||||
"totalAmount": 500.00,
|
||||
"buyer": {
|
||||
"enterpriseName": "某某科技有限公司",
|
||||
"creditCode": "91110XXXX",
|
||||
"contactName": "张三",
|
||||
"contactPhone": "13800000000",
|
||||
"contactEmail": "a@b.com"
|
||||
},
|
||||
"paidAt": "2026-08-01 10:30:00",
|
||||
"payMethod": "WECHAT_NATIVE",
|
||||
"status": "REFUNDED",
|
||||
"refundTime": "2026-08-03 09:15:00",
|
||||
"refundReason": "项目终止,客户申请退款",
|
||||
"invoiceStatus": "NONE"
|
||||
}
|
||||
```
|
||||
|
||||
### 3.5 响应约定
|
||||
|
||||
- 一站式按自身 `API` 返回;官方网侧把 `HTTP 2xx` 视为成功,否则记入推送日志(`hjc_order_push_log`)待重试。
|
||||
- **幂等**:建议一站式以 `orderNo`/`idempotencyKey` 去重,同单重复提交返回成功、不重复插入。
|
||||
|
||||
### 3.6 重试策略(官方网侧)
|
||||
|
||||
- 失败(非 2xx / 网络异常)写入 `push_status=2`,`next_retry_time = now + 30min`,`attempt_count + 1`。
|
||||
- 由定时任务 `retryPendingPush()` 扫描待推送/失败记录重发;重发时 `timestamp/sign` 重新计算。
|
||||
|
||||
---
|
||||
|
||||
## 4. 字段映射总表
|
||||
|
||||
| 一站式字段 | 含义 | 官方网内部字段 |
|
||||
|---|---|---|
|
||||
| `projectNo` | 项目编号 | `hjc_bid_project.project_no` |
|
||||
| `projectName` | 项目名称 | `project_name` |
|
||||
| `tenderPrice` | 标书价格 | `tender_price` |
|
||||
| `files` | 标书附件 | `tender_file` |
|
||||
| `tenderOnsaleTime` | 开售时间 | `onsale_time` |
|
||||
| `tenderOffsaleTime` | 停售时间 | `offsale_time` |
|
||||
| `bulletinName` | 公告标题 | `bulletin_title` |
|
||||
| `customerName` | 招标人 | `tenderer` |
|
||||
| `supplierName` | 中标公司 | `winner_supplier` |
|
||||
| `bidAmount` | 中标金额 | `bid_amount` |
|
||||
| `content` | 公告正文 | `bulletin_content` |
|
||||
| `fileList` | 公告附件 | `bulletin_file_list` |
|
||||
| `needSellTender` | 是否卖标书 | `need_sell` |
|
||||
| `sellingMethod` | 售卖方式 | `selling_method` |
|
||||
| `refundTime` | 退款时间(出向) | `hjc_order.refund_time` |
|
||||
| `refundReason` | 退款原因(出向) | `hjc_order.refund_reason` |
|
||||
|
||||
---
|
||||
|
||||
## 5. 配置清单(待双方/部署方填写)
|
||||
|
||||
| 项 | 值 | 位置 |
|
||||
|---|---|---|
|
||||
| 官方网 base-url | `http://<官方网域名>/api` | 一站式侧调用方配置 |
|
||||
| 一站式 base-url | `http://<一站式域名>` | `mp-java/application.yml` → `hjc.one-stop.base-url` |
|
||||
| createPurchaseDetails 路径 | `/api/biz/createPurchaseDetails` | `hjc.one-stop.create-purchase-details-path` |
|
||||
| `appKey` | `HJC_Official_Website` | 双方约定 |
|
||||
| `password` | `vQ8$kR3#mW6@xP2!nF` | 双方约定 |
|
||||
| 租户 ID | `10626` | 官方网请求头 `tenantId` |
|
||||
|
||||
---
|
||||
|
||||
## 6. 待确认事项
|
||||
|
||||
1. 出向 `sign` 拼接顺序(`appKey+password+timestamp`)与一站式既有算法是否一致;不一致请给出一站式现网签名规范。
|
||||
2. `timestamp` 格式、时区、±10min 窗口是否认可。
|
||||
3. `createPurchaseDetails` 字段名是否需与一站式现网入参完全一致(现按本表定义);如需调整字段名请给出一站式入参清单。
|
||||
4. 入向:一站式调用官方网 `/api/hjc/push/project` 时是否也按同一套 `appKey/timestamp/sign` 鉴权(本表默认对称鉴权)。
|
||||
5. 退款字段名 `refundTime` / `refundReason` 与一站式现网入参是否一致;格式默认 `yyyy-MM-dd HH:mm:ss`,如一站式要求其他命名或时间格式请同步调整 `CreatePurchaseDetails`。
|
||||
@@ -0,0 +1,130 @@
|
||||
# 汇吉采 → 一站式代理平台:标书订单推送接口鉴权规范
|
||||
|
||||
> 用途:本文档是**本平台(汇吉采标书购买平台,下称「官方网」)调用一站式代理平台接口**时的鉴权规范,用于对接一站式平台开发人员,请对方按此规则在服务端做校验。
|
||||
> 目标接口:`POST /api/biz/createPurchaseDetails`(本平台推送购买记录与订单信息到一站式平台落盘)
|
||||
|
||||
---
|
||||
|
||||
## 1. 共享凭证(双方提前约定,不通过网络传输)
|
||||
|
||||
| 参数 | 值 | 说明 |
|
||||
|---|---|---|
|
||||
| `appKey` | `HJC_Official_Website` | 调用方标识,明文放在请求头 |
|
||||
| `password` | `vQ8$kR3#mW6@xP2!nF` | **签名密钥(Secret)**,仅双方服务端持有,**不放在请求头、不出现于任何请求/日志/报文** |
|
||||
|
||||
> ⚠️ 出于安全考虑,本规范**不把 `password` 明文放请求头**。原始需求中「把 password 明文字段加到请求头」的做法会泄露密钥,改为「用 password 参与签名、请求头只带签名结果」的等价且更安全的方案(见第 3 节)。如需严格沿用原始「明文 password 头」方案,见附录 A。
|
||||
|
||||
---
|
||||
|
||||
## 2. 请求头(请求方——官方网——每次调用携带 3 个)
|
||||
|
||||
| Header | 示例值 | 说明 |
|
||||
|---|---|---|
|
||||
| `appKey` | `HJC_Official_Website` | 明文 appKey(固定值) |
|
||||
| `timestamp` | `202604080103` | 签名时间,格式 `yyyyMMddHHmm`(24 小时制,北京时区,精确到分钟) |
|
||||
| `sign` | `9f7c…(32 位小写十六进制)` | 签名值,算法见第 3 节 |
|
||||
|
||||
另需:`Content-Type: application/json`。
|
||||
|
||||
---
|
||||
|
||||
## 3. 签名算法
|
||||
|
||||
```
|
||||
sign = MD5( appKey + password + timestamp )
|
||||
```
|
||||
|
||||
- `+` 表示**字符串直接拼接**,中间无分隔符。
|
||||
- `timestamp` 使用与请求头 `timestamp` **完全相同**的值。
|
||||
- `MD5` 输出**小写** 32 位十六进制字符串。
|
||||
|
||||
步骤:
|
||||
|
||||
1. 取当前北京时间的分钟表示 `timestamp = yyyyMMddHHmm`(例:`2026-04-08 01:03` → `202604080103`)。
|
||||
2. 拼串:`HJC_Official_Website` + `vQ8$kR3#mW6@xP2!nF` + `202604080103`。
|
||||
3. 对该字符串做 MD5,转小写,得到 `sign`。
|
||||
4. 将 `appKey`、`timestamp`、`sign` 放入请求头发出。
|
||||
|
||||
---
|
||||
|
||||
## 4. 校验规则(一站式平台服务端)
|
||||
|
||||
收请求后按以下顺序校验,任一步不通过即拒绝(建议返回 `401` / `400`,并附错误码与说明,便于排查):
|
||||
|
||||
1. **校验 appKey**:`appKey` 是否等于已登记的应用标识 `HJC_Official_Website`。不等 → 拒绝。
|
||||
2. **校验 timestamp 时效(防重放)**:`timestamp` 与**一站式服务器当前时间**之差是否在 **±10 分钟**以内(统一按北京时区、分钟精度)。超出窗口 → 拒绝,提示「时间戳失效」。
|
||||
- 该窗口同时限制了重放窗口;如需更严可协商收紧到 ±3 分钟。
|
||||
3. **校验签名**:用共享的 `password` 重算 `MD5(appKey + password + timestamp)`,与请求头 `sign` **不区分大小写**比较(统一小写后比较)。不一致 → 拒绝,提示「签名校验失败」。
|
||||
4. 校验通过后,按请求体 `createPurchaseDetails` 的字段约定解析并落盘(业务字段见单独一节的「createPurchaseDetails 请求体字段表」)。
|
||||
|
||||
---
|
||||
|
||||
## 5. 幂等与重试约定(可选但强烈建议)
|
||||
|
||||
`createPurchaseDetails` 是「落盘」类写操作,本平台侧会做失败重试,因此建议一站式平台按业务主键幂等处理,避免重复落盘:
|
||||
|
||||
- 请求体需带唯一业务单号(如 `purchaseId` / `orderNo`),一站式平台以此作为去重键;**同一单号重复提交时应返回成功、不重复插入**(或返回「已存在」)。
|
||||
- 本平台对失败的推送会按 `attempt` 递增重试(建议:1/2/4/8 分钟间隔),重试时 `timestamp/sign` 需要**重新计算**(每次请求都要以新时间重签)。
|
||||
|
||||
---
|
||||
|
||||
## 6. 双端示例
|
||||
|
||||
**官方网(请求方)**——以 Python 为例:
|
||||
|
||||
```python
|
||||
import hashlib, time, requests
|
||||
|
||||
app_key = "HJC_Official_Website"
|
||||
password = "vQ8$kR3#mW6@xP2!nF"
|
||||
ts = time.strftime("%Y%m%d%H%M") # 202604080103
|
||||
sign = hashlib.md5((app_key + password + ts).encode("utf-8")).hexdigest()
|
||||
|
||||
resp = requests.post(
|
||||
"https://<一站式域名>/api/biz/createPurchaseDetails",
|
||||
json={ ... 业务字段 ... },
|
||||
headers={
|
||||
"appKey": app_key,
|
||||
"timestamp": ts,
|
||||
"sign": sign,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
timeout=15,
|
||||
)
|
||||
```
|
||||
|
||||
**一站式(校验方)**——以 Java 为例:
|
||||
|
||||
```java
|
||||
String appKey = req.getHeader("appKey");
|
||||
String ts = req.getHeader("timestamp");
|
||||
String sign = req.getHeader("sign");
|
||||
|
||||
if (!"HJC_Official_Website".equals(appKey)) return 401; // 1
|
||||
if (Math.abs(System.currentTimeMillis() / 60000 - parseMinute(ts)) > 10)
|
||||
return 401; // 2
|
||||
String expect = md5("HJC_Official_Website" + SECRET + ts); // 3
|
||||
if (!expect.equalsIgnoreCase(sign)) return 401;
|
||||
|
||||
// 4. 解析 body,按 createPurchaseDetails 字段落盘(按 orderNo 幂等)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 附录 A:若一站式平台坚持「明文 password 头」的原始方案
|
||||
|
||||
原始需求表述为「请求头添加 appKey、password,appKey+年月日时分、password+年月日时分,MD5 加密」。若对方已按此固定算法实现,则采用:
|
||||
|
||||
- 请求头:`appKey=HJC_Official_Website`、`password=vQ8$kR3#mW6@xP2!nF`、`sign=MD5(password + yyyyMMddHHmm)`(小写)。
|
||||
- 校验:`password` 需与约定值一致,且 `MD5(password + timestamp) == sign`,同时 `timestamp` 在 ±10 分钟内。
|
||||
|
||||
> 该方案会把 `password` 以明文形式暴露在报文中,安全性差;**仅作兼容退路,不作为默认推荐**。若对方无法确认固定算法,请首选第 1–6 节的方案。
|
||||
|
||||
---
|
||||
|
||||
## 附:需要一站式平台确认/提供的信息
|
||||
|
||||
1. 上述 `sign` 拼接顺序是否与合作方既有算法一致(`appKey+password+timestamp`)。
|
||||
2. 时间戳格式 `yyyyMMddHHmm` 与北京时区是否认可。
|
||||
3. 校验窗口 ±10 分钟是否可接受。
|
||||
4. `createPurchaseDetails` 请求体字段表(本平台另一份文档,见需求/接口清单)的具体入参名与必填项,需对方给出或双方对齐,以免字段名不一致导致落盘失败。
|
||||
@@ -1,98 +0,0 @@
|
||||
# 水票配送订单:后端提示词(可直接发给后端)
|
||||
|
||||
> 目标:把“水票下单后 -> 配送员接单/配送 -> 用户确认 -> 自动确认”的闭环放到后端,用明确的字段 + 状态机校验保证不越权、不乱跳状态、并发不重复接单。
|
||||
>
|
||||
> 接口前缀:当前后端控制器为 `@RequestMapping("/api/glt/glt-ticket-order")`,下文默认都带 `/api` 前缀(如需兼容旧路径,可做网关转发或保留旧路由)。
|
||||
|
||||
## 0) 角色与权限边界(务必在后端兜底)
|
||||
- 用户端(小程序用户):只能看/操作自己的订单(`userId` = token userId)。
|
||||
- 配送员端:只能看/操作分配给自己的订单(`riderId` = token userId / rider userId)。
|
||||
- 管理端:按后台权限控制(可查询/派单/改状态,但仍需 tenantId 隔离)。
|
||||
|
||||
建议:对“配送员端接口”忽略前端传入的 `riderId/userId/tenantId`,统一从登录态注入,避免越权。
|
||||
|
||||
## 1) 订单查询(配送员端)
|
||||
建议提供配送员专用分页接口:`GET /api/glt/glt-ticket-order/rider/page`(避免与后台管理分页混用)。
|
||||
请支持以下筛选,并保证权限隔离:
|
||||
- `deliveryStatus`:10待配送、20配送中、30待客户确认、40已完成(配送员端必要;不传默认=10)
|
||||
- `keywords`:支持按地址/备注等模糊搜索(可选)
|
||||
- 排序:建议默认 `sendTime asc, createTime desc`(或沿用后端默认排序,但请告知前端)
|
||||
|
||||
权限隔离要求(配送员端):
|
||||
- 只返回当前登录配送员的订单:后端强制 `param.riderId = loginUserId`(前端传不传都一样)。
|
||||
- `tenantId/deleted` 等同样后端兜底(只查当前租户、只查未删除)。
|
||||
|
||||
返回字段建议(配送员端用得上):
|
||||
- 门店/仓库/用户/配送员的展示字段:`storeName/storeAddress/storePhone`、`warehouseName/warehouseAddress`、`nickname/phone/avatar`、`riderName/riderPhone`(现有 `pageRel/listRel` 已在做关联返回)。
|
||||
- 导航相关(详见第 5 节):收货地址 `lat/lng`、门店/仓库 `lngAndLat`(可关联返回或做快照字段)。
|
||||
|
||||
## 2) 配送流程字段(建议后端落库并回传)
|
||||
订单表建议确保有以下字段(当前前端已按这些字段做流程判断/展示):
|
||||
- `riderId/riderName/riderPhone`:配送员信息
|
||||
- `deliveryStatus`:10/20/30/40
|
||||
- `sendStartTime`:配送员点击“开始配送”的时间(建议 datetime)
|
||||
- `sendEndTime`:配送员点击“确认送达”的时间(建议 datetime)
|
||||
- `sendEndImg`:送达拍照留档图片 URL(可选/必填由后端策略决定;建议 varchar(512))
|
||||
- `receiveConfirmTime`:客户确认收货时间(建议 datetime)
|
||||
- `receiveConfirmType`:10客户手动确认、20配送照片自动确认、30超时自动确认
|
||||
|
||||
数据库变更(示例SQL见:`docs/sql/2026-02-06_glt_ticket_order_delivery_fields.sql`)。
|
||||
|
||||
强烈建议把“配送状态”与“业务状态(status=0/1、deleted=0/1)”分开,避免混用:
|
||||
- `status/deleted`:系统通用字段(现有逻辑)
|
||||
- `deliveryStatus`:配送流程状态(本需求新增)
|
||||
|
||||
## 3) 状态流转与校验(强烈建议在后端做)
|
||||
请在更新订单时做状态机校验,避免前端绕过流程:
|
||||
- `10 -> 20`:仅允许订单属于当前配送员,且未开始/未送达
|
||||
- `20 -> 30`:配送员确认送达(可带 `sendEndImg`)
|
||||
- `20/30 -> 40`:完成;来源可能是
|
||||
- 客户手动确认(写 `receiveConfirmTime` + `receiveConfirmType=10`)
|
||||
- 配送照片直接完成(写 `receiveConfirmTime` + `receiveConfirmType=20`,并要求 `sendEndImg`)
|
||||
- 超时自动确认(写 `receiveConfirmTime` + `receiveConfirmType=30`,建议由定时任务执行)
|
||||
|
||||
并发/幂等建议(避免重复点击/重复请求带来的脏数据):
|
||||
- 所有“状态变更接口”用条件更新实现原子校验:`UPDATE ... SET ... WHERE id=? AND rider_id=? AND delivery_status=? AND deleted=0`
|
||||
- 对重复调用做幂等:
|
||||
- `start`:如果已是 20 则直接返回成功;如果已到 30/40 返回“状态不允许”
|
||||
- `delivered`:如果已是 30/40 则返回成功(或提示已送达);避免重复写 `sendEndTime`
|
||||
- `confirm-receive`:如果已是 40 则返回成功(或提示已完成)
|
||||
|
||||
## 4) 建议新增/明确的接口能力
|
||||
为了避免并发抢单/越权更新,建议新增更语义化的接口(或在 update 内做等价校验):
|
||||
- 接单(抢单/派单):`POST /api/glt/glt-ticket-order/{id}/accept`
|
||||
- 配送员端:后端原子校验:仅当 `rider_id IS NULL`(或为 0)时才能写入当前 rider 信息
|
||||
- 管理端派单:允许传 `riderId`,但需校验骑手归属门店/租户(如有该约束)
|
||||
- 开始配送:`POST /api/glt/glt-ticket-order/{id}/start`
|
||||
- 写:`sendStartTime=now`、`deliveryStatus=20`
|
||||
- 校验:必须 `riderId=当前登录配送员` 且当前 `deliveryStatus=10`
|
||||
- 确认送达:`POST /api/glt/glt-ticket-order/{id}/delivered`
|
||||
- 入参:`sendEndImg`(可选/必填,按策略)
|
||||
- 写:`sendEndTime=now`、`deliveryStatus=30`、`sendEndImg`
|
||||
- 可选策略 A(推荐可配置):若 `sendEndImg` 必填且存在,则可直接 `deliveryStatus=40` 并写 `receiveConfirmTime/Type=20`
|
||||
- 客户确认收货:`POST /api/glt/glt-ticket-order/{id}/confirm-receive`
|
||||
- 校验:只能本人 `userId` 操作,且必须 `deliveryStatus=30`
|
||||
- 写:`deliveryStatus=40`、`receiveConfirmTime=now`、`receiveConfirmType=10`
|
||||
|
||||
接口返回建议:
|
||||
- 成功统一返回 `ApiResult.success(...)`
|
||||
- 失败请返回明确 msg(例如:`无权限`、`订单不存在`、`订单状态不允许`、`订单已被其他配送员接单`)
|
||||
|
||||
## 5) 为了“导航到收货地址/取货点”的字段补充(建议)
|
||||
当前仅有 `address` 字符串,无法在小程序内 `openLocation` 精准导航;建议补充:
|
||||
- 收货地址(推荐至少返回):`receiverName`、`receiverPhone`、`province/city/region/address/fullAddress`、`lat/lng`
|
||||
- 取货点(门店/仓库,推荐至少返回):`store.lngAndLat`、`warehouse.lngAndLat`
|
||||
|
||||
实现方式二选一:
|
||||
- 方式 A(更快):查询时关联 `shop_user_address`、`shop_store`、`shop_warehouse`,把经纬度字段透出给前端。
|
||||
- 方式 B(更稳):下单时把收货地址的 `name/phone/lat/lng/fullAddress` 以及门店/仓库 `lngAndLat` 做快照写入订单,避免后续数据变更影响历史订单导航。
|
||||
|
||||
## 6)(可选但很有用)超时自动确认规则
|
||||
- 建议后端提供可配置项:`autoConfirmHours`(例如 24h/48h)
|
||||
- 定时任务扫描:`deliveryStatus=30` 且 `sendEndTime < now - autoConfirmHours` 的订单
|
||||
- 原子更新:只更新仍处于 30 的订单,写入 `deliveryStatus=40`、`receiveConfirmTime=now`、`receiveConfirmType=30`
|
||||
|
||||
## 7)(可选)字段/枚举建议(便于前后端对齐)
|
||||
- `deliveryStatus`:10待配送、20配送中、30待客户确认、40已完成
|
||||
- `receiveConfirmType`:10客户手动确认、20配送照片自动确认、30超时自动确认
|
||||
- 时间字段统一返回格式:`yyyy-MM-dd HH:mm:ss`(与项目现有 `@JsonFormat` 风格一致)
|
||||
@@ -38,11 +38,6 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- spring-boot-web -->
|
||||
<dependency>
|
||||
@@ -218,6 +213,8 @@
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.4.3</version>
|
||||
</dependency>
|
||||
<!-- 证件 OCR(身份证/营业执照识别)已改用百度云 REST 接口,不再依赖 aliyun-java-sdk-ocr:
|
||||
理由见 ADR-0003《证件 OCR 改用百度云》,调用封装在 com.gxwebsoft.hjc.ocr.HjcBaiduOcrClient -->
|
||||
<!--阿里支付 老版本 SDK-->
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
#!/bin/bash
|
||||
|
||||
###############################################################################
|
||||
# 捐款证书中文乱码修复脚本
|
||||
# 用途:在运行中的Docker容器内安装中文字体
|
||||
# 适用于:无法重新构建镜像的紧急情况
|
||||
###############################################################################
|
||||
|
||||
set -e # 遇到错误立即退出
|
||||
|
||||
# 颜色输出
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 容器名称(可根据实际情况修改)
|
||||
CONTAINER_NAME="websoft-api-container"
|
||||
|
||||
echo -e "${GREEN}================================${NC}"
|
||||
echo -e "${GREEN}中文字体修复脚本${NC}"
|
||||
echo -e "${GREEN}================================${NC}"
|
||||
echo ""
|
||||
|
||||
# 检查容器是否存在
|
||||
echo -e "${YELLOW}步骤 1/6: 检查容器状态...${NC}"
|
||||
if ! docker ps | grep -q "$CONTAINER_NAME"; then
|
||||
echo -e "${RED}错误:容器 $CONTAINER_NAME 未运行!${NC}"
|
||||
echo "当前运行的容器:"
|
||||
docker ps --format "table {{.Names}}\t{{.Status}}"
|
||||
echo ""
|
||||
read -p "请输入正确的容器名称: " CONTAINER_NAME
|
||||
if [ -z "$CONTAINER_NAME" ]; then
|
||||
echo -e "${RED}容器名称不能为空,退出。${NC}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo -e "${GREEN}✓ 容器正在运行${NC}"
|
||||
echo ""
|
||||
|
||||
# 检查是否已安装字体
|
||||
echo -e "${YELLOW}步骤 2/6: 检查是否已安装中文字体...${NC}"
|
||||
if docker exec "$CONTAINER_NAME" fc-list :lang=zh 2>/dev/null | grep -q "WenQuanYi"; then
|
||||
echo -e "${GREEN}✓ 中文字体已安装${NC}"
|
||||
docker exec "$CONTAINER_NAME" fc-list :lang=zh
|
||||
echo ""
|
||||
read -p "是否重新安装?(y/N): " REINSTALL
|
||||
if [[ ! "$REINSTALL" =~ ^[Yy]$ ]]; then
|
||||
echo "跳过安装,退出。"
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
echo -e "${YELLOW}未检测到中文字体,开始安装...${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 安装字体工具
|
||||
echo -e "${YELLOW}步骤 3/6: 安装字体工具...${NC}"
|
||||
docker exec -u root "$CONTAINER_NAME" sh -c "apk add --no-cache fontconfig ttf-dejavu wget" || {
|
||||
echo -e "${RED}✗ 字体工具安装失败${NC}"
|
||||
exit 1
|
||||
}
|
||||
echo -e "${GREEN}✓ 字体工具安装成功${NC}"
|
||||
echo ""
|
||||
|
||||
# 下载中文字体
|
||||
echo -e "${YELLOW}步骤 4/6: 下载文泉驿微米黑字体...${NC}"
|
||||
echo "正在从GitHub下载(约10MB),请稍候..."
|
||||
docker exec -u root "$CONTAINER_NAME" sh -c "
|
||||
wget -O /tmp/wqy-microhei.ttc https://github.com/anthonyfok/fonts-wqy-microhei/raw/master/wqy-microhei.ttc 2>&1 | grep -E 'Connecting|Length|saved' || true
|
||||
" || {
|
||||
echo -e "${YELLOW}GitHub下载失败,尝试使用代理...${NC}"
|
||||
docker exec -u root "$CONTAINER_NAME" sh -c "
|
||||
wget -O /tmp/wqy-microhei.ttc https://ghproxy.com/https://github.com/anthonyfok/fonts-wqy-microhei/raw/master/wqy-microhei.ttc
|
||||
" || {
|
||||
echo -e "${RED}✗ 字体下载失败${NC}"
|
||||
echo "请检查网络连接或手动下载字体文件。"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
echo -e "${GREEN}✓ 字体下载成功${NC}"
|
||||
echo ""
|
||||
|
||||
# 安装字体
|
||||
echo -e "${YELLOW}步骤 5/6: 安装字体文件...${NC}"
|
||||
docker exec -u root "$CONTAINER_NAME" sh -c "
|
||||
mkdir -p /usr/share/fonts/truetype/wqy && \
|
||||
mv /tmp/wqy-microhei.ttc /usr/share/fonts/truetype/wqy/ && \
|
||||
fc-cache -fv
|
||||
" || {
|
||||
echo -e "${RED}✗ 字体安装失败${NC}"
|
||||
exit 1
|
||||
}
|
||||
echo -e "${GREEN}✓ 字体安装成功${NC}"
|
||||
echo ""
|
||||
|
||||
# 验证安装
|
||||
echo -e "${YELLOW}步骤 6/6: 验证字体安装...${NC}"
|
||||
FONT_COUNT=$(docker exec "$CONTAINER_NAME" fc-list :lang=zh | wc -l)
|
||||
if [ "$FONT_COUNT" -gt 0 ]; then
|
||||
echo -e "${GREEN}✓ 中文字体验证成功!${NC}"
|
||||
echo "已安装的中文字体:"
|
||||
docker exec "$CONTAINER_NAME" fc-list :lang=zh
|
||||
else
|
||||
echo -e "${RED}✗ 字体验证失败${NC}"
|
||||
exit 1
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 完成提示
|
||||
echo -e "${GREEN}================================${NC}"
|
||||
echo -e "${GREEN}修复完成!${NC}"
|
||||
echo -e "${GREEN}================================${NC}"
|
||||
echo ""
|
||||
echo "后续步骤:"
|
||||
echo "1. 不需要重启容器,字体已生效"
|
||||
echo "2. 重新生成捐款证书即可看到效果"
|
||||
echo "3. 如果仍有问题,请查看容器日志:"
|
||||
echo " docker logs -f $CONTAINER_NAME"
|
||||
echo ""
|
||||
echo -e "${YELLOW}注意:${NC}"
|
||||
echo "- 此修复方法在容器重启后会失效"
|
||||
echo "- 建议后续使用更新后的Dockerfile重新构建镜像"
|
||||
echo "- 详细文档请参考:docs/chinese-font-fix-guide.md"
|
||||
echo ""
|
||||
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
汇吉采 <-- 一站式:推送标书项目测试脚本(入向 POST /api/hjc/push/project)
|
||||
|
||||
用法:
|
||||
python hjc_test_push.py # 默认 http://uk.frp.one:62335
|
||||
python hjc_test_push.py http://uk.frp.one:62335
|
||||
python hjc_test_push.py --base http://uk.frp.one:62335 --project-no TEST-xxx
|
||||
|
||||
无第三方依赖,仅标准库(hashlib + urllib)。时间用北京时间(UTC+8)。
|
||||
签名 sign = MD5(appKey + password + timestamp),timestamp = yyyyMMddHHmm。
|
||||
"""
|
||||
import sys
|
||||
import json
|
||||
import hashlib
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
import datetime
|
||||
|
||||
APP_KEY = "HJC_Official_Website"
|
||||
PASSWORD = "vQ8$kR3#mW6@xP2!nF"
|
||||
DEFAULT_BASE = "http://uk.frp.one:62335"
|
||||
|
||||
DEFAULT_PAYLOAD = {
|
||||
"projectNo": "TEST-HJC-20260801",
|
||||
"projectName": "测试标书项目·服务器采购",
|
||||
"category": "货物类",
|
||||
"tenderPrice": 500.00,
|
||||
"files": "[{\"name\":\"招标文件.pdf\",\"url\":\"https://file.example.com/t.pdf\"}]",
|
||||
"tenderOnsaleTime": "2026-08-01 09:00:00",
|
||||
"tenderOffsaleTime": "2026-08-10 17:00:00",
|
||||
"bulletinName": "中标公告-测试",
|
||||
"customerName": "某招标单位",
|
||||
"supplierName": "某中标公司",
|
||||
"bidAmount": 128000.00,
|
||||
"content": "测试公告正文。中标供应商:某中标公司,中标金额 128000 元。",
|
||||
"fileList": "[{\"name\":\"中标通知书.pdf\",\"url\":\"https://file.example.com/n.pdf\"}]",
|
||||
"needSellTender": 1,
|
||||
"sellingMethod": 2
|
||||
}
|
||||
|
||||
|
||||
def bj_now() -> str:
|
||||
"""北京时间 yyyyMMddHHmm"""
|
||||
return (datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(hours=8)).strftime("%Y%m%d%H%M")
|
||||
|
||||
|
||||
def main():
|
||||
base = DEFAULT_BASE
|
||||
payload = dict(DEFAULT_PAYLOAD)
|
||||
args = sys.argv[1:]
|
||||
i = 0
|
||||
while i < len(args):
|
||||
a = args[i]
|
||||
if a in ("--base", "-b"):
|
||||
base = args[i + 1]
|
||||
i += 2
|
||||
elif a in ("--project-no", "-p"):
|
||||
payload["projectNo"] = args[i + 1]
|
||||
i += 2
|
||||
elif a == "--json":
|
||||
with open(args[i + 1], encoding="utf-8") as f:
|
||||
payload = json.load(f)
|
||||
i += 2
|
||||
else:
|
||||
base = a # 位置参数作为 baseUrl
|
||||
i += 1
|
||||
|
||||
url = base.rstrip("/") + "/api/hjc/push/project"
|
||||
ts = bj_now()
|
||||
sign = hashlib.md5((APP_KEY + PASSWORD + ts).encode("utf-8")).hexdigest()
|
||||
body = json.dumps(payload, ensure_ascii=False).encode("utf-8")
|
||||
|
||||
req = urllib.request.Request(url, data=body, method="POST", headers={
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"appKey": APP_KEY,
|
||||
"timestamp": ts,
|
||||
"sign": sign,
|
||||
"tenantId": "10626"
|
||||
})
|
||||
|
||||
print("== 请求 ==")
|
||||
print("URL:", url)
|
||||
print("timestamp:", ts, "| sign:", sign)
|
||||
print("body:", body.decode("utf-8"))
|
||||
print()
|
||||
print("== 响应 ==")
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=20) as resp:
|
||||
print("HTTP", resp.status)
|
||||
print(resp.read().decode("utf-8"))
|
||||
except urllib.error.HTTPError as e:
|
||||
print("HTTP", e.code)
|
||||
print(e.read().decode("utf-8"))
|
||||
except Exception as e:
|
||||
print("ERROR:", type(e).__name__, e)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,657 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
汇吉采 → 一站式:**出向**推送联调探测脚本(POST {base-url}{create-purchase-details-path})
|
||||
|
||||
与同目录 hjc_test_push.py(入向:一站式 → 官方网 /api/hjc/push/project)互为反向。
|
||||
|
||||
用途:一条命令回答「出向对接到底通没通、卡在哪一层」。
|
||||
脚本会自动做三件事:
|
||||
1. 按文档约定的签名方案(sign = MD5(appKey + password + timestamp))发起真实推送;
|
||||
2. 额外遍历若干鉴权头变体(含 password 明文头等历史解读),用于区分「签名不对」与「根本没校验签名」;
|
||||
3. 用对照探测把失败定位到具体一层:登录过滤器 / 路由不存在 / 验签失败 / 网络不可达。
|
||||
|
||||
默认参数自动从仓库读取,避免与代码脱节:
|
||||
- application.yml → hjc.one-stop.base-url、create-purchase-details-path
|
||||
- HjcOneStopAuthUtil.java → APP_KEY、PASSWORD
|
||||
|
||||
用法::
|
||||
|
||||
python hjc_test_push_out.py # 全量:约定方案 + 变体矩阵 + 对照探测
|
||||
python hjc_test_push_out.py --quick # 只打约定方案(日常回归用)
|
||||
python hjc_test_push_out.py --repeat 3 # 约定方案连打 3 次(同一订单号,验幂等)
|
||||
python hjc_test_push_out.py --base http://x:8810 --path /api/biz/createPurchaseDetails
|
||||
python hjc_test_push_out.py --order-no HJC2026080101ABCD --json result.json
|
||||
python hjc_test_push_out.py --dry-run # 只打印将要发出的请求,不真的发
|
||||
|
||||
订单号默认是固定值 ``TEST-HJC-ORDER-20260801``(不随时间变化):它同时是一站式的幂等键,
|
||||
固定住才能重复验证幂等/状态流转,也不会每跑一次就在对方库里堆一条新订单;要换单号显式传 ``--order-no``。
|
||||
|
||||
退款报文(status=REFUNDED,必带 refundTime + refundReason,见 docs/一站式平台对接-接口文档.md §3.4)::
|
||||
|
||||
python hjc_test_push_out.py --refund --dry-run # 看退款报文长什么样
|
||||
python hjc_test_push_out.py --refund --quick # 打退款报文
|
||||
python hjc_test_push_out.py --paid-then-refund # 同一订单号先 PAID 再 REFUNDED(推荐的联调姿势)
|
||||
python hjc_test_push_out.py --refund --order-no HJC2026080101ABCD \\
|
||||
--refund-reason "项目终止,客户申请退款" --refund-time "2026-08-03 09:15:00"
|
||||
|
||||
无第三方依赖,仅标准库。时间统一按北京时间(UTC+8)。
|
||||
|
||||
退出码:0=出向推送成功(收到 2xx);1=失败(并打印定位结论)。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import datetime as dt
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import ssl
|
||||
import sys
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
try: # Windows 控制台默认 GBK,强制 UTF-8 避免中文乱码
|
||||
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
||||
sys.stderr.reconfigure(encoding="utf-8", errors="replace")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 默认值 / 配置读取
|
||||
# --------------------------------------------------------------------------- #
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
MP_JAVA = os.path.dirname(HERE)
|
||||
APPLICATION_YML = os.path.join(MP_JAVA, "src", "main", "resources", "application.yml")
|
||||
AUTH_UTIL_JAVA = os.path.join(
|
||||
MP_JAVA, "src", "main", "java", "com", "gxwebsoft", "hjc", "util", "HjcOneStopAuthUtil.java"
|
||||
)
|
||||
|
||||
FALLBACK_BASE = "http://180.141.88.21:8810"
|
||||
FALLBACK_PATH = "/api/biz/createPurchaseDetails"
|
||||
FALLBACK_APP_KEY = "HJC_Official_Website"
|
||||
FALLBACK_PASSWORD = "vQ8$kR3#mW6@xP2!nF"
|
||||
|
||||
TS_FMT = "%Y%m%d%H%M"
|
||||
DT_FMT = "%Y-%m-%d %H:%M:%S"
|
||||
# argparse 的 help 会对 % 做格式化,展示用的时间格式需转义
|
||||
DT_FMT_HELP = DT_FMT.replace("%", "%%")
|
||||
|
||||
STATUS_PAID = "PAID"
|
||||
STATUS_REFUNDED = "REFUNDED"
|
||||
# 固定探测订单号:不随时间变化,重复运行始终命中一站式同一条记录。
|
||||
# 订单号同时是一站式幂等键(HJC_ORD_<orderNo>),固定值才能稳定验证幂等与状态流转,
|
||||
# 也不会每跑一次就在对方库里堆一条新订单。(与 hjc_test_push.py 固定 projectNo 同一思路)
|
||||
DEFAULT_ORDER_NO = "PROBE_202609111127"
|
||||
# 与 HjcBizServiceImpl.DEFAULT_REFUND_REASON 对齐:退款原因留空时官方网会兜底这个值
|
||||
DEFAULT_REFUND_REASON = "联调探测:客户申请退款"
|
||||
# 与 hjc_order.refund_reason 字段长度对齐(varchar(255))
|
||||
REFUND_REASON_MAX = 255
|
||||
|
||||
|
||||
def _read_text(path: str) -> str:
|
||||
try:
|
||||
with open(path, encoding="utf-8") as f:
|
||||
return f.read()
|
||||
except OSError:
|
||||
return ""
|
||||
|
||||
|
||||
def load_config() -> tuple[str, str]:
|
||||
"""从仓库读取 base-url / path,读不到则回退到内置值。"""
|
||||
base, path = FALLBACK_BASE, FALLBACK_PATH
|
||||
yml = _read_text(APPLICATION_YML)
|
||||
if yml:
|
||||
m = re.search(r'base-url:\s*"([^"]*)"', yml)
|
||||
if m and m.group(1).strip():
|
||||
base = m.group(1).strip()
|
||||
m = re.search(r"create-purchase-details-path:\s*(\S+)", yml)
|
||||
if m and m.group(1).strip():
|
||||
path = m.group(1).strip().strip('"')
|
||||
return base, path
|
||||
|
||||
|
||||
def load_credentials() -> tuple[str, str]:
|
||||
"""从 HjcOneStopAuthUtil.java 读取 APP_KEY / PASSWORD,读不到则回退。"""
|
||||
app_key, password = FALLBACK_APP_KEY, FALLBACK_PASSWORD
|
||||
java = _read_text(AUTH_UTIL_JAVA)
|
||||
if java:
|
||||
m = re.search(r'APP_KEY\s*=\s*"([^"]*)"', java)
|
||||
if m:
|
||||
app_key = m.group(1)
|
||||
m = re.search(r'PASSWORD\s*=\s*"([^"]*)"', java)
|
||||
if m:
|
||||
password = m.group(1)
|
||||
return app_key, password
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 签名 / 时间
|
||||
# --------------------------------------------------------------------------- #
|
||||
def bj_now() -> dt.datetime:
|
||||
return dt.datetime.now(dt.timezone.utc).astimezone(dt.timezone(dt.timedelta(hours=8)))
|
||||
|
||||
|
||||
def timestamp_str(now: dt.datetime) -> str:
|
||||
return now.strftime(TS_FMT)
|
||||
|
||||
|
||||
def sign_of(app_key: str, password: str, ts: str) -> str:
|
||||
return hashlib.md5((app_key + password + ts).encode("utf-8")).hexdigest()
|
||||
|
||||
|
||||
def md5(text: str) -> str:
|
||||
return hashlib.md5(text.encode("utf-8")).hexdigest()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# HTTP
|
||||
# --------------------------------------------------------------------------- #
|
||||
def post(url: str, body: bytes, headers: dict, timeout: float, insecure: bool = False):
|
||||
"""返回 (http_code, response_text, elapsed_ms, error)。http_code=0 表示网络层失败。"""
|
||||
req = urllib.request.Request(url, data=body, method="POST", headers=headers)
|
||||
ctx = ssl._create_unverified_context() if insecure else None
|
||||
t0 = time.monotonic()
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=timeout, context=ctx) as resp:
|
||||
text = resp.read().decode("utf-8", errors="replace")
|
||||
return resp.status, text, (time.monotonic() - t0) * 1000, None
|
||||
except urllib.error.HTTPError as e:
|
||||
text = e.read().decode("utf-8", errors="replace")
|
||||
return e.code, text, (time.monotonic() - t0) * 1000, None
|
||||
except Exception as e: # noqa: BLE001 - 网络层任何异常都归为不可达
|
||||
return 0, "", (time.monotonic() - t0) * 1000, f"{type(e).__name__}: {e}"
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 响应判定
|
||||
# --------------------------------------------------------------------------- #
|
||||
LOGIN_HINTS = ("token失效", "请重新登录", "未登录", "not login", "unauthorized")
|
||||
SIGN_HINTS = ("签名", "验签", "sign校验", "invalid signature", "signature")
|
||||
TS_HINTS = ("时间戳", "timestamp失效", "timestamp expired")
|
||||
|
||||
VERDICT_LABEL = {
|
||||
"OK": "✅ 通过",
|
||||
"LOGIN_FILTER": "🔒 登录过滤器拦截",
|
||||
"SIGN_REJECT": "❌ 验签被拒",
|
||||
"TS_REJECT": "❌ 时间戳被拒",
|
||||
"NOT_FOUND": "🚫 路由不存在(404)",
|
||||
"UNREACHABLE": "🌐 网络不可达",
|
||||
"OTHER": "❓ 其他",
|
||||
}
|
||||
|
||||
|
||||
def classify(status: int, body: str) -> str:
|
||||
if status == 0:
|
||||
return "UNREACHABLE"
|
||||
if 200 <= status < 300:
|
||||
return "OK"
|
||||
low = (body or "").lower()
|
||||
if any(h in low for h in TS_HINTS):
|
||||
return "TS_REJECT"
|
||||
if any(h in low for h in SIGN_HINTS):
|
||||
return "SIGN_REJECT"
|
||||
if any(h in low for h in LOGIN_HINTS):
|
||||
return "LOGIN_FILTER"
|
||||
if status == 404:
|
||||
return "NOT_FOUND"
|
||||
return "OTHER"
|
||||
|
||||
|
||||
def brief(body: str, limit: int = 160) -> str:
|
||||
one = " ".join((body or "").split())
|
||||
return one if len(one) <= limit else one[:limit] + "…"
|
||||
|
||||
|
||||
def fingerprint(status: int, body: str) -> str:
|
||||
"""响应的「错误语义指纹」:忽略每次都变的 timestamp/path 字段,只保留结论性字段。
|
||||
|
||||
用于判断两次响应是否表达同一个错误(例如真实接口与不存在路径都被同一个过滤器拒绝)。
|
||||
"""
|
||||
try:
|
||||
obj = json.loads(body)
|
||||
if isinstance(obj, dict):
|
||||
keep = {k: obj[k] for k in ("status", "error", "message") if k in obj}
|
||||
if keep:
|
||||
return json.dumps(keep, ensure_ascii=False, sort_keys=True)
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
return " ".join((body or "").split())[:200] or f"HTTP {status}"
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 报文
|
||||
# --------------------------------------------------------------------------- #
|
||||
def default_payload(
|
||||
order_no: str,
|
||||
now: dt.datetime,
|
||||
status: str = STATUS_PAID,
|
||||
refund_reason: str | None = None,
|
||||
refund_time: dt.datetime | None = None,
|
||||
) -> dict:
|
||||
"""构造 createPurchaseDetails 请求体。
|
||||
|
||||
status=REFUNDED 时追加 refundTime / refundReason(官方网侧同样只在退款单推这两个字段,
|
||||
见 HjcBizServiceImpl#buildCreatePurchaseDetails)。
|
||||
"""
|
||||
payload = {
|
||||
"idempotencyKey": "HJC_ORD_" + order_no,
|
||||
"orderNo": order_no,
|
||||
"projectNo": "HJC-GXZCY2-2026002",
|
||||
"projectName": "出向推送联调探测",
|
||||
"tenderPrice": 0.01,
|
||||
"quantity": 1,
|
||||
"totalAmount": 0.01,
|
||||
"buyer": {
|
||||
"enterpriseName": "联调探测企业",
|
||||
"creditCode": "91450000PROBE01",
|
||||
"contactName": "联调",
|
||||
"contactPhone": "13800000000",
|
||||
"contactEmail": "probe@example.com",
|
||||
},
|
||||
"paidAt": now.strftime(DT_FMT),
|
||||
"payMethod": "WECHAT_NATIVE",
|
||||
"status": status,
|
||||
"invoiceStatus": "NONE",
|
||||
}
|
||||
if status == STATUS_REFUNDED:
|
||||
reason = (refund_reason or "").strip() or DEFAULT_REFUND_REASON
|
||||
payload["refundTime"] = (refund_time or now).strftime(DT_FMT)
|
||||
payload["refundReason"] = reason[:REFUND_REASON_MAX]
|
||||
return payload
|
||||
|
||||
|
||||
def refund_payload_issues(payload: dict) -> list[str]:
|
||||
"""退款报文的本地自检:官方网/一站式都要求这两个字段非空,先在这里拦住低级错误。"""
|
||||
issues: list[str] = []
|
||||
if payload.get("status") != STATUS_REFUNDED:
|
||||
return issues
|
||||
for field in ("refundTime", "refundReason"):
|
||||
value = payload.get(field)
|
||||
if not isinstance(value, str) or not value.strip():
|
||||
issues.append(f"{field} 缺失或为空(退款推送必带)")
|
||||
rt = payload.get("refundTime")
|
||||
if isinstance(rt, str) and rt.strip():
|
||||
try:
|
||||
dt.datetime.strptime(rt.strip(), DT_FMT)
|
||||
except ValueError:
|
||||
issues.append(f"refundTime 格式应为 {DT_FMT}(当前: {rt})")
|
||||
reason = payload.get("refundReason")
|
||||
if isinstance(reason, str) and len(reason) > REFUND_REASON_MAX:
|
||||
issues.append(f"refundReason 超过 {REFUND_REASON_MAX} 字符(当前: {len(reason)})")
|
||||
return issues
|
||||
|
||||
|
||||
def case_matrix(app_key: str, password: str, ts: str, sign: str) -> list[tuple[str, dict, str]]:
|
||||
"""返回 [(方案名, 请求头, 说明)],方案 1 为文档约定方案。"""
|
||||
return [
|
||||
(
|
||||
"1 文档约定方案",
|
||||
{"appKey": app_key, "timestamp": ts, "sign": sign},
|
||||
"appKey+timestamp+sign(sign=MD5(appKey+password+timestamp))",
|
||||
),
|
||||
(
|
||||
"2 约定 + password 明文头",
|
||||
{"appKey": app_key, "timestamp": ts, "sign": sign, "password": password},
|
||||
"在原需求「明文 password 头」与现规范之间的折中",
|
||||
),
|
||||
(
|
||||
"3 仅 password 明文头",
|
||||
{"password": password},
|
||||
"只带密钥,不带 appKey/sign",
|
||||
),
|
||||
(
|
||||
"4 appKey + password 明文",
|
||||
{"appKey": app_key, "password": password, "timestamp": ts},
|
||||
"按原文需求字面实现(无 sign)",
|
||||
),
|
||||
(
|
||||
"5 双 MD5 解读",
|
||||
{"appKey": md5(app_key + ts), "password": md5(password + ts), "timestamp": ts},
|
||||
"原文「appKey+年月日时分,password+年月日时分,MD5加密」的另一种读法",
|
||||
),
|
||||
(
|
||||
"6 Authorization 头",
|
||||
{"appKey": app_key, "timestamp": ts, "Authorization": sign},
|
||||
"把签名放 Authorization,适配标准网关",
|
||||
),
|
||||
(
|
||||
"7 无任何鉴权头",
|
||||
{},
|
||||
"基准:对比有无鉴权头的响应差异",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 主流程
|
||||
# --------------------------------------------------------------------------- #
|
||||
def main() -> int:
|
||||
ap = argparse.ArgumentParser(
|
||||
description="汇吉采 → 一站式 出向推送联调探测",
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
)
|
||||
cfg_base, cfg_path = load_config()
|
||||
cfg_key, cfg_pwd = load_credentials()
|
||||
|
||||
ap.add_argument("--base", default=cfg_base, help=f"一站式 base-url(默认读配置: {cfg_base})")
|
||||
ap.add_argument("--path", default=cfg_path, help=f"推送路径(默认读配置: {cfg_path})")
|
||||
ap.add_argument("--appkey", default=cfg_key, help="appKey")
|
||||
ap.add_argument("--password", default=cfg_pwd, help="签名密钥 password")
|
||||
ap.add_argument("--order-no", default=DEFAULT_ORDER_NO, help=f"订单号(默认固定值 {DEFAULT_ORDER_NO})")
|
||||
ap.add_argument("--payload", default=None, help="自定义请求体 JSON 文件")
|
||||
ap.add_argument(
|
||||
"--refund",
|
||||
action="store_true",
|
||||
help="推退款报文(status=REFUNDED,带 refundTime/refundReason)",
|
||||
)
|
||||
ap.add_argument(
|
||||
"--paid-then-refund",
|
||||
action="store_true",
|
||||
help="同一订单号先推 PAID 基线、再推 REFUNDED(模拟真实退款状态流转)",
|
||||
)
|
||||
ap.add_argument(
|
||||
"--refund-reason",
|
||||
default=None,
|
||||
help=f"退款原因(默认「{DEFAULT_REFUND_REASON}」,最长 {REFUND_REASON_MAX} 字符)",
|
||||
)
|
||||
ap.add_argument(
|
||||
"--refund-time",
|
||||
default=None,
|
||||
help=f"退款时间,格式 {DT_FMT_HELP}(默认当前北京时间)",
|
||||
)
|
||||
ap.add_argument("--repeat", type=int, default=1, help="约定方案重复次数,用于验幂等(默认 1)")
|
||||
ap.add_argument("--timeout", type=float, default=15.0, help="单请求超时秒数(默认 15)")
|
||||
ap.add_argument("--quick", action="store_true", help="只跑约定方案,跳过变体矩阵与对照探测")
|
||||
ap.add_argument("--no-control", action="store_true", help="跳过对照探测(不额外打扰对方服务)")
|
||||
ap.add_argument("--dry-run", action="store_true", help="只打印请求,不发送")
|
||||
ap.add_argument("--insecure", action="store_true", help="跳过 HTTPS 证书校验")
|
||||
ap.add_argument("--json", dest="json_out", default=None, help="把完整结果写入 JSON 文件")
|
||||
args = ap.parse_args()
|
||||
|
||||
now = bj_now()
|
||||
ts = timestamp_str(now)
|
||||
sign = sign_of(args.appkey, args.password, ts)
|
||||
order_no = args.order_no
|
||||
url = args.base.rstrip("/") + args.path
|
||||
|
||||
refund_time = None
|
||||
if args.refund_time:
|
||||
try:
|
||||
refund_time = dt.datetime.strptime(args.refund_time.strip(), DT_FMT)
|
||||
except ValueError:
|
||||
print(f"❌ --refund-time 格式应为 {DT_FMT},收到:{args.refund_time}", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
want_refund = args.refund or args.paid_then_refund
|
||||
status = STATUS_REFUNDED if want_refund else STATUS_PAID
|
||||
if not want_refund and not args.payload and (args.refund_reason or args.refund_time):
|
||||
print(
|
||||
"⚠️ --refund-reason/--refund-time 仅在 --refund 或 --paid-then-refund 下生效"
|
||||
"(当前为 PAID 报文)",
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
if args.payload:
|
||||
if want_refund:
|
||||
print("⚠️ --payload 已指定,忽略 --refund/--paid-then-refund/--refund-reason/--refund-time", file=sys.stderr)
|
||||
with open(args.payload, encoding="utf-8") as f:
|
||||
payload = json.load(f)
|
||||
else:
|
||||
payload = default_payload(order_no, now, status, args.refund_reason, refund_time)
|
||||
|
||||
# 退款报文自检:本地先拦掉「必带字段缺失/时间格式错/超长」,避免白跑一轮联调
|
||||
issues = refund_payload_issues(payload)
|
||||
if issues:
|
||||
print("❌ 退款报文自检未通过:", file=sys.stderr)
|
||||
for it in issues:
|
||||
print(f" · {it}", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
# --paid-then-refund:同一订单号先落一条 PAID,再发 REFUNDED
|
||||
paid_body = None
|
||||
if args.paid_then_refund and not args.payload:
|
||||
paid_body = json.dumps(
|
||||
default_payload(order_no, now, STATUS_PAID), ensure_ascii=False
|
||||
).encode("utf-8")
|
||||
|
||||
body = json.dumps(payload, ensure_ascii=False).encode("utf-8")
|
||||
|
||||
print("=" * 78)
|
||||
print("汇吉采 → 一站式 出向推送探测" + ("(退款报文)" if payload.get("status") == STATUS_REFUNDED else ""))
|
||||
print("=" * 78)
|
||||
print(f"目标 URL : {url}")
|
||||
print(f"北京时间 : {now.strftime(DT_FMT)} → timestamp={ts}")
|
||||
print(f"appKey : {args.appkey}")
|
||||
print(f"sign : {sign}")
|
||||
print(f"订单号 : {order_no}")
|
||||
print(f"订单状态 : {payload.get('status')}")
|
||||
if payload.get("status") == STATUS_REFUNDED:
|
||||
print(f"退款时间 : {payload.get('refundTime')}")
|
||||
print(f"退款原因 : {payload.get('refundReason')}")
|
||||
print(f"请求体 : {body.decode('utf-8')}")
|
||||
if paid_body is not None:
|
||||
print()
|
||||
print("(--paid-then-refund:先发 PAID 基线)")
|
||||
print(f"请求体 : {paid_body.decode('utf-8')}")
|
||||
print()
|
||||
|
||||
if args.dry_run:
|
||||
print("[dry-run] 未发送任何请求。等价 curl:")
|
||||
if paid_body is not None:
|
||||
print(
|
||||
f" # 1) 同一订单号先落 PAID\n"
|
||||
f" curl -i -X POST '{url}' \\\n"
|
||||
f" -H 'Content-Type: application/json' \\\n"
|
||||
f" -H 'appKey: {args.appkey}' -H 'timestamp: {ts}' -H 'sign: {sign}' \\\n"
|
||||
f" -d '{paid_body.decode('utf-8')}'\n"
|
||||
f" # 2) 再推 REFUNDED(带退款时间/原因)"
|
||||
)
|
||||
print(
|
||||
f" curl -i -X POST '{url}' \\\n"
|
||||
f" -H 'Content-Type: application/json' \\\n"
|
||||
f" -H 'appKey: {args.appkey}' -H 'timestamp: {ts}' -H 'sign: {sign}' \\\n"
|
||||
f" -d '{body.decode('utf-8')}'"
|
||||
)
|
||||
return 0
|
||||
|
||||
results: list[dict] = []
|
||||
|
||||
def run_case(name: str, headers: dict, note: str, target_url: str = url, use_body: bytes = body):
|
||||
h = {"Content-Type": "application/json", **headers}
|
||||
status_code, text, ms, err = post(target_url, use_body, h, args.timeout, args.insecure)
|
||||
verdict = classify(status_code, text)
|
||||
results.append(
|
||||
{
|
||||
"name": name,
|
||||
"note": note,
|
||||
"url": target_url,
|
||||
"status": status_code,
|
||||
"verdict": verdict,
|
||||
"fingerprint": fingerprint(status_code, text),
|
||||
"elapsed_ms": round(ms, 1),
|
||||
"body": text,
|
||||
"error": err,
|
||||
}
|
||||
)
|
||||
shown = f"HTTP {status_code}" if status_code else "无响应"
|
||||
print(f" {name:<22} {shown:<9} {VERDICT_LABEL[verdict]:<18} {brief(err or text)}")
|
||||
return results[-1]
|
||||
|
||||
matrix = case_matrix(args.appkey, args.password, ts, sign)
|
||||
|
||||
# ---------------- 阶段 0:(可选)PAID 基线 ----------------
|
||||
# 退款推送要针对「已在一站式存在的订单」,故先用同一订单号落一条 PAID 记录。
|
||||
if paid_body is not None:
|
||||
print("── 阶段 0:PAID 基线(同一订单号,先建立已支付记录)──")
|
||||
run_case("0 PAID 基线", matrix[0][1], "退款前先落一条已支付记录", use_body=paid_body)
|
||||
print()
|
||||
|
||||
# ---------------- 阶段 1:约定方案(含 repeat 幂等验证) ----------------
|
||||
print(f"── 阶段 1:文档约定方案{'(连打 %d 次验幂等)' % args.repeat if args.repeat > 1 else ''} ──")
|
||||
primary = run_case(matrix[0][0], matrix[0][1], matrix[0][2])
|
||||
for i in range(2, args.repeat + 1):
|
||||
run_case(f"1 文档约定方案 #{i}", matrix[0][1], "幂等复打")
|
||||
|
||||
if not args.quick:
|
||||
# ---------------- 阶段 2:鉴权头变体 ----------------
|
||||
print()
|
||||
print("── 阶段 2:鉴权头变体矩阵(用于区分「签名不对」与「未校验签名」)──")
|
||||
for name, headers, note in matrix[1:]:
|
||||
run_case(name, headers, note)
|
||||
|
||||
# query 参数形式单独处理(不带请求头)
|
||||
q = urllib.parse.urlencode(
|
||||
{"appKey": args.appkey, "password": args.password, "timestamp": ts, "sign": sign}
|
||||
)
|
||||
run_case("8 query 参数", {}, "凭据放 URL query", target_url=f"{url}?{q}")
|
||||
|
||||
# ---------------- 阶段 3:对照探测 ----------------
|
||||
# 仅在失败时才有诊断价值;已成功就不再给对方发多余请求。
|
||||
controls: list[dict] = []
|
||||
if not args.no_control and primary["verdict"] != "OK":
|
||||
print()
|
||||
print("── 阶段 3:对照探测(定位失败发生在哪一层)──")
|
||||
parts = [p for p in args.path.strip("/").split("/") if p]
|
||||
if len(parts) >= 2:
|
||||
protected_nope = "/" + "/".join(parts[:-1] + ["__probe_nope__"])
|
||||
reference_nope = "/" + "/".join(parts[:1] + ["auth", "__probe_nope__"])
|
||||
ctl_headers = matrix[0][1]
|
||||
for label, p, note in (
|
||||
("C1 同前缀不存在路径", protected_nope, "若与目标接口响应一致 → 拦截发生在路由解析之前"),
|
||||
("C2 另一前缀不存在路径", reference_nope, "未受保护的参照组,应为干净的 404"),
|
||||
):
|
||||
controls.append(
|
||||
run_case(label, ctl_headers, note, target_url=args.base.rstrip("/") + p)
|
||||
)
|
||||
else:
|
||||
print(" (路径层级不足,跳过对照探测)")
|
||||
|
||||
# ---------------- 结论 ----------------
|
||||
print()
|
||||
print("=" * 78)
|
||||
print("结论")
|
||||
print("=" * 78)
|
||||
|
||||
primary_verdict = primary["verdict"]
|
||||
success = primary_verdict == "OK"
|
||||
|
||||
# 与「同前缀不存在路径」对照:错误语义一致说明根本没走到路由
|
||||
same_as_control = bool(
|
||||
controls
|
||||
and controls[0]["status"] == primary["status"]
|
||||
and controls[0]["fingerprint"] == primary["fingerprint"]
|
||||
)
|
||||
|
||||
if success:
|
||||
print("✅ 出向对接成功:目标接口返回 2xx,对方已接受并(应已)落盘。")
|
||||
if args.repeat > 1:
|
||||
ok_all = all(r["verdict"] == "OK" for r in results if r["name"].startswith("1 "))
|
||||
print(
|
||||
f" 幂等复打 {args.repeat} 次:{'全部 2xx ✅' if ok_all else '存在非 2xx,请检查幂等处理 ❌'}"
|
||||
)
|
||||
else:
|
||||
print(f"❌ 出向对接失败:约定方案判定为「{VERDICT_LABEL[primary_verdict]}」。")
|
||||
print()
|
||||
if primary_verdict == "LOGIN_FILTER":
|
||||
print("定位:请求被对方的**登录态过滤器**拒绝,与签名无关。依据:")
|
||||
if same_as_control:
|
||||
print(" · 同一套凭据打「同前缀下不存在的路径」,响应与真实接口**完全一致**")
|
||||
print(" → 拒绝发生在路由解析之前,接口是否存在、签名是否正确都影响不到它。")
|
||||
print(" · 响应体是登录错误而非「签名校验失败」,说明对方的验签逻辑没有被执行。")
|
||||
print()
|
||||
print("需对方处理:把该接口加入免登录白名单并实现约定验签,或提供获取调用 Token 的方式。")
|
||||
elif primary_verdict == "SIGN_REJECT":
|
||||
print("定位:对方已放行到验签逻辑,但签名不通过 → 属于**算法/密钥不一致**。")
|
||||
print("建议:让对方用下面这组固定值离线自证,无需部署:")
|
||||
print(f" appKey={args.appkey} timestamp={ts} sign={sign}")
|
||||
print(" 若对方算不出同一 sign,核对 password 取值与拼接顺序(是否含分隔符、大小写)。")
|
||||
elif primary_verdict == "TS_REJECT":
|
||||
print("定位:时间戳被拒 → 核对对方服务器时间与北京时区,以及允许窗口(约定 ±10 分钟)。")
|
||||
elif primary_verdict == "NOT_FOUND":
|
||||
print("定位:路由不存在 → 路径或 base-url 不对,需对方确认接口实际地址与端口。")
|
||||
elif primary_verdict == "UNREACHABLE":
|
||||
print(f"定位:网络不可达 → {primary['error']}")
|
||||
print("建议:确认对方服务已启动、端口开放、本机到该地址无防火墙/白名单限制。")
|
||||
else:
|
||||
print("未能自动归类,请把上面的响应原文提供给对方排查。")
|
||||
|
||||
# 变体是否出现「与基准不同」的响应——若全一致,进一步佐证签名未被校验
|
||||
if not args.quick:
|
||||
variants = [
|
||||
r
|
||||
for r in results
|
||||
if r["name"][0].isdigit() and not r["name"].startswith(("0 ", "1 "))
|
||||
]
|
||||
distinct = {r["fingerprint"] for r in variants}
|
||||
if len(distinct) <= 1 and variants:
|
||||
print()
|
||||
print("补充:全部鉴权头变体(含不带任何头的基准)响应**完全相同**")
|
||||
print(" → 对方当前没有对请求头做任何区分,签名校验尚未生效。")
|
||||
|
||||
# 退款模式补充结论:PAID 基线 + REFUNDED 是否都通过(退款字段是否被对方接受)
|
||||
if payload.get("status") == STATUS_REFUNDED:
|
||||
print()
|
||||
paid_base = next((r for r in results if r["name"].startswith("0 ")), None)
|
||||
if paid_base is not None:
|
||||
print(
|
||||
f"PAID 基线 : {VERDICT_LABEL[paid_base['verdict']]}(同一订单号 {order_no})"
|
||||
+ ("" if paid_base["verdict"] == "OK" else " ← 基线未通过,退款结果可能不可信")
|
||||
)
|
||||
print(
|
||||
f"REFUNDED 报文: {VERDICT_LABEL[primary_verdict]},"
|
||||
f"refundTime={payload.get('refundTime')} / refundReason={payload.get('refundReason')}"
|
||||
)
|
||||
|
||||
print()
|
||||
print(f"复现命令(可直接发给对方):")
|
||||
if paid_body is not None:
|
||||
print(
|
||||
f" # 1) 同一订单号先落 PAID\n"
|
||||
f" curl -i -X POST '{url}' -H 'Content-Type: application/json' \\\n"
|
||||
f" -H 'appKey: {args.appkey}' -H 'timestamp: {ts}' -H 'sign: {sign}' \\\n"
|
||||
f" -d '{paid_body.decode('utf-8')}'\n"
|
||||
f" # 2) 再推 REFUNDED(带退款时间/原因)"
|
||||
)
|
||||
print(
|
||||
f" curl -i -X POST '{url}' \\\n"
|
||||
f" -H 'Content-Type: application/json' \\\n"
|
||||
f" -H 'appKey: {args.appkey}' -H 'timestamp: {ts}' -H 'sign: {sign}' \\\n"
|
||||
f" -d '{body.decode('utf-8')}'"
|
||||
)
|
||||
|
||||
if args.json_out:
|
||||
with open(args.json_out, "w", encoding="utf-8") as f:
|
||||
json.dump(
|
||||
{
|
||||
"base": args.base,
|
||||
"path": args.path,
|
||||
"url": url,
|
||||
"timestamp": ts,
|
||||
"sign": sign,
|
||||
"appKey": args.appkey,
|
||||
"orderNo": order_no,
|
||||
"orderStatus": payload.get("status"),
|
||||
"refundTime": payload.get("refundTime"),
|
||||
"refundReason": payload.get("refundReason"),
|
||||
"paidThenRefund": args.paid_then_refund,
|
||||
"payload": payload,
|
||||
"results": results,
|
||||
"controls": controls,
|
||||
"verdict": primary_verdict,
|
||||
"success": success,
|
||||
},
|
||||
f,
|
||||
ensure_ascii=False,
|
||||
indent=2,
|
||||
)
|
||||
print(f"\n完整结果已写入:{args.json_out}")
|
||||
|
||||
return 0 if success else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -1,129 +0,0 @@
|
||||
package com.gxwebsoft.app.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.app.entity.AppConfig;
|
||||
import com.gxwebsoft.app.param.AppConfigParam;
|
||||
import com.gxwebsoft.app.service.AppConfigService;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 应用配置表 Controller
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "应用配置管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/app/app-config")
|
||||
public class AppConfigController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AppConfigService appConfigService;
|
||||
|
||||
/**
|
||||
* 分页查询应用配置
|
||||
*/
|
||||
@Operation(summary = "分页查询应用配置")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AppConfig>> page(AppConfigParam param) {
|
||||
return success(new PageResult<>(appConfigService.page(param)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用配置列表
|
||||
*/
|
||||
@Operation(summary = "获取应用配置列表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AppConfig>> list(AppConfigParam param) {
|
||||
return success(appConfigService.list(param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据应用ID获取配置映射
|
||||
*/
|
||||
@Operation(summary = "根据应用ID获取配置映射")
|
||||
@GetMapping("/map/{websiteId}")
|
||||
public ApiResult<Map<String, Object>> getConfigsByWebsiteId(@PathVariable Integer websiteId) {
|
||||
return success(appConfigService.getConfigsByWebsiteId(websiteId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个配置值
|
||||
*/
|
||||
@Operation(summary = "获取单个配置值")
|
||||
@GetMapping("/value")
|
||||
public ApiResult<String> getConfigValue(@RequestParam Integer websiteId, @RequestParam String configKey) {
|
||||
return success(appConfigService.getConfigValue(websiteId, configKey),null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存配置
|
||||
*/
|
||||
@Operation(summary = "保存配置")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AppConfig config) {
|
||||
appConfigService.saveConfig(config);
|
||||
return success("保存成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存配置
|
||||
*/
|
||||
@Operation(summary = "批量保存配置")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> batchSave(@RequestBody BatchSaveRequest request) {
|
||||
appConfigService.batchSaveConfig(request.getWebsiteId(), request.getConfigs());
|
||||
return success("保存成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新配置
|
||||
*/
|
||||
@Operation(summary = "更新配置")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AppConfig config) {
|
||||
appConfigService.updateConfig(config);
|
||||
return success("更新成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配置
|
||||
*/
|
||||
@Operation(summary = "删除配置")
|
||||
@DeleteMapping("/{configId}")
|
||||
public ApiResult<?> delete(@PathVariable Integer configId) {
|
||||
appConfigService.deleteConfig(configId);
|
||||
return success("删除成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存请求对象
|
||||
*/
|
||||
public static class BatchSaveRequest {
|
||||
private Integer websiteId;
|
||||
private List<AppConfig> configs;
|
||||
|
||||
public Integer getWebsiteId() {
|
||||
return websiteId;
|
||||
}
|
||||
|
||||
public void setWebsiteId(Integer websiteId) {
|
||||
this.websiteId = websiteId;
|
||||
}
|
||||
|
||||
public List<AppConfig> getConfigs() {
|
||||
return configs;
|
||||
}
|
||||
|
||||
public void setConfigs(List<AppConfig> configs) {
|
||||
this.configs = configs;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
package com.gxwebsoft.app.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.app.service.AppCredentialService;
|
||||
import com.gxwebsoft.app.entity.AppCredential;
|
||||
import com.gxwebsoft.app.param.AppCredentialParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用密钥凭证控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "应用密钥凭证管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/app/app-credential")
|
||||
public class AppCredentialController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AppCredentialService appCredentialService;
|
||||
|
||||
@Operation(summary = "分页查询应用密钥凭证")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AppCredential>> page(AppCredentialParam param) {
|
||||
return success(appCredentialService.pageRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询全部应用密钥凭证")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AppCredential>> list(AppCredentialParam param) {
|
||||
return success(appCredentialService.listRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据id查询应用密钥凭证")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AppCredential> get(@PathVariable("id") Integer id) {
|
||||
return success(appCredentialService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appCredential:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "创建应用密钥凭证(自动生成 AppID 和 AppSecret)")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AppCredential appCredential) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
appCredential.setUserId(loginUser.getUserId());
|
||||
// 创建并生成密钥
|
||||
AppCredential result = appCredentialService.createCredential(appCredential);
|
||||
return success("创建成功,请保存 AppSecret,该信息仅展示一次", result);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appCredential:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改应用密钥凭证(名称/类型/备注等,不含密钥)")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AppCredential appCredential) {
|
||||
// 防止通过此接口直接修改 appId/appSecret
|
||||
appCredential.setAppId(null);
|
||||
appCredential.setAppSecret(null);
|
||||
if (appCredentialService.updateById(appCredential)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appCredential:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "重置 AppSecret(重新生成密钥)")
|
||||
@PostMapping("/resetSecret/{id}")
|
||||
public ApiResult<?> resetSecret(@PathVariable("id") Long id) {
|
||||
try {
|
||||
AppCredential result = appCredentialService.resetSecret(id);
|
||||
return success("重置成功,请保存新 AppSecret,该信息仅展示一次", result);
|
||||
} catch (RuntimeException e) {
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appCredential:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "禁用/启用凭证")
|
||||
@PutMapping("/status/{id}/{status}")
|
||||
public ApiResult<?> updateStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
|
||||
if (appCredentialService.updateStatus(id, status)) {
|
||||
return success(status == 0 ? "已启用" : "已禁用");
|
||||
}
|
||||
return fail("操作失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appCredential:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除应用密钥凭证")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (appCredentialService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appCredential:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加应用密钥凭证")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<AppCredential> list) {
|
||||
if (appCredentialService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appCredential:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改应用密钥凭证")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> updateBatch(@RequestBody BatchParam<AppCredential> batchParam) {
|
||||
if (batchParam.update(appCredentialService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appCredential:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除应用密钥凭证")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (appCredentialService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package com.gxwebsoft.app.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.app.service.AppEventService;
|
||||
import com.gxwebsoft.app.entity.AppEvent;
|
||||
import com.gxwebsoft.app.param.AppEventParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用操作动态控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "应用操作动态管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/app/app-event")
|
||||
public class AppEventController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AppEventService appEventService;
|
||||
|
||||
@Operation(summary = "分页查询操作动态")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AppEvent>> page(AppEventParam param) {
|
||||
return success(appEventService.pageRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询全部操作动态")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AppEvent>> list(AppEventParam param) {
|
||||
return success(appEventService.listRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据id查询操作动态")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AppEvent> get(@PathVariable("id") Integer id) {
|
||||
return success(appEventService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取应用最新一条动态(用于卡片展示)")
|
||||
@GetMapping("/latest/{websiteId}")
|
||||
public ApiResult<AppEvent> getLatest(@PathVariable("websiteId") Long websiteId) {
|
||||
return success(appEventService.getLatestEvent(websiteId));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appEvent:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "手动记录操作动态")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AppEvent appEvent) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
appEvent.setUserId(loginUser.getUserId());
|
||||
appEvent.setTenantId(loginUser.getTenantId());
|
||||
if (appEvent.getOperatorId() == null) {
|
||||
appEvent.setOperatorId(loginUser.getUserId().longValue());
|
||||
}
|
||||
if (appEvent.getOperator() == null) {
|
||||
appEvent.setOperator(loginUser.getNickname());
|
||||
}
|
||||
}
|
||||
if (appEventService.save(appEvent)) {
|
||||
return success("记录成功");
|
||||
}
|
||||
return fail("记录失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appEvent:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改操作动态")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AppEvent appEvent) {
|
||||
if (appEventService.updateById(appEvent)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appEvent:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除操作动态")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (appEventService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appEvent:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "清空应用所有动态记录")
|
||||
@DeleteMapping("/clear/{websiteId}")
|
||||
public ApiResult<?> clearByWebsiteId(@PathVariable("websiteId") Long websiteId) {
|
||||
// 只清空当前租户下的数据
|
||||
AppEventParam param = new AppEventParam();
|
||||
param.setWebsiteId(websiteId);
|
||||
List<AppEvent> list = appEventService.listRel(param);
|
||||
if (list.isEmpty()) {
|
||||
return success("暂无动态记录");
|
||||
}
|
||||
List<Long> ids = list.stream().map(AppEvent::getId).collect(java.util.stream.Collectors.toList());
|
||||
if (appEventService.removeByIds(ids)) {
|
||||
return success("已清空 " + ids.size() + " 条动态记录");
|
||||
}
|
||||
return fail("清空失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appEvent:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除操作动态")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (appEventService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
package com.gxwebsoft.app.controller;
|
||||
|
||||
import com.gxwebsoft.app.entity.AppResource;
|
||||
import com.gxwebsoft.app.param.AppResourceParam;
|
||||
import com.gxwebsoft.app.service.AppResourceService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 开发者资源管理控制器(服务器/数据库/云存储/域名/SSL)
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-31
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "开发者资源管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/app/developer-resource")
|
||||
public class AppResourceController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AppResourceService appResourceService;
|
||||
|
||||
// ─── 查询接口 ─────────────────────────────────────────────────
|
||||
|
||||
@Operation(summary = "分页查询资源列表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AppResource>> page(AppResourceParam param) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录", null);
|
||||
// 普通开发者只能查自己的资源
|
||||
param.setUserId(loginUser.getUserId());
|
||||
param.setTenantId(loginUser.getTenantId());
|
||||
return success(appResourceService.pageRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询资源列表(不分页)")
|
||||
@GetMapping
|
||||
public ApiResult<List<AppResource>> list(AppResourceParam param) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录", null);
|
||||
param.setUserId(loginUser.getUserId());
|
||||
param.setTenantId(loginUser.getTenantId());
|
||||
return success(appResourceService.listRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取资源详情")
|
||||
@GetMapping("/{resourceId}")
|
||||
public ApiResult<AppResource> get(@PathVariable Long resourceId) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录", null);
|
||||
AppResource resource = appResourceService.getByIdRel(resourceId);
|
||||
if (resource == null) return fail("资源不存在", null);
|
||||
if (!resource.getUserId().equals(loginUser.getUserId())) return fail("无权访问此资源", null);
|
||||
return success(resource);
|
||||
}
|
||||
|
||||
@Operation(summary = "统计各类型资源数量")
|
||||
@GetMapping("/stats")
|
||||
public ApiResult<Map<String, Long>> stats() {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录", null);
|
||||
return success(appResourceService.countByType(loginUser.getUserId(), loginUser.getTenantId()));
|
||||
}
|
||||
|
||||
// ─── 新增/修改接口 ────────────────────────────────────────────
|
||||
|
||||
@OperationLog
|
||||
@Operation(summary = "新增资源")
|
||||
@PostMapping
|
||||
public ApiResult<AppResource> save(@RequestBody AppResource resource) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录", null);
|
||||
if (resource.getResourceType() == null || resource.getResourceType().isEmpty()) {
|
||||
return fail("资源类型不能为空", null);
|
||||
}
|
||||
if (resource.getName() == null || resource.getName().isEmpty()) {
|
||||
return fail("资源名称不能为空", null);
|
||||
}
|
||||
resource.setTenantId(loginUser.getTenantId());
|
||||
try {
|
||||
AppResource result = appResourceService.addResource(resource, loginUser.getUserId());
|
||||
return success("添加成功", result);
|
||||
} catch (Exception e) {
|
||||
return fail(e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@Operation(summary = "修改资源")
|
||||
@PutMapping
|
||||
public ApiResult<AppResource> update(@RequestBody AppResource resource) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录", null);
|
||||
try {
|
||||
AppResource result = appResourceService.updateResource(resource);
|
||||
return success("修改成功", result);
|
||||
} catch (Exception e) {
|
||||
return fail(e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── 删除接口 ─────────────────────────────────────────────────
|
||||
|
||||
@OperationLog
|
||||
@Operation(summary = "删除资源(逻辑删除)")
|
||||
@DeleteMapping("/{resourceId}")
|
||||
public ApiResult<?> remove(@PathVariable Long resourceId) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录");
|
||||
try {
|
||||
appResourceService.removeResource(resourceId, loginUser.getUserId());
|
||||
return success("删除成功");
|
||||
} catch (Exception e) {
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除资源")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Long> ids) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录");
|
||||
try {
|
||||
for (Long id : ids) {
|
||||
appResourceService.removeResource(id, loginUser.getUserId());
|
||||
}
|
||||
return success("批量删除成功");
|
||||
} catch (Exception e) {
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
package com.gxwebsoft.app.controller;
|
||||
|
||||
import com.gxwebsoft.app.entity.AppTicket;
|
||||
import com.gxwebsoft.app.entity.AppTicketReply;
|
||||
import com.gxwebsoft.app.param.AppTicketParam;
|
||||
import com.gxwebsoft.app.service.AppTicketService;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 应用工单控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-30
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "应用工单管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/app/ticket")
|
||||
public class AppTicketController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AppTicketService appTicketService;
|
||||
|
||||
// ─── 客户端接口 ────────────────────────────────────────────────
|
||||
|
||||
@Operation(summary = "查询我的工单(分页)")
|
||||
@GetMapping("/my")
|
||||
public ApiResult<PageResult<AppTicket>> myTickets(AppTicketParam param) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录",null);
|
||||
return success(appTicketService.myPage(param, loginUser.getUserId()));
|
||||
}
|
||||
|
||||
@Operation(summary = "提交工单")
|
||||
@PostMapping("/submit")
|
||||
public ApiResult<AppTicket> submit(@RequestBody AppTicket ticket) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录",null);
|
||||
try {
|
||||
AppTicket result = appTicketService.submit(ticket, loginUser.getUserId());
|
||||
return success("工单提交成功", result);
|
||||
} catch (Exception e) {
|
||||
return fail(e.getMessage(),null);
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "关闭工单(提交人)")
|
||||
@PutMapping("/{ticketId}/close")
|
||||
public ApiResult<?> close(@PathVariable Long ticketId) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录");
|
||||
try {
|
||||
appTicketService.closeByUser(ticketId, loginUser.getUserId());
|
||||
return success("工单已关闭");
|
||||
} catch (Exception e) {
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ─── 技术端接口 ────────────────────────────────────────────────
|
||||
|
||||
@Operation(summary = "查询所有工单(技术人员)")
|
||||
@GetMapping("/list")
|
||||
public ApiResult<PageResult<AppTicket>> allTickets(AppTicketParam param) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录",null);
|
||||
return success(appTicketService.allPage(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取工单详情")
|
||||
@GetMapping("/{ticketId}")
|
||||
public ApiResult<AppTicket> detail(@PathVariable Long ticketId) {
|
||||
return success(appTicketService.getById(ticketId));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新工单状态(技术人员)")
|
||||
@PutMapping("/status")
|
||||
public ApiResult<?> updateStatus(@RequestBody Map<String, Object> body) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录");
|
||||
Long ticketId = Long.valueOf(body.get("ticketId").toString());
|
||||
String status = body.get("status").toString();
|
||||
appTicketService.updateStatus(ticketId, status, loginUser.getUserId());
|
||||
return success("状态已更新");
|
||||
}
|
||||
|
||||
@Operation(summary = "分配处理人(管理员)")
|
||||
@PutMapping("/assign")
|
||||
public ApiResult<?> assign(@RequestBody Map<String, Object> body) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录");
|
||||
Long ticketId = Long.valueOf(body.get("ticketId").toString());
|
||||
Integer assigneeId = Integer.valueOf(body.get("assigneeId").toString());
|
||||
appTicketService.assign(ticketId, assigneeId);
|
||||
return success("分配成功");
|
||||
}
|
||||
|
||||
// ─── 回复接口 ─────────────────────────────────────────────────
|
||||
|
||||
@Operation(summary = "获取工单回复列表")
|
||||
@GetMapping("/{ticketId}/replies")
|
||||
public ApiResult<List<AppTicketReply>> replies(@PathVariable Long ticketId) {
|
||||
return success(appTicketService.getReplies(ticketId));
|
||||
}
|
||||
|
||||
@Operation(summary = "提交工单回复")
|
||||
@PostMapping("/reply")
|
||||
public ApiResult<AppTicketReply> reply(@RequestBody AppTicketReply reply) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录",null);
|
||||
if (reply.getContent() == null || reply.getContent().trim().isEmpty()) {
|
||||
return fail("回复内容不能为空",null);
|
||||
}
|
||||
try {
|
||||
AppTicketReply result = appTicketService.addReply(reply, loginUser.getUserId());
|
||||
return success("回复成功", result);
|
||||
} catch (Exception e) {
|
||||
return fail(e.getMessage(),null);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── 统计 & 辅助 ─────────────────────────────────────────────
|
||||
|
||||
@Operation(summary = "工单统计数据")
|
||||
@GetMapping("/stats")
|
||||
public ApiResult<Map<String, Long>> stats(
|
||||
@RequestParam(required = false) Long websiteId) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) return fail("请先登录",null);
|
||||
// 技术端不限制用户维度;客户端通过路由区分
|
||||
return success(appTicketService.stats(websiteId, null));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取技术人员列表(用于分配)")
|
||||
@GetMapping("/staff-list")
|
||||
public ApiResult<List<Map<String, Object>>> staffList() {
|
||||
return success(appTicketService.getTechStaffList());
|
||||
}
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
package com.gxwebsoft.app.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.app.service.AppUserService;
|
||||
import com.gxwebsoft.app.entity.AppUser;
|
||||
import com.gxwebsoft.app.param.AppUserParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用成员控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "应用成员管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/app/app-user")
|
||||
public class AppUserController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AppUserService appUserService;
|
||||
|
||||
@Operation(summary = "分页查询应用成员")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AppUser>> page(AppUserParam param) {
|
||||
return success(appUserService.pageRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询全部应用成员")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AppUser>> list(AppUserParam param) {
|
||||
return success(appUserService.listRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据id查询应用成员")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AppUser> get(@PathVariable("id") Integer id) {
|
||||
return success(appUserService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appUser:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加应用成员(手动添加)")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AppUser appUser) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
appUser.setUserId(loginUser.getUserId());
|
||||
appUser.setTenantId(loginUser.getTenantId());
|
||||
}
|
||||
if (appUserService.save(appUser)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@Operation(summary = "邀请用户成为应用成员(支持用户ID或手机号)")
|
||||
@PostMapping("/invite")
|
||||
public ApiResult<?> invite(@RequestBody AppUser appUser) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
// 支持手机号邀请:若 userId 为空但传了 phone,则先按手机号查出用户
|
||||
if (appUser.getUserId() == null && appUser.getPhone() != null && !appUser.getPhone().isEmpty()) {
|
||||
User targetUser = appUserService.findUserByPhone(appUser.getPhone());
|
||||
if (targetUser == null) {
|
||||
return fail("手机号未注册,请确认后再试");
|
||||
}
|
||||
appUser.setUserId(targetUser.getUserId());
|
||||
}
|
||||
if (appUser.getUserId() == null) {
|
||||
return fail("请输入用户ID或手机号");
|
||||
}
|
||||
try {
|
||||
AppUser result = appUserService.inviteUser(
|
||||
appUser.getWebsiteId(),
|
||||
appUser.getUserId(),
|
||||
appUser.getRole(),
|
||||
loginUser.getUserId()
|
||||
);
|
||||
return success("邀请成功", result);
|
||||
} catch (RuntimeException e) {
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appUser:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改应用成员信息")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AppUser appUser) {
|
||||
if (appUserService.updateById(appUser)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appUser:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改成员角色")
|
||||
@PutMapping("/role/{id}/{role}")
|
||||
public ApiResult<?> updateRole(@PathVariable("id") Long id, @PathVariable("role") String role) {
|
||||
if (appUserService.updateRole(id, role)) {
|
||||
return success("角色修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appUser:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "移除应用成员")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (appUserService.removeById(id)) {
|
||||
return success("已移除");
|
||||
}
|
||||
return fail("移除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appUser:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加应用成员")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<AppUser> list) {
|
||||
if (appUserService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appUser:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改应用成员")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> updateBatch(@RequestBody BatchParam<AppUser> batchParam) {
|
||||
if (batchParam.update(appUserService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appUser:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量移除应用成员")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (appUserService.removeByIds(ids)) {
|
||||
return success("移除成功");
|
||||
}
|
||||
return fail("移除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
package com.gxwebsoft.app.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.app.service.AppVersionService;
|
||||
import com.gxwebsoft.app.entity.AppVersion;
|
||||
import com.gxwebsoft.app.param.AppVersionParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用版本发布记录控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "应用版本发布管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/app/app-version")
|
||||
public class AppVersionController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AppVersionService appVersionService;
|
||||
|
||||
@Operation(summary = "分页查询版本记录")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AppVersion>> page(AppVersionParam param) {
|
||||
return success(appVersionService.pageRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询全部版本记录")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AppVersion>> list(AppVersionParam param) {
|
||||
return success(appVersionService.listRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据id查询版本")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AppVersion> get(@PathVariable("id") Integer id) {
|
||||
return success(appVersionService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取应用当前版本")
|
||||
@GetMapping("/current/{websiteId}")
|
||||
public ApiResult<AppVersion> getCurrentVersion(@PathVariable("websiteId") Long websiteId) {
|
||||
return success(appVersionService.getCurrentVersion(websiteId));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appVersion:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "新增版本(构建中状态)")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AppVersion appVersion) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
appVersion.setUserId(loginUser.getUserId());
|
||||
appVersion.setTenantId(loginUser.getTenantId());
|
||||
}
|
||||
// 默认为构建中状态
|
||||
if (appVersion.getStatus() == null) {
|
||||
appVersion.setStatus(0);
|
||||
}
|
||||
if (appVersion.getEnv() == null) {
|
||||
appVersion.setEnv("production");
|
||||
}
|
||||
appVersion.setIsCurrent(false);
|
||||
if (appVersionService.save(appVersion)) {
|
||||
return success("创建成功");
|
||||
}
|
||||
return fail("创建失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appVersion:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改版本信息")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AppVersion appVersion) {
|
||||
if (appVersionService.updateById(appVersion)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appVersion:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "发布版本(将此版本设为当前运行版本)")
|
||||
@PostMapping("/publish/{id}")
|
||||
public ApiResult<?> publish(@PathVariable("id") Long id) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
try {
|
||||
appVersionService.publish(id, loginUser.getUserId());
|
||||
return success("发布成功");
|
||||
} catch (RuntimeException e) {
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appVersion:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "回滚到指定版本")
|
||||
@PostMapping("/rollback/{id}")
|
||||
public ApiResult<?> rollback(@PathVariable("id") Long id) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
try {
|
||||
appVersionService.rollback(id, loginUser.getUserId());
|
||||
return success("回滚成功");
|
||||
} catch (RuntimeException e) {
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appVersion:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除版本记录")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (appVersionService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appVersion:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加版本")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<AppVersion> list) {
|
||||
if (appVersionService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appVersion:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改版本")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> updateBatch(@RequestBody BatchParam<AppVersion> batchParam) {
|
||||
if (batchParam.update(appVersionService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('app:appVersion:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除版本记录")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (appVersionService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package com.gxwebsoft.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 应用配置表
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("app_config")
|
||||
public class AppConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 配置ID
|
||||
*/
|
||||
@TableId(value = "config_id", type = IdType.AUTO)
|
||||
private Integer configId;
|
||||
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
private Integer websiteId;
|
||||
|
||||
/**
|
||||
* 配置键
|
||||
*/
|
||||
private String configKey;
|
||||
|
||||
/**
|
||||
* 配置值(JSON或字符串)
|
||||
*/
|
||||
private String configValue;
|
||||
|
||||
/**
|
||||
* 配置类型:general/api/callback/wechat/payment/git等
|
||||
*/
|
||||
private String configType;
|
||||
|
||||
/**
|
||||
* 是否加密 0否 1是
|
||||
*/
|
||||
private Integer isEncrypted;
|
||||
|
||||
/**
|
||||
* 是否敏感信息 0否 1是
|
||||
*/
|
||||
private Integer isSecret;
|
||||
|
||||
/**
|
||||
* 配置说明
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private Integer sortNumber;
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long createdTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Long updatedTime;
|
||||
|
||||
/**
|
||||
* 是否删除 0否 1是
|
||||
*/
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package com.gxwebsoft.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 开发者资源(服务器/数据库/云存储/域名/SSL证书)
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-31
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("app_resource")
|
||||
@Schema(name = "AppResource对象", description = "开发者资源")
|
||||
public class AppResource implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "资源ID")
|
||||
@TableId(value = "resource_id", type = IdType.AUTO)
|
||||
private Long resourceId;
|
||||
|
||||
@Schema(description = "资源类型: server/database/storage/domain/ssl")
|
||||
private String resourceType;
|
||||
|
||||
@Schema(description = "资源名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "服务商: tencent/aliyun/huawei/other")
|
||||
private String provider;
|
||||
|
||||
@Schema(description = "关联应用ID(可选)")
|
||||
private Long websiteId;
|
||||
|
||||
@Schema(description = "关联应用名称(冗余)")
|
||||
private String websiteName;
|
||||
|
||||
// ─── 服务器字段 ───────────────────────────────────────
|
||||
@Schema(description = "IP地址(服务器用)")
|
||||
private String ip;
|
||||
|
||||
// ─── 数据库字段 ───────────────────────────────────────
|
||||
@Schema(description = "数据库类型: MySQL/PostgreSQL/Redis/MongoDB(数据库用)")
|
||||
private String dbType;
|
||||
|
||||
@Schema(description = "连接主机地址(数据库用)")
|
||||
private String host;
|
||||
|
||||
@Schema(description = "连接端口(数据库用)")
|
||||
private Integer port;
|
||||
|
||||
// ─── 云存储字段 ───────────────────────────────────────
|
||||
@Schema(description = "地区/Region(云存储用)")
|
||||
private String region;
|
||||
|
||||
@Schema(description = "访问权限: public-read/private(云存储用)")
|
||||
private String acl;
|
||||
|
||||
@Schema(description = "已用空间(字节,云存储用)")
|
||||
private Long usedBytes;
|
||||
|
||||
// ─── 域名字段 ─────────────────────────────────────────
|
||||
@Schema(description = "域名(域名用)")
|
||||
private String domain;
|
||||
|
||||
@Schema(description = "注册商(域名用)")
|
||||
private String registrar;
|
||||
|
||||
@Schema(description = "是否已备案(域名用)")
|
||||
private Boolean icp;
|
||||
|
||||
@Schema(description = "ICP备案号(域名用)")
|
||||
private String icpNo;
|
||||
|
||||
@Schema(description = "是否已绑定SSL(域名用,冗余)")
|
||||
private Boolean sslBound;
|
||||
|
||||
// ─── SSL证书字段 ──────────────────────────────────────
|
||||
@Schema(description = "证书类型: DV/OV/EV(SSL用)")
|
||||
private String certType;
|
||||
|
||||
@Schema(description = "颁发机构(SSL用)")
|
||||
private String issuer;
|
||||
|
||||
// ─── 通用字段 ─────────────────────────────────────────
|
||||
@Schema(description = "状态: running/stopped/expired/pending")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "到期时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate expireAt;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "所属用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
private Integer tenantId;
|
||||
|
||||
@Schema(description = "是否删除: 0否 1是")
|
||||
private Integer deleted;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
package com.gxwebsoft.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.gxwebsoft.common.core.config.JsonArrayToStringDeserializer;
|
||||
import com.gxwebsoft.common.core.config.JsonStringToArraySerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 应用工单
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-30
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("app_ticket")
|
||||
@Schema(name = "AppTicket对象", description = "应用工单")
|
||||
public class AppTicket implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "工单ID")
|
||||
@TableId(value = "ticket_id", type = IdType.AUTO)
|
||||
private Long ticketId;
|
||||
|
||||
@Schema(description = "工单编号(TK-yyyyMMddHHmmss+4位随机)")
|
||||
private String ticketNo;
|
||||
|
||||
@Schema(description = "工单标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "工单内容描述")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "关联应用ID")
|
||||
private Long websiteId;
|
||||
|
||||
@Schema(description = "应用名称(冗余)")
|
||||
private String websiteName;
|
||||
|
||||
@Schema(description = "工单分类: bug/feature/consultation/complaint/other")
|
||||
private String category;
|
||||
|
||||
@Schema(description = "优先级: low/normal/high/urgent")
|
||||
private String priority;
|
||||
|
||||
@Schema(description = "状态: pending/assigned/processing/resolved/closed/rejected")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "附件JSON数组")
|
||||
@JsonDeserialize(using = JsonArrayToStringDeserializer.class)
|
||||
@JsonSerialize(using = JsonStringToArraySerializer.class)
|
||||
private String attachments;
|
||||
|
||||
@Schema(description = "提交人用户ID")
|
||||
private Integer submitUserId;
|
||||
|
||||
@Schema(description = "提交人昵称(冗余)")
|
||||
private String submitUserName;
|
||||
|
||||
@Schema(description = "提交人头像(冗余)")
|
||||
private String submitUserAvatar;
|
||||
|
||||
@Schema(description = "分配的处理人用户ID")
|
||||
private Integer assigneeId;
|
||||
|
||||
@Schema(description = "处理人昵称(冗余)")
|
||||
private String assigneeName;
|
||||
|
||||
@Schema(description = "处理人头像(冗余)")
|
||||
private String assigneeAvatar;
|
||||
|
||||
@Schema(description = "回复数量")
|
||||
private Integer replyCount;
|
||||
|
||||
@Schema(description = "解决时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime resolvedTime;
|
||||
|
||||
@Schema(description = "关闭时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime closedTime;
|
||||
|
||||
@Schema(description = "是否删除: 0否 1是")
|
||||
private Integer deleted;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.gxwebsoft.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.gxwebsoft.common.core.config.JsonArrayToStringDeserializer;
|
||||
import com.gxwebsoft.common.core.config.JsonStringToArraySerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 工单回复
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-30
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("app_ticket_reply")
|
||||
@Schema(name = "AppTicketReply对象", description = "工单回复")
|
||||
public class AppTicketReply implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "回复ID")
|
||||
@TableId(value = "reply_id", type = IdType.AUTO)
|
||||
private Long replyId;
|
||||
|
||||
@Schema(description = "关联工单ID")
|
||||
private Long ticketId;
|
||||
|
||||
@Schema(description = "回复内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "附件JSON数组")
|
||||
@JsonDeserialize(using = JsonArrayToStringDeserializer.class)
|
||||
@JsonSerialize(using = JsonStringToArraySerializer.class)
|
||||
private String attachments;
|
||||
|
||||
@Schema(description = "回复人用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "回复人昵称(冗余)")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "回复人头像(冗余)")
|
||||
private String userAvatar;
|
||||
|
||||
@Schema(description = "是否是技术人员/客服: 0否 1是")
|
||||
private Integer isStaff;
|
||||
|
||||
@Schema(description = "是否删除: 0否 1是")
|
||||
private Integer deleted;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.gxwebsoft.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 应用成员
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(name = "AppUser对象", description = "应用成员")
|
||||
public class AppUser implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "自增ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "关联应用ID")
|
||||
private Long websiteId;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "用户名(冗余)")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "昵称(冗余)")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "头像(冗余)")
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "手机号(冗余,脱敏存储)")
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "角色: owner/admin/developer/viewer")
|
||||
private String role;
|
||||
|
||||
@Schema(description = "邀请人用户ID")
|
||||
private Long inviteBy;
|
||||
|
||||
@Schema(description = "加入时间")
|
||||
private LocalDateTime inviteTime;
|
||||
|
||||
@Schema(description = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
@Schema(description = "状态, 0正常, 1冻结")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "修改时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package com.gxwebsoft.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 应用版本发布记录
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(name = "AppVersion对象", description = "应用版本发布记录")
|
||||
public class AppVersion implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "自增ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "关联应用ID")
|
||||
private Long websiteId;
|
||||
|
||||
@Schema(description = "版本号,如 1.0.0")
|
||||
private String versionNo;
|
||||
|
||||
@Schema(description = "版本名称")
|
||||
private String versionName;
|
||||
|
||||
@Schema(description = "版本更新说明")
|
||||
private String changelog;
|
||||
|
||||
@Schema(description = "安装包地址")
|
||||
private String packageUrl;
|
||||
|
||||
@Schema(description = "包大小(字节)")
|
||||
private Long packageSize;
|
||||
|
||||
@Schema(description = "包MD5/SHA256")
|
||||
private String packageHash;
|
||||
|
||||
@Schema(description = "环境: development/staging/production")
|
||||
private String env;
|
||||
|
||||
@Schema(description = "状态 0=构建中 1=已发布 2=已回滚 3=构建失败")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否为当前版本")
|
||||
private Boolean isCurrent;
|
||||
|
||||
@Schema(description = "发布人用户ID")
|
||||
private Long publishBy;
|
||||
|
||||
@Schema(description = "发布时间")
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "修改时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.gxwebsoft.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.app.entity.AppConfig;
|
||||
import com.gxwebsoft.app.param.AppConfigParam;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 应用配置表 Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
*/
|
||||
@Mapper
|
||||
public interface AppConfigMapper extends BaseMapper<AppConfig> {
|
||||
|
||||
/**
|
||||
* 批量获取应用配置
|
||||
*/
|
||||
List<Map<String, Object>> selectConfigsByWebsiteId(Integer websiteId);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<AppConfig>
|
||||
*/
|
||||
List<AppConfig> selectPageRel(@Param("page") IPage<AppConfig> page,
|
||||
@Param("param") AppConfigParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<AppConfig>
|
||||
*/
|
||||
List<AppConfig> selectListRel(@Param("param") AppConfigParam param);
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.gxwebsoft.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.app.entity.AppCredential;
|
||||
import com.gxwebsoft.app.param.AppCredentialParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用密钥凭证Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:43
|
||||
*/
|
||||
public interface AppCredentialMapper extends BaseMapper<AppCredential> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<AppCredential>
|
||||
*/
|
||||
List<AppCredential> selectPageRel(@Param("page") IPage<AppCredential> page,
|
||||
@Param("param") AppCredentialParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<AppCredential> selectListRel(@Param("param") AppCredentialParam param);
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.gxwebsoft.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.app.entity.AppEvent;
|
||||
import com.gxwebsoft.app.param.AppEventParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用操作动态Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
public interface AppEventMapper extends BaseMapper<AppEvent> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<AppEvent>
|
||||
*/
|
||||
List<AppEvent> selectPageRel(@Param("page") IPage<AppEvent> page,
|
||||
@Param("param") AppEventParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<AppEvent> selectListRel(@Param("param") AppEventParam param);
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.gxwebsoft.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.app.entity.AppResource;
|
||||
import com.gxwebsoft.app.param.AppResourceParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 开发者资源 Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-31
|
||||
*/
|
||||
public interface AppResourceMapper extends BaseMapper<AppResource> {
|
||||
|
||||
/**
|
||||
* 分页查询(关联应用名称)
|
||||
*/
|
||||
List<AppResource> selectPageRel(@Param("page") IPage<AppResource> page,
|
||||
@Param("param") AppResourceParam param);
|
||||
|
||||
/**
|
||||
* 查询全部列表(关联应用名称)
|
||||
*/
|
||||
List<AppResource> selectListRel(@Param("param") AppResourceParam param);
|
||||
|
||||
/**
|
||||
* 统计各类型资源数量,返回 [{resourceType, cnt}]
|
||||
*/
|
||||
List<java.util.Map<String, Object>> countByType(@Param("userId") Integer userId,
|
||||
@Param("tenantId") Integer tenantId);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.gxwebsoft.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gxwebsoft.app.entity.AppTicket;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 应用工单 Mapper
|
||||
*/
|
||||
public interface AppTicketMapper extends BaseMapper<AppTicket> {
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.gxwebsoft.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gxwebsoft.app.entity.AppTicketReply;
|
||||
|
||||
/**
|
||||
* 工单回复 Mapper
|
||||
*/
|
||||
public interface AppTicketReplyMapper extends BaseMapper<AppTicketReply> {
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.gxwebsoft.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.app.entity.AppUser;
|
||||
import com.gxwebsoft.app.param.AppUserParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用成员Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
public interface AppUserMapper extends BaseMapper<AppUser> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<AppUser>
|
||||
*/
|
||||
List<AppUser> selectPageRel(@Param("page") IPage<AppUser> page,
|
||||
@Param("param") AppUserParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<AppUser> selectListRel(@Param("param") AppUserParam param);
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.gxwebsoft.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.app.entity.AppVersion;
|
||||
import com.gxwebsoft.app.param.AppVersionParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用版本发布记录Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
public interface AppVersionMapper extends BaseMapper<AppVersion> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<AppVersion>
|
||||
*/
|
||||
List<AppVersion> selectPageRel(@Param("page") IPage<AppVersion> page,
|
||||
@Param("param") AppVersionParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<AppVersion> selectListRel(@Param("param") AppVersionParam param);
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
<?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.gxwebsoft.app.mapper.AppConfigMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM app_config a
|
||||
<where>
|
||||
a.deleted = 0
|
||||
<if test="param.configId != null">
|
||||
AND a.config_id = #{param.configId}
|
||||
</if>
|
||||
<if test="param.websiteId != null">
|
||||
AND a.website_id = #{param.websiteId}
|
||||
</if>
|
||||
<if test="param.configKey != null and param.configKey != ''">
|
||||
AND a.config_key LIKE CONCAT('%', #{param.configKey}, '%')
|
||||
</if>
|
||||
<if test="param.configType != null and param.configType != ''">
|
||||
AND a.config_type = #{param.configType}
|
||||
</if>
|
||||
<if test="param.isSecret != null">
|
||||
AND a.is_secret = #{param.isSecret}
|
||||
</if>
|
||||
<if test="param.tenantId != null">
|
||||
AND a.tenant_id = #{param.tenantId}
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null and param.keywords != ''">
|
||||
AND a.config_key LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.app.entity.AppConfig">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.app.entity.AppConfig">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 批量获取应用配置(自动解密) -->
|
||||
<select id="selectConfigsByWebsiteId" resultType="java.util.HashMap">
|
||||
SELECT
|
||||
config_key as configKey,
|
||||
config_value as configValue,
|
||||
config_type as configType,
|
||||
is_encrypted as isEncrypted,
|
||||
is_secret as isSecret,
|
||||
description
|
||||
FROM app_config
|
||||
WHERE website_id = #{websiteId}
|
||||
AND deleted = 0
|
||||
ORDER BY config_type, sort_number, config_id
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,66 +0,0 @@
|
||||
<?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.gxwebsoft.app.mapper.AppEventMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*, w.website_name, w.website_code, w.website_icon
|
||||
FROM app_event a
|
||||
LEFT JOIN cms_website w ON a.website_id = w.website_id AND w.deleted = 0
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.websiteId != null">
|
||||
AND a.website_id = #{param.websiteId}
|
||||
</if>
|
||||
<if test="param.eventType != null and param.eventType != ''">
|
||||
AND a.event_type = #{param.eventType}
|
||||
</if>
|
||||
<if test="param.title != null and param.title != ''">
|
||||
AND a.title LIKE CONCAT('%', #{param.title}, '%')
|
||||
</if>
|
||||
<if test="param.operatorId != null">
|
||||
AND a.operator_id = #{param.operatorId}
|
||||
</if>
|
||||
<if test="param.refId != null">
|
||||
AND a.ref_id = #{param.refId}
|
||||
</if>
|
||||
<if test="param.refType != null and param.refType != ''">
|
||||
AND a.ref_type = #{param.refType}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.tenantId != null">
|
||||
AND a.tenant_id = #{param.tenantId}
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null and param.keywords != ''">
|
||||
AND (a.title LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.content LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY a.create_time DESC
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.app.entity.AppEvent">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.app.entity.AppEvent">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,75 +0,0 @@
|
||||
<?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.gxwebsoft.app.mapper.AppResourceMapper">
|
||||
|
||||
<!-- 关联查询 SQL -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*, w.website_name
|
||||
FROM app_resource a
|
||||
LEFT JOIN cms_website w ON a.website_id = w.website_id AND w.deleted = 0
|
||||
<where>
|
||||
a.deleted = 0
|
||||
<if test="param.resourceId != null">
|
||||
AND a.resource_id = #{param.resourceId}
|
||||
</if>
|
||||
<if test="param.resourceType != null and param.resourceType != ''">
|
||||
AND a.resource_type = #{param.resourceType}
|
||||
</if>
|
||||
<if test="param.websiteId != null">
|
||||
AND a.website_id = #{param.websiteId}
|
||||
</if>
|
||||
<if test="param.provider != null and param.provider != ''">
|
||||
AND a.provider = #{param.provider}
|
||||
</if>
|
||||
<if test="param.status != null and param.status != ''">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.tenantId != null">
|
||||
AND a.tenant_id = #{param.tenantId}
|
||||
</if>
|
||||
<if test="param.keywords != null and param.keywords != ''">
|
||||
AND (
|
||||
a.name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.ip LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.domain LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.host LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY a.create_time DESC
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.app.entity.AppResource">
|
||||
<include refid="selectSql"/>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.app.entity.AppResource">
|
||||
<include refid="selectSql"/>
|
||||
</select>
|
||||
|
||||
<!-- 按类型统计数量 -->
|
||||
<select id="countByType" resultType="java.util.Map">
|
||||
SELECT resource_type AS resourceType, COUNT(*) AS cnt
|
||||
FROM app_resource
|
||||
WHERE deleted = 0
|
||||
<if test="userId != null">
|
||||
AND user_id = #{userId}
|
||||
</if>
|
||||
<if test="tenantId != null">
|
||||
AND tenant_id = #{tenantId}
|
||||
</if>
|
||||
GROUP BY resource_type
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,62 +0,0 @@
|
||||
<?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.gxwebsoft.app.mapper.AppUserMapper">
|
||||
|
||||
<!-- 关联查询sql(已移除跨库 JOIN gxwebsoft_core.sys_user,用户信息从冗余字段读取) -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*, w.website_name, w.website_code, w.website_icon
|
||||
FROM app_user a
|
||||
LEFT JOIN cms_website w ON a.website_id = w.website_id AND w.deleted = 0
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.websiteId != null">
|
||||
AND a.website_id = #{param.websiteId}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.username != null and param.username != ''">
|
||||
AND (a.username LIKE CONCAT('%', #{param.username}, '%')
|
||||
OR a.nickname LIKE CONCAT('%', #{param.username}, '%'))
|
||||
</if>
|
||||
<if test="param.role != null and param.role != ''">
|
||||
AND a.role = #{param.role}
|
||||
</if>
|
||||
<if test="param.inviteBy != null">
|
||||
AND a.invite_by = #{param.inviteBy}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.tenantId != null">
|
||||
AND a.tenant_id = #{param.tenantId}
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null and param.keywords != ''">
|
||||
AND (a.username LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.nickname LIKE CONCAT('%', #{param.keywords}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.app.entity.AppUser">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.app.entity.AppUser">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,66 +0,0 @@
|
||||
<?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.gxwebsoft.app.mapper.AppVersionMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*, w.website_name, w.website_code, w.website_icon
|
||||
FROM app_version a
|
||||
LEFT JOIN cms_website w ON a.website_id = w.website_id AND w.deleted = 0
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.websiteId != null">
|
||||
AND a.website_id = #{param.websiteId}
|
||||
</if>
|
||||
<if test="param.versionNo != null and param.versionNo != ''">
|
||||
AND a.version_no = #{param.versionNo}
|
||||
</if>
|
||||
<if test="param.versionName != null and param.versionName != ''">
|
||||
AND a.version_name LIKE CONCAT('%', #{param.versionName}, '%')
|
||||
</if>
|
||||
<if test="param.env != null and param.env != ''">
|
||||
AND a.env = #{param.env}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.isCurrent != null">
|
||||
AND a.is_current = #{param.isCurrent}
|
||||
</if>
|
||||
<if test="param.publishBy != null">
|
||||
AND a.publish_by = #{param.publishBy}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.tenantId != null">
|
||||
AND a.tenant_id = #{param.tenantId}
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null and param.keywords != ''">
|
||||
AND (a.version_no LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.version_name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.changelog LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.app.entity.AppVersion">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.app.entity.AppVersion">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.gxwebsoft.app.param;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 应用配置表查询参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AppConfigParam extends BaseParam {
|
||||
|
||||
/**
|
||||
* 配置ID
|
||||
*/
|
||||
private Integer configId;
|
||||
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
private Integer websiteId;
|
||||
|
||||
/**
|
||||
* 配置键
|
||||
*/
|
||||
private String configKey;
|
||||
|
||||
/**
|
||||
* 配置类型
|
||||
*/
|
||||
private String configType;
|
||||
|
||||
/**
|
||||
* 是否敏感信息
|
||||
*/
|
||||
private Integer isSecret;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.gxwebsoft.app.param;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 应用操作动态查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Schema(name = "AppEventParam对象", description = "应用操作动态查询参数")
|
||||
public class AppEventParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "自增ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "关联应用ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Long websiteId;
|
||||
|
||||
@Schema(description = "事件类型: created/published/updated/domain_bound/member_added/status_changed")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private String eventType;
|
||||
|
||||
@Schema(description = "事件标题(模糊)")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "操作人用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Long operatorId;
|
||||
|
||||
@Schema(description = "关联ID,如版本ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Long refId;
|
||||
|
||||
@Schema(description = "关联类型")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private String refType;
|
||||
|
||||
@Schema(description = "状态, 0正常, 1冻结")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer tenantId;
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.gxwebsoft.app.param;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 开发者资源查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-31
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Schema(name = "AppResourceParam对象", description = "开发者资源查询参数")
|
||||
public class AppResourceParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "资源ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Long resourceId;
|
||||
|
||||
@Schema(description = "资源类型: server/database/storage/domain/ssl")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private String resourceType;
|
||||
|
||||
@Schema(description = "关联应用ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Long websiteId;
|
||||
|
||||
@Schema(description = "服务商")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private String provider;
|
||||
|
||||
@Schema(description = "状态")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private String status;
|
||||
|
||||
@Schema(description = "所属用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer tenantId;
|
||||
|
||||
@Schema(description = "关键词(名称/IP/域名/Host模糊搜索)")
|
||||
private String keywords;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.gxwebsoft.app.param;
|
||||
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 工单查询参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "工单查询参数")
|
||||
public class AppTicketParam extends PageParam {
|
||||
|
||||
@Schema(description = "关联应用ID")
|
||||
private Long websiteId;
|
||||
|
||||
@Schema(description = "工单状态")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "工单分类")
|
||||
private String category;
|
||||
|
||||
@Schema(description = "优先级")
|
||||
private String priority;
|
||||
|
||||
@Schema(description = "处理人ID(传0=未分配)")
|
||||
private Integer assigneeId;
|
||||
|
||||
@Schema(description = "关键词(标题/工单编号)")
|
||||
private String keywords;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.gxwebsoft.app.param;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 应用版本发布记录查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Schema(name = "AppVersionParam对象", description = "应用版本发布记录查询参数")
|
||||
public class AppVersionParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "自增ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "关联应用ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Long websiteId;
|
||||
|
||||
@Schema(description = "版本号,如 1.0.0")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private String versionNo;
|
||||
|
||||
@Schema(description = "版本名称(模糊)")
|
||||
private String versionName;
|
||||
|
||||
@Schema(description = "环境: development/staging/production")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private String env;
|
||||
|
||||
@Schema(description = "状态 0=构建中 1=已发布 2=已回滚 3=构建失败")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否为当前版本")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Boolean isCurrent;
|
||||
|
||||
@Schema(description = "发布人用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Long publishBy;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer tenantId;
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.gxwebsoft.app.service;
|
||||
|
||||
import com.gxwebsoft.app.entity.AppConfig;
|
||||
import com.gxwebsoft.app.param.AppConfigParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 应用配置表 Service
|
||||
*/
|
||||
public interface AppConfigService {
|
||||
|
||||
/**
|
||||
* 分页查询应用配置
|
||||
*/
|
||||
List<AppConfig> page(AppConfigParam param);
|
||||
|
||||
/**
|
||||
* 获取应用配置列表
|
||||
*/
|
||||
List<AppConfig> list(AppConfigParam param);
|
||||
|
||||
/**
|
||||
* 根据应用ID获取配置映射(自动解密)
|
||||
*/
|
||||
Map<String, Object> getConfigsByWebsiteId(Integer websiteId);
|
||||
|
||||
/**
|
||||
* 获取单个配置值
|
||||
*/
|
||||
String getConfigValue(Integer websiteId, String configKey);
|
||||
|
||||
/**
|
||||
* 保存配置
|
||||
*/
|
||||
void saveConfig(AppConfig config);
|
||||
|
||||
/**
|
||||
* 批量保存配置
|
||||
*/
|
||||
void batchSaveConfig(Integer websiteId, List<AppConfig> configs);
|
||||
|
||||
/**
|
||||
* 更新配置
|
||||
*/
|
||||
void updateConfig(AppConfig config);
|
||||
|
||||
/**
|
||||
* 删除配置
|
||||
*/
|
||||
void deleteConfig(Integer configId);
|
||||
|
||||
/**
|
||||
* 根据应用ID删除所有配置
|
||||
*/
|
||||
void deleteByWebsiteId(Integer websiteId);
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.gxwebsoft.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.app.entity.AppCredential;
|
||||
import com.gxwebsoft.app.param.AppCredentialParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用密钥凭证Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:43
|
||||
*/
|
||||
public interface AppCredentialService extends IService<AppCredential> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*/
|
||||
PageResult<AppCredential> pageRel(AppCredentialParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*/
|
||||
List<AppCredential> listRel(AppCredentialParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*/
|
||||
AppCredential getByIdRel(Integer id);
|
||||
|
||||
/**
|
||||
* 创建凭证(自动生成 appId 和 appSecret)
|
||||
*
|
||||
* @param credential 凭证基础信息
|
||||
* @return 包含明文 appSecret 的凭证对象(仅此次返回,之后不再展示)
|
||||
*/
|
||||
AppCredential createCredential(AppCredential credential);
|
||||
|
||||
/**
|
||||
* 重置密钥(重新生成 appSecret)
|
||||
*
|
||||
* @param id 凭证ID
|
||||
* @return 包含新明文 appSecret 的凭证对象
|
||||
*/
|
||||
AppCredential resetSecret(Long id);
|
||||
|
||||
/**
|
||||
* 禁用/启用凭证
|
||||
*
|
||||
* @param id 凭证ID
|
||||
* @param status 0=正常 1=冻结
|
||||
*/
|
||||
boolean updateStatus(Long id, Integer status);
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.gxwebsoft.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.app.entity.AppEvent;
|
||||
import com.gxwebsoft.app.param.AppEventParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用操作动态Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
public interface AppEventService extends IService<AppEvent> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*/
|
||||
PageResult<AppEvent> pageRel(AppEventParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*/
|
||||
List<AppEvent> listRel(AppEventParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*/
|
||||
AppEvent getByIdRel(Integer id);
|
||||
|
||||
/**
|
||||
* 记录应用事件(便捷方法,供其他模块调用)
|
||||
*
|
||||
* @param websiteId 应用ID
|
||||
* @param eventType 事件类型(created/published/updated/domain_bound/member_added/status_changed 等)
|
||||
* @param title 事件标题
|
||||
* @param content 详细描述
|
||||
* @param operatorId 操作人用户ID
|
||||
* @param operatorName 操作人名称
|
||||
* @param refId 关联记录ID(如版本ID)
|
||||
* @param refType 关联记录类型
|
||||
*/
|
||||
void logEvent(Long websiteId, String eventType, String title, String content,
|
||||
Long operatorId, String operatorName, Long refId, String refType);
|
||||
|
||||
/**
|
||||
* 快捷记录事件(无关联记录)
|
||||
*/
|
||||
void logEvent(Long websiteId, String eventType, String title, Long operatorId, String operatorName);
|
||||
|
||||
/**
|
||||
* 获取指定应用的最新一条事件(用于卡片"最新动态"展示)
|
||||
*
|
||||
* @param websiteId 应用ID
|
||||
*/
|
||||
AppEvent getLatestEvent(Long websiteId);
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.gxwebsoft.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.app.entity.AppResource;
|
||||
import com.gxwebsoft.app.param.AppResourceParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 开发者资源 Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-31
|
||||
*/
|
||||
public interface AppResourceService extends IService<AppResource> {
|
||||
|
||||
/** 分页查询(关联应用名称) */
|
||||
PageResult<AppResource> pageRel(AppResourceParam param);
|
||||
|
||||
/** 列表查询 */
|
||||
List<AppResource> listRel(AppResourceParam param);
|
||||
|
||||
/** 详情(关联查询) */
|
||||
AppResource getByIdRel(Long resourceId);
|
||||
|
||||
/** 新增资源 */
|
||||
AppResource addResource(AppResource resource, Integer userId);
|
||||
|
||||
/** 更新资源 */
|
||||
AppResource updateResource(AppResource resource);
|
||||
|
||||
/** 删除资源(逻辑删除) */
|
||||
void removeResource(Long resourceId, Integer userId);
|
||||
|
||||
/** 按资源类型统计数量 [{resourceType, cnt}] */
|
||||
Map<String, Long> countByType(Integer userId, Integer tenantId);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.gxwebsoft.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.app.entity.AppTicket;
|
||||
import com.gxwebsoft.app.entity.AppTicketReply;
|
||||
import com.gxwebsoft.app.param.AppTicketParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 应用工单 Service
|
||||
*/
|
||||
public interface AppTicketService extends IService<AppTicket> {
|
||||
|
||||
/** 客户端:查自己提交的工单(分页) */
|
||||
PageResult<AppTicket> myPage(AppTicketParam param, Integer userId);
|
||||
|
||||
/** 技术端:查询所有工单(分页) */
|
||||
PageResult<AppTicket> allPage(AppTicketParam param);
|
||||
|
||||
/** 提交工单(自动分配) */
|
||||
AppTicket submit(AppTicket ticket, Integer userId);
|
||||
|
||||
/** 更新状态(技术人员操作) */
|
||||
void updateStatus(Long ticketId, String status, Integer operatorId);
|
||||
|
||||
/** 分配处理人 */
|
||||
void assign(Long ticketId, Integer assigneeId);
|
||||
|
||||
/** 关闭工单(提交人操作) */
|
||||
void closeByUser(Long ticketId, Integer userId);
|
||||
|
||||
/** 获取工单回复列表 */
|
||||
List<AppTicketReply> getReplies(Long ticketId);
|
||||
|
||||
/** 添加回复 */
|
||||
AppTicketReply addReply(AppTicketReply reply, Integer userId);
|
||||
|
||||
/** 统计数据 */
|
||||
Map<String, Long> stats(Long websiteId, Integer userId);
|
||||
|
||||
/** 获取技术人员列表(角色:developer/admin 的应用成员) */
|
||||
List<Map<String, Object>> getTechStaffList();
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.gxwebsoft.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.app.entity.AppUser;
|
||||
import com.gxwebsoft.app.param.AppUserParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用成员Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
public interface AppUserService extends IService<AppUser> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*/
|
||||
PageResult<AppUser> pageRel(AppUserParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*/
|
||||
List<AppUser> listRel(AppUserParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*/
|
||||
AppUser getByIdRel(Integer id);
|
||||
|
||||
/**
|
||||
* 邀请成员加入应用
|
||||
*
|
||||
* @param websiteId 应用ID
|
||||
* @param userId 被邀请的用户ID
|
||||
* @param role 分配的角色
|
||||
* @param inviteBy 邀请人用户ID
|
||||
* @return 成员记录
|
||||
*/
|
||||
AppUser inviteUser(Long websiteId, Integer userId, String role, Integer inviteBy);
|
||||
|
||||
/**
|
||||
* 修改成员角色
|
||||
*
|
||||
* @param id 成员记录ID
|
||||
* @param role 新角色
|
||||
*/
|
||||
boolean updateRole(Long id, String role);
|
||||
|
||||
/**
|
||||
* 检查用户是否已是应用成员
|
||||
*
|
||||
* @param websiteId 应用ID
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
boolean isMember(Long websiteId, Integer userId);
|
||||
|
||||
/**
|
||||
* 根据手机号查找系统用户(用于手机号邀请)
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @return 系统用户,不存在返回 null
|
||||
*/
|
||||
com.gxwebsoft.common.system.entity.User findUserByPhone(String phone);
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.gxwebsoft.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.app.entity.AppVersion;
|
||||
import com.gxwebsoft.app.param.AppVersionParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用版本发布记录Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
public interface AppVersionService extends IService<AppVersion> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*/
|
||||
PageResult<AppVersion> pageRel(AppVersionParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*/
|
||||
List<AppVersion> listRel(AppVersionParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*/
|
||||
AppVersion getByIdRel(Integer id);
|
||||
|
||||
/**
|
||||
* 发布版本(将此版本设为当前版本,其他版本 isCurrent=false)
|
||||
*
|
||||
* @param id 版本ID
|
||||
* @param publishBy 发布人用户ID
|
||||
*/
|
||||
boolean publish(Long id, Integer publishBy);
|
||||
|
||||
/**
|
||||
* 回滚到指定版本(将此版本设为当前版本,当前版本标为已回滚)
|
||||
*
|
||||
* @param id 要回滚到的版本ID
|
||||
* @param publishBy 操作人用户ID
|
||||
*/
|
||||
boolean rollback(Long id, Integer publishBy);
|
||||
|
||||
/**
|
||||
* 获取指定应用的当前版本
|
||||
*
|
||||
* @param websiteId 应用ID
|
||||
*/
|
||||
AppVersion getCurrentVersion(Long websiteId);
|
||||
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
package com.gxwebsoft.app.service.impl;
|
||||
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.app.entity.AppConfig;
|
||||
import com.gxwebsoft.app.mapper.AppConfigMapper;
|
||||
import com.gxwebsoft.app.param.AppConfigParam;
|
||||
import com.gxwebsoft.app.service.AppConfigService;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 应用配置表 Service 实现类
|
||||
*
|
||||
* @author 科技小王子
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AppConfigServiceImpl extends ServiceImpl<AppConfigMapper, AppConfig> implements AppConfigService {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 配置加密密钥(从配置文件读取)
|
||||
*/
|
||||
@Value("${app.config.encrypt-key:GXWebsoft2024!@#$}")
|
||||
private String encryptKey;
|
||||
|
||||
/**
|
||||
* 分页查询应用配置
|
||||
*/
|
||||
@Override
|
||||
public List<AppConfig> page(AppConfigParam param) {
|
||||
PageParam<AppConfig, AppConfigParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, config_id asc");
|
||||
List<AppConfig> list = baseMapper.selectPageRel(page, param);
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询应用配置(返回PageResult)
|
||||
*/
|
||||
public PageResult<AppConfig> pageRel(AppConfigParam param) {
|
||||
PageParam<AppConfig, AppConfigParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, config_id asc");
|
||||
List<AppConfig> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用配置列表
|
||||
*/
|
||||
@Override
|
||||
public List<AppConfig> list(AppConfigParam param) {
|
||||
List<AppConfig> list = baseMapper.selectListRel(param);
|
||||
PageParam<AppConfig, AppConfigParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, config_id asc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据应用ID获取配置映射(自动解密)
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getConfigsByWebsiteId(Integer websiteId) {
|
||||
List<Map<String, Object>> configs = baseMapper.selectConfigsByWebsiteId(websiteId);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
for (Map<String, Object> config : configs) {
|
||||
String configKey = (String) config.get("configKey");
|
||||
Object configValue = config.get("configValue");
|
||||
Integer isEncrypted = (Integer) config.get("isEncrypted");
|
||||
|
||||
// 解密
|
||||
if (isEncrypted != null && isEncrypted == 1 && configValue != null) {
|
||||
try {
|
||||
configValue = decrypt((String) configValue);
|
||||
} catch (Exception e) {
|
||||
log.error("配置解密失败: {}", configKey, e);
|
||||
}
|
||||
}
|
||||
|
||||
result.put(configKey, configValue);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个配置值
|
||||
*/
|
||||
@Override
|
||||
public String getConfigValue(Integer websiteId, String configKey) {
|
||||
LambdaQueryWrapper<AppConfig> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(AppConfig::getWebsiteId, websiteId);
|
||||
wrapper.eq(AppConfig::getConfigKey, configKey);
|
||||
AppConfig config = getOne(wrapper);
|
||||
|
||||
if (config == null || config.getConfigValue() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 解密
|
||||
if (config.getIsEncrypted() != null && config.getIsEncrypted() == 1) {
|
||||
return decrypt(config.getConfigValue());
|
||||
}
|
||||
|
||||
return config.getConfigValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存配置
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveConfig(AppConfig config) {
|
||||
// 设置租户ID
|
||||
Integer tenantId = getCurrentTenantId();
|
||||
if (tenantId != null) {
|
||||
config.setTenantId(Long.valueOf(tenantId));
|
||||
}
|
||||
|
||||
// 加密敏感信息
|
||||
if (config.getIsEncrypted() != null && config.getIsEncrypted() == 1 && config.getConfigValue() != null) {
|
||||
config.setConfigValue(encrypt(config.getConfigValue()));
|
||||
}
|
||||
|
||||
save(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存配置
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchSaveConfig(Integer websiteId, List<AppConfig> configs) {
|
||||
// 设置租户ID
|
||||
Integer tenantId = getCurrentTenantId();
|
||||
if (tenantId != null) {
|
||||
for (AppConfig config : configs) {
|
||||
config.setTenantId(Long.valueOf(tenantId));
|
||||
}
|
||||
}
|
||||
|
||||
// 先删除该应用的所有配置
|
||||
remove(new LambdaQueryWrapper<AppConfig>()
|
||||
.eq(AppConfig::getWebsiteId, websiteId));
|
||||
|
||||
// 批量插入新配置
|
||||
for (AppConfig config : configs) {
|
||||
config.setWebsiteId(websiteId);
|
||||
|
||||
// 加密敏感信息
|
||||
if (config.getIsEncrypted() != null && config.getIsEncrypted() == 1 && config.getConfigValue() != null) {
|
||||
config.setConfigValue(encrypt(config.getConfigValue()));
|
||||
}
|
||||
|
||||
save(config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新配置
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateConfig(AppConfig config) {
|
||||
// 加密敏感信息
|
||||
if (config.getIsEncrypted() != null && config.getIsEncrypted() == 1 && config.getConfigValue() != null) {
|
||||
config.setConfigValue(encrypt(config.getConfigValue()));
|
||||
}
|
||||
|
||||
updateById(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配置
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteConfig(Integer configId) {
|
||||
removeById(configId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据应用ID删除所有配置
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteByWebsiteId(Integer websiteId) {
|
||||
remove(new LambdaQueryWrapper<AppConfig>()
|
||||
.eq(AppConfig::getWebsiteId, websiteId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询条件
|
||||
*/
|
||||
private LambdaQueryWrapper<AppConfig> buildQueryWrapper(AppConfigParam param) {
|
||||
LambdaQueryWrapper<AppConfig> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
if (param.getConfigId() != null) {
|
||||
wrapper.eq(AppConfig::getConfigId, param.getConfigId());
|
||||
}
|
||||
if (param.getWebsiteId() != null) {
|
||||
wrapper.eq(AppConfig::getWebsiteId, param.getWebsiteId());
|
||||
}
|
||||
if (param.getConfigKey() != null) {
|
||||
wrapper.like(AppConfig::getConfigKey, param.getConfigKey());
|
||||
}
|
||||
if (param.getConfigType() != null) {
|
||||
wrapper.eq(AppConfig::getConfigType, param.getConfigType());
|
||||
}
|
||||
if (param.getIsSecret() != null) {
|
||||
wrapper.eq(AppConfig::getIsSecret, param.getIsSecret());
|
||||
}
|
||||
|
||||
wrapper.orderByAsc(AppConfig::getConfigType)
|
||||
.orderByAsc(AppConfig::getSortNumber)
|
||||
.orderByAsc(AppConfig::getConfigId);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* AES 加密
|
||||
*/
|
||||
private String encrypt(String plainText) {
|
||||
AES aes = SecureUtil.aes(encryptKey.getBytes());
|
||||
return aes.encryptBase64(plainText);
|
||||
}
|
||||
|
||||
/**
|
||||
* AES 解密
|
||||
*/
|
||||
private String decrypt(String cipherText) {
|
||||
AES aes = SecureUtil.aes(encryptKey.getBytes());
|
||||
return aes.decryptStr(cipherText);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户的租户ID
|
||||
*/
|
||||
private Integer getCurrentTenantId() {
|
||||
try {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication != null && authentication.getPrincipal() instanceof User) {
|
||||
return ((User) authentication.getPrincipal()).getTenantId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取当前用户租户ID失败", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
package com.gxwebsoft.app.service.impl;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.app.mapper.AppCredentialMapper;
|
||||
import com.gxwebsoft.app.service.AppCredentialService;
|
||||
import com.gxwebsoft.app.entity.AppCredential;
|
||||
import com.gxwebsoft.app.param.AppCredentialParam;
|
||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用密钥凭证Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:43
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AppCredentialServiceImpl extends ServiceImpl<AppCredentialMapper, AppCredential> implements AppCredentialService {
|
||||
|
||||
@Override
|
||||
public PageResult<AppCredential> pageRel(AppCredentialParam param) {
|
||||
PageParam<AppCredential, AppCredentialParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<AppCredential> list = baseMapper.selectPageRel(page, param);
|
||||
// 脱敏处理:appSecret 不对外展示(仅创建/重置时返回明文)
|
||||
list.forEach(this::maskSecret);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppCredential> listRel(AppCredentialParam param) {
|
||||
List<AppCredential> list = baseMapper.selectListRel(param);
|
||||
PageParam<AppCredential, AppCredentialParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
list = page.sortRecords(list);
|
||||
list.forEach(this::maskSecret);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppCredential getByIdRel(Integer id) {
|
||||
AppCredentialParam param = new AppCredentialParam();
|
||||
param.setId(id.longValue());
|
||||
AppCredential credential = param.getOne(baseMapper.selectListRel(param));
|
||||
if (credential != null) {
|
||||
maskSecret(credential);
|
||||
}
|
||||
return credential;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppCredential createCredential(AppCredential credential) {
|
||||
// 生成 AppID:app_ + 16位随机字符串
|
||||
String appId = "app_" + CommonUtil.randomUUID16();
|
||||
// 生成 AppSecret:32位随机字符串(大小写字母+数字)
|
||||
String appSecret = generateSecretValue();
|
||||
|
||||
credential.setAppId(appId);
|
||||
credential.setAppSecret(appSecret);
|
||||
// 默认状态正常
|
||||
if (credential.getStatus() == null) {
|
||||
credential.setStatus(0);
|
||||
}
|
||||
if (StrUtil.isBlank(credential.getType())) {
|
||||
credential.setType("server");
|
||||
}
|
||||
|
||||
save(credential);
|
||||
log.info("创建凭证成功,websiteId={}, appId={}", credential.getWebsiteId(), appId);
|
||||
// 返回含明文 secret 的对象(仅此一次)
|
||||
return credential;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppCredential resetSecret(Long id) {
|
||||
AppCredential credential = getById(id);
|
||||
if (credential == null) {
|
||||
throw new RuntimeException("凭证不存在");
|
||||
}
|
||||
String newSecret = generateSecretValue();
|
||||
credential.setAppSecret(newSecret);
|
||||
updateById(credential);
|
||||
log.info("重置凭证密钥成功,id={}", id);
|
||||
return credential;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateStatus(Long id, Integer status) {
|
||||
return update(new LambdaUpdateWrapper<AppCredential>()
|
||||
.eq(AppCredential::getId, id)
|
||||
.set(AppCredential::getStatus, status));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成32位随机 AppSecret
|
||||
*/
|
||||
private String generateSecretValue() {
|
||||
// 格式:8位-8位-8位-8位(类似 UUID 格式,便于复制)
|
||||
return RandomUtil.randomString(8) + "-"
|
||||
+ RandomUtil.randomString(8) + "-"
|
||||
+ RandomUtil.randomString(8) + "-"
|
||||
+ RandomUtil.randomString(8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 脱敏处理:将 appSecret 替换为掩码
|
||||
*/
|
||||
private void maskSecret(AppCredential credential) {
|
||||
if (StrUtil.isNotBlank(credential.getAppSecret())) {
|
||||
// 只保留前4位,其余用 * 替代
|
||||
String secret = credential.getAppSecret();
|
||||
credential.setAppSecret(secret.substring(0, Math.min(4, secret.length())) + "**********************");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package com.gxwebsoft.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.app.mapper.AppEventMapper;
|
||||
import com.gxwebsoft.app.service.AppEventService;
|
||||
import com.gxwebsoft.app.entity.AppEvent;
|
||||
import com.gxwebsoft.app.param.AppEventParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用操作动态Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AppEventServiceImpl extends ServiceImpl<AppEventMapper, AppEvent> implements AppEventService {
|
||||
|
||||
@Override
|
||||
public PageResult<AppEvent> pageRel(AppEventParam param) {
|
||||
PageParam<AppEvent, AppEventParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
List<AppEvent> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppEvent> listRel(AppEventParam param) {
|
||||
List<AppEvent> list = baseMapper.selectListRel(param);
|
||||
PageParam<AppEvent, AppEventParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppEvent getByIdRel(Integer id) {
|
||||
AppEventParam param = new AppEventParam();
|
||||
param.setId(id.longValue());
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void logEvent(Long websiteId, String eventType, String title, String content,
|
||||
Long operatorId, String operatorName, Long refId, String refType) {
|
||||
try {
|
||||
AppEvent event = new AppEvent();
|
||||
event.setWebsiteId(websiteId);
|
||||
event.setEventType(eventType);
|
||||
event.setTitle(title);
|
||||
event.setContent(content);
|
||||
event.setOperatorId(operatorId);
|
||||
event.setOperator(operatorName);
|
||||
event.setRefId(refId);
|
||||
event.setRefType(refType);
|
||||
event.setStatus(0);
|
||||
save(event);
|
||||
log.debug("记录事件成功,websiteId={}, eventType={}, title={}", websiteId, eventType, title);
|
||||
} catch (Exception e) {
|
||||
log.warn("记录事件失败,websiteId={}, eventType={}: {}", websiteId, eventType, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void logEvent(Long websiteId, String eventType, String title, Long operatorId, String operatorName) {
|
||||
logEvent(websiteId, eventType, title, null, operatorId, operatorName, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppEvent getLatestEvent(Long websiteId) {
|
||||
return getOne(new LambdaQueryWrapper<AppEvent>()
|
||||
.eq(AppEvent::getWebsiteId, websiteId)
|
||||
.orderByDesc(AppEvent::getCreateTime)
|
||||
.last("LIMIT 1"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
package com.gxwebsoft.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.app.entity.AppResource;
|
||||
import com.gxwebsoft.app.mapper.AppResourceMapper;
|
||||
import com.gxwebsoft.app.param.AppResourceParam;
|
||||
import com.gxwebsoft.app.service.AppResourceService;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 开发者资源 Service 实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-31
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AppResourceServiceImpl extends ServiceImpl<AppResourceMapper, AppResource>
|
||||
implements AppResourceService {
|
||||
|
||||
@Override
|
||||
public PageResult<AppResource> pageRel(AppResourceParam param) {
|
||||
PageParam<AppResource, AppResourceParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
List<AppResource> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppResource> listRel(AppResourceParam param) {
|
||||
return baseMapper.selectListRel(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppResource getByIdRel(Long resourceId) {
|
||||
AppResourceParam param = new AppResourceParam();
|
||||
param.setResourceId(resourceId);
|
||||
List<AppResource> list = baseMapper.selectListRel(param);
|
||||
return list.isEmpty() ? null : list.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AppResource addResource(AppResource resource, Integer userId) {
|
||||
resource.setUserId(userId);
|
||||
resource.setDeleted(0);
|
||||
resource.setCreateTime(LocalDateTime.now());
|
||||
resource.setUpdateTime(LocalDateTime.now());
|
||||
// 默认状态
|
||||
if (resource.getStatus() == null) {
|
||||
resource.setStatus("running");
|
||||
}
|
||||
save(resource);
|
||||
log.info("新增资源成功, type={}, name={}, userId={}", resource.getResourceType(), resource.getName(), userId);
|
||||
return resource;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AppResource updateResource(AppResource resource) {
|
||||
if (resource.getResourceId() == null) {
|
||||
throw new RuntimeException("资源ID不能为空");
|
||||
}
|
||||
resource.setUpdateTime(LocalDateTime.now());
|
||||
updateById(resource);
|
||||
return getByIdRel(resource.getResourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeResource(Long resourceId, Integer userId) {
|
||||
AppResource resource = getById(resourceId);
|
||||
if (resource == null) {
|
||||
throw new RuntimeException("资源不存在");
|
||||
}
|
||||
if (!resource.getUserId().equals(userId)) {
|
||||
throw new RuntimeException("无权操作此资源");
|
||||
}
|
||||
resource.setDeleted(1);
|
||||
resource.setUpdateTime(LocalDateTime.now());
|
||||
updateById(resource);
|
||||
log.info("删除资源成功, resourceId={}, userId={}", resourceId, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Long> countByType(Integer userId, Integer tenantId) {
|
||||
List<Map<String, Object>> raw = baseMapper.countByType(userId, tenantId);
|
||||
Map<String, Long> result = new HashMap<>();
|
||||
// 初始化所有类型为 0
|
||||
for (String type : new String[]{"server", "database", "storage", "domain", "ssl"}) {
|
||||
result.put(type, 0L);
|
||||
}
|
||||
for (Map<String, Object> row : raw) {
|
||||
String type = (String) row.get("resourceType");
|
||||
Long cnt = ((Number) row.get("cnt")).longValue();
|
||||
result.put(type, cnt);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,579 +0,0 @@
|
||||
package com.gxwebsoft.app.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.app.entity.AppTicket;
|
||||
import com.gxwebsoft.app.entity.AppTicketReply;
|
||||
import com.gxwebsoft.app.entity.AppUser;
|
||||
import com.gxwebsoft.app.mapper.AppTicketMapper;
|
||||
import com.gxwebsoft.app.mapper.AppTicketReplyMapper;
|
||||
import com.gxwebsoft.app.param.AppTicketParam;
|
||||
import com.gxwebsoft.app.service.AppTicketService;
|
||||
import com.gxwebsoft.app.service.AppUserService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 应用工单 Service 实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-30
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AppTicketServiceImpl extends ServiceImpl<AppTicketMapper, AppTicket> implements AppTicketService {
|
||||
|
||||
/** 企业微信群机器人 Webhook,留空则不发送 */
|
||||
@Value("${notify.wecom-webhook:}")
|
||||
private String wecomWebhook;
|
||||
|
||||
/** 飞书群机器人 Webhook,留空则不发送 */
|
||||
@Value("${notify.feishu-webhook:}")
|
||||
private String feishuWebhook;
|
||||
|
||||
@Resource
|
||||
private AppTicketReplyMapper replyMapper;
|
||||
|
||||
@Resource
|
||||
private AppUserService appUserService;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
// ─── 生成工单编号 ─────────────────────────────────────────────
|
||||
private String generateTicketNo() {
|
||||
String ts = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||
String rand = String.format("%04d", new Random().nextInt(10000));
|
||||
return "TK-" + ts + rand;
|
||||
}
|
||||
|
||||
// ─── 客户端:查自己的工单 ─────────────────────────────────────
|
||||
@Override
|
||||
public PageResult<AppTicket> myPage(AppTicketParam param, Integer userId) {
|
||||
// 用 PageParam 包装分页参数(getCurrent/getSize 来自父类 Page<T>)
|
||||
Page<AppTicket> page = new Page<>(param.getCurrent(), param.getSize() > 0 ? param.getSize() : 15);
|
||||
|
||||
LambdaQueryWrapper<AppTicket> wrapper = new LambdaQueryWrapper<AppTicket>()
|
||||
.eq(AppTicket::getDeleted, 0)
|
||||
.eq(AppTicket::getSubmitUserId, userId)
|
||||
.eq(ObjectUtil.isNotNull(param.getWebsiteId()), AppTicket::getWebsiteId, param.getWebsiteId())
|
||||
.eq(ObjectUtil.isNotEmpty(param.getStatus()), AppTicket::getStatus, param.getStatus())
|
||||
.eq(ObjectUtil.isNotEmpty(param.getCategory()), AppTicket::getCategory, param.getCategory())
|
||||
.and(ObjectUtil.isNotEmpty(param.getKeywords()), q ->
|
||||
q.like(AppTicket::getTitle, param.getKeywords())
|
||||
.or().like(AppTicket::getTicketNo, param.getKeywords()))
|
||||
// 状态优先级:pending > assigned > processing > resolved > closed;同状态内最新的排前
|
||||
.last("ORDER BY FIELD(status,'pending','assigned','processing','resolved','closed','rejected'), create_time DESC");
|
||||
|
||||
baseMapper.selectPage(page, wrapper);
|
||||
return new PageResult<>(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
// ─── 技术端:查所有工单 ───────────────────────────────────────
|
||||
@Override
|
||||
public PageResult<AppTicket> allPage(AppTicketParam param) {
|
||||
Page<AppTicket> page = new Page<>(param.getCurrent(), param.getSize() > 0 ? param.getSize() : 20);
|
||||
|
||||
LambdaQueryWrapper<AppTicket> wrapper = new LambdaQueryWrapper<AppTicket>()
|
||||
.eq(AppTicket::getDeleted, 0)
|
||||
.eq(ObjectUtil.isNotNull(param.getWebsiteId()), AppTicket::getWebsiteId, param.getWebsiteId())
|
||||
.eq(ObjectUtil.isNotEmpty(param.getStatus()), AppTicket::getStatus, param.getStatus())
|
||||
.eq(ObjectUtil.isNotEmpty(param.getCategory()), AppTicket::getCategory, param.getCategory())
|
||||
.eq(ObjectUtil.isNotEmpty(param.getPriority()), AppTicket::getPriority, param.getPriority())
|
||||
.and(ObjectUtil.isNotNull(param.getAssigneeId()) && param.getAssigneeId() == 0,
|
||||
q -> q.isNull(AppTicket::getAssigneeId))
|
||||
.eq(ObjectUtil.isNotNull(param.getAssigneeId()) && param.getAssigneeId() > 0,
|
||||
AppTicket::getAssigneeId, param.getAssigneeId())
|
||||
.and(ObjectUtil.isNotEmpty(param.getKeywords()), q ->
|
||||
q.like(AppTicket::getTitle, param.getKeywords())
|
||||
.or().like(AppTicket::getTicketNo, param.getKeywords()))
|
||||
// 状态优先级 > 紧急程度 > 最新提交时间
|
||||
.last("ORDER BY FIELD(status,'pending','assigned','processing','resolved','closed','rejected'), FIELD(priority,'urgent','high','normal','low'), create_time DESC");
|
||||
|
||||
baseMapper.selectPage(page, wrapper);
|
||||
return new PageResult<>(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
// ─── 提交工单(自动分配) ─────────────────────────────────────
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AppTicket submit(AppTicket ticket, Integer userId) {
|
||||
// 补充提交人信息
|
||||
ticket.setSubmitUserId(userId);
|
||||
ticket.setTicketNo(generateTicketNo());
|
||||
ticket.setStatus("pending");
|
||||
ticket.setReplyCount(0);
|
||||
ticket.setDeleted(0);
|
||||
ticket.setCreateTime(LocalDateTime.now());
|
||||
ticket.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
// 从用户服务取昵称/头像冗余存储(@InterceptorIgnore 绕过租户拦截器跨库查询)
|
||||
try {
|
||||
User user = userService.getByIdIgnoreTenant(userId);
|
||||
if (user != null) {
|
||||
ticket.setSubmitUserName(user.getNickname() != null ? user.getNickname() : user.getUsername());
|
||||
ticket.setSubmitUserAvatar(user.getAvatar());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("获取提交人信息失败", e);
|
||||
}
|
||||
|
||||
// 自动分配:查找该应用的 admin/developer 成员,随机分配
|
||||
autoAssign(ticket);
|
||||
|
||||
save(ticket);
|
||||
|
||||
// 异步推送:新工单通知(通知分配到的技术人员)
|
||||
sendTicketCreatedAsync(ticket);
|
||||
|
||||
return ticket;
|
||||
}
|
||||
|
||||
/** 自动分配工单给应用的技术成员 */
|
||||
private void autoAssign(AppTicket ticket) {
|
||||
if (ticket.getWebsiteId() == null) return;
|
||||
try {
|
||||
List<AppUser> members = appUserService.list(
|
||||
new LambdaQueryWrapper<AppUser>()
|
||||
.eq(AppUser::getWebsiteId, ticket.getWebsiteId())
|
||||
.eq(AppUser::getStatus, 0)
|
||||
.in(AppUser::getRole, "admin", "developer", "owner"));
|
||||
if (!members.isEmpty()) {
|
||||
// 简单轮询:按工单数最少分配(此处随机)
|
||||
AppUser assigned = members.get(new Random().nextInt(members.size()));
|
||||
ticket.setAssigneeId(assigned.getUserId());
|
||||
ticket.setAssigneeName(assigned.getNickname() != null ? assigned.getNickname() : assigned.getUsername());
|
||||
ticket.setAssigneeAvatar(assigned.getAvatar());
|
||||
ticket.setStatus("assigned");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("自动分配工单失败,保持 pending 状态", e);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── 更新状态 ─────────────────────────────────────────────────
|
||||
@Override
|
||||
public void updateStatus(Long ticketId, String status, Integer operatorId) {
|
||||
LambdaUpdateWrapper<AppTicket> wrapper = new LambdaUpdateWrapper<AppTicket>()
|
||||
.eq(AppTicket::getTicketId, ticketId)
|
||||
.set(AppTicket::getStatus, status)
|
||||
.set(AppTicket::getUpdateTime, LocalDateTime.now());
|
||||
if ("resolved".equals(status)) {
|
||||
wrapper.set(AppTicket::getResolvedTime, LocalDateTime.now());
|
||||
// 如果没有分配人,自动将操作人设为处理人
|
||||
AppTicket t = getById(ticketId);
|
||||
if (t != null && t.getAssigneeId() == null) {
|
||||
wrapper.set(AppTicket::getAssigneeId, operatorId);
|
||||
}
|
||||
}
|
||||
update(wrapper);
|
||||
|
||||
// 异步推送:状态变更通知提交人(已解决/已关闭)
|
||||
if ("resolved".equals(status) || "closed".equals(status)) {
|
||||
AppTicket t = getById(ticketId);
|
||||
if (t != null) sendStatusChangedAsync(t, status);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── 分配处理人 ───────────────────────────────────────────────
|
||||
@Override
|
||||
public void assign(Long ticketId, Integer assigneeId) {
|
||||
User user = userService.getByIdIgnoreTenant(assigneeId);
|
||||
LambdaUpdateWrapper<AppTicket> wrapper = new LambdaUpdateWrapper<AppTicket>()
|
||||
.eq(AppTicket::getTicketId, ticketId)
|
||||
.set(AppTicket::getAssigneeId, assigneeId)
|
||||
.set(user != null, AppTicket::getAssigneeName,
|
||||
user != null ? (user.getNickname() != null ? user.getNickname() : user.getUsername()) : null)
|
||||
.set(user != null, AppTicket::getAssigneeAvatar, user != null ? user.getAvatar() : null)
|
||||
.set(AppTicket::getStatus, "assigned")
|
||||
.set(AppTicket::getUpdateTime, LocalDateTime.now());
|
||||
update(wrapper);
|
||||
|
||||
// 异步推送:通知新分配到的技术人员
|
||||
AppTicket t = getById(ticketId);
|
||||
if (t != null) sendTicketAssignedAsync(t);
|
||||
}
|
||||
|
||||
// ─── 用户关闭工单 ─────────────────────────────────────────────
|
||||
@Override
|
||||
public void closeByUser(Long ticketId, Integer userId) {
|
||||
AppTicket ticket = getById(ticketId);
|
||||
if (ticket == null || !ticket.getSubmitUserId().equals(userId)) {
|
||||
throw new RuntimeException("无权操作该工单");
|
||||
}
|
||||
update(new LambdaUpdateWrapper<AppTicket>()
|
||||
.eq(AppTicket::getTicketId, ticketId)
|
||||
.set(AppTicket::getStatus, "closed")
|
||||
.set(AppTicket::getClosedTime, LocalDateTime.now())
|
||||
.set(AppTicket::getUpdateTime, LocalDateTime.now()));
|
||||
}
|
||||
|
||||
// ─── 获取回复列表 ─────────────────────────────────────────────
|
||||
@Override
|
||||
public List<AppTicketReply> getReplies(Long ticketId) {
|
||||
return replyMapper.selectList(
|
||||
new LambdaQueryWrapper<AppTicketReply>()
|
||||
.eq(AppTicketReply::getTicketId, ticketId)
|
||||
.eq(AppTicketReply::getDeleted, 0)
|
||||
.orderByAsc(AppTicketReply::getCreateTime));
|
||||
}
|
||||
|
||||
// ─── 添加回复 ─────────────────────────────────────────────────
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AppTicketReply addReply(AppTicketReply reply, Integer userId) {
|
||||
reply.setUserId(userId);
|
||||
reply.setDeleted(0);
|
||||
reply.setCreateTime(LocalDateTime.now());
|
||||
|
||||
// 补充用户信息(@InterceptorIgnore 绕过租户拦截器跨库查询)
|
||||
try {
|
||||
User user = userService.getByIdIgnoreTenant(userId);
|
||||
if (user != null) {
|
||||
reply.setUserName(user.getNickname() != null ? user.getNickname() : user.getUsername());
|
||||
reply.setUserAvatar(user.getAvatar());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("获取回复人信息失败", e);
|
||||
}
|
||||
|
||||
// 判断是否是技术人员(该应用的 admin/developer/owner)
|
||||
AppTicket ticket = getById(reply.getTicketId());
|
||||
if (ticket != null) {
|
||||
boolean isStaff = appUserService.count(new LambdaQueryWrapper<AppUser>()
|
||||
.eq(AppUser::getWebsiteId, ticket.getWebsiteId())
|
||||
.eq(AppUser::getUserId, userId)
|
||||
.in(AppUser::getRole, "owner", "admin", "developer")
|
||||
.eq(AppUser::getStatus, 0)) > 0;
|
||||
reply.setIsStaff(isStaff ? 1 : 0);
|
||||
} else {
|
||||
reply.setIsStaff(0);
|
||||
}
|
||||
|
||||
replyMapper.insert(reply);
|
||||
|
||||
// 更新工单回复数 & 更新时间,若状态是 assigned 则推进为 processing
|
||||
update(new LambdaUpdateWrapper<AppTicket>()
|
||||
.eq(AppTicket::getTicketId, reply.getTicketId())
|
||||
.setSql("reply_count = reply_count + 1")
|
||||
.set(AppTicket::getUpdateTime, LocalDateTime.now())
|
||||
.eq(AppTicket::getStatus, "assigned")
|
||||
.set(AppTicket::getStatus, "processing"));
|
||||
|
||||
// 异步推送:有新回复时通知对方
|
||||
if (ticket != null) sendReplyNotifyAsync(ticket, reply);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
// ─── 统计 ─────────────────────────────────────────────────────
|
||||
@Override
|
||||
public Map<String, Long> stats(Long websiteId, Integer userId) {
|
||||
LambdaQueryWrapper<AppTicket> base = new LambdaQueryWrapper<AppTicket>()
|
||||
.eq(AppTicket::getDeleted, 0)
|
||||
.eq(ObjectUtil.isNotNull(websiteId), AppTicket::getWebsiteId, websiteId)
|
||||
.eq(ObjectUtil.isNotNull(userId), AppTicket::getSubmitUserId, userId);
|
||||
|
||||
Map<String, Long> result = new HashMap<>();
|
||||
result.put("total", (long) count(base.clone()));
|
||||
result.put("pending", (long) count(base.clone().in(AppTicket::getStatus, "pending", "assigned")));
|
||||
result.put("processing", (long) count(base.clone().eq(AppTicket::getStatus, "processing")));
|
||||
result.put("resolved", (long) count(base.clone().eq(AppTicket::getStatus, "resolved")));
|
||||
result.put("closed", (long) count(base.clone().eq(AppTicket::getStatus, "closed")));
|
||||
return result;
|
||||
}
|
||||
|
||||
// ─── 获取技术人员列表 ─────────────────────────────────────────
|
||||
@Override
|
||||
public List<Map<String, Object>> getTechStaffList() {
|
||||
List<AppUser> members = appUserService.list(
|
||||
new LambdaQueryWrapper<AppUser>()
|
||||
.eq(AppUser::getStatus, 0)
|
||||
.in(AppUser::getRole, "owner", "admin", "developer")
|
||||
.select(AppUser::getUserId, AppUser::getNickname, AppUser::getAvatar));
|
||||
|
||||
// 去重(一个用户可能在多个应用里)
|
||||
Map<Integer, AppUser> dedupMap = new LinkedHashMap<>();
|
||||
for (AppUser m : members) {
|
||||
dedupMap.put(m.getUserId(), m);
|
||||
}
|
||||
|
||||
return dedupMap.values().stream().map(m -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("userId", m.getUserId());
|
||||
map.put("nickname", m.getNickname() != null ? m.getNickname() : "用户" + m.getUserId());
|
||||
map.put("avatar", m.getAvatar());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// ════════════════════════════════════════════════════════════
|
||||
// 异步消息推送
|
||||
// ════════════════════════════════════════════════════════════
|
||||
|
||||
/**
|
||||
* 场景1:新工单提交 → 通知分配到的技术人员
|
||||
*/
|
||||
@Async
|
||||
public void sendTicketCreatedAsync(AppTicket ticket) {
|
||||
String now = now();
|
||||
String title = String.format("🎫 新工单待处理(%s)", now);
|
||||
|
||||
String assigneeLine = StrUtil.isNotBlank(ticket.getAssigneeName())
|
||||
? "**处理人:** " + ticket.getAssigneeName()
|
||||
: "**处理人:** 待分配";
|
||||
|
||||
String wecomContent = String.format(
|
||||
"## %s\n" +
|
||||
"> **工单号:** %s\n" +
|
||||
"> **标题:** %s\n" +
|
||||
"> **分类:** %s **优先级:** %s\n" +
|
||||
"> **提交人:** %s\n" +
|
||||
"> %s\n" +
|
||||
"> **描述:** %s",
|
||||
title,
|
||||
nullSafe(ticket.getTicketNo()),
|
||||
nullSafe(ticket.getTitle()),
|
||||
categoryLabel(ticket.getCategory()), priorityLabel(ticket.getPriority()),
|
||||
nullSafe(ticket.getSubmitUserName()),
|
||||
assigneeLine,
|
||||
truncate(ticket.getContent(), 120)
|
||||
);
|
||||
|
||||
List<String[]> feishuLines = Arrays.asList(
|
||||
new String[]{"工单号:" + nullSafe(ticket.getTicketNo())},
|
||||
new String[]{"标 题:" + nullSafe(ticket.getTitle())},
|
||||
new String[]{"分 类:" + categoryLabel(ticket.getCategory()) + " 优先级:" + priorityLabel(ticket.getPriority())},
|
||||
new String[]{"提交人:" + nullSafe(ticket.getSubmitUserName())},
|
||||
new String[]{assigneeLine.replace("**", "")},
|
||||
new String[]{"描 述:" + truncate(ticket.getContent(), 120)}
|
||||
);
|
||||
|
||||
doSend(title, wecomContent, feishuLines, "ticket_created");
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景2:工单被重新分配 → 通知新处理人
|
||||
*/
|
||||
@Async
|
||||
public void sendTicketAssignedAsync(AppTicket ticket) {
|
||||
String now = now();
|
||||
String title = String.format("📋 工单已分配给您(%s)", now);
|
||||
|
||||
String wecomContent = String.format(
|
||||
"## %s\n" +
|
||||
"> **工单号:** %s\n" +
|
||||
"> **标题:** %s\n" +
|
||||
"> **分配给:** <font color=\"warning\">%s</font>\n" +
|
||||
"> **分类:** %s **优先级:** %s\n" +
|
||||
"> **描述:** %s",
|
||||
title,
|
||||
nullSafe(ticket.getTicketNo()),
|
||||
nullSafe(ticket.getTitle()),
|
||||
nullSafe(ticket.getAssigneeName()),
|
||||
categoryLabel(ticket.getCategory()), priorityLabel(ticket.getPriority()),
|
||||
truncate(ticket.getContent(), 100)
|
||||
);
|
||||
|
||||
List<String[]> feishuLines = Arrays.asList(
|
||||
new String[]{"工单号:" + nullSafe(ticket.getTicketNo())},
|
||||
new String[]{"标 题:" + nullSafe(ticket.getTitle())},
|
||||
new String[]{"分配给:" + nullSafe(ticket.getAssigneeName())},
|
||||
new String[]{"分 类:" + categoryLabel(ticket.getCategory()) + " 优先级:" + priorityLabel(ticket.getPriority())},
|
||||
new String[]{"描 述:" + truncate(ticket.getContent(), 100)}
|
||||
);
|
||||
|
||||
doSend(title, wecomContent, feishuLines, "ticket_assigned");
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景3:有新回复 → 技术人员回复则通知客户,客户回复则通知技术人员
|
||||
*/
|
||||
@Async
|
||||
public void sendReplyNotifyAsync(AppTicket ticket, AppTicketReply reply) {
|
||||
boolean isStaff = Integer.valueOf(1).equals(reply.getIsStaff());
|
||||
String now = now();
|
||||
String who = isStaff ? "技术人员" : "用户";
|
||||
String notifyRole = isStaff ? "您的工单有新回复" : "工单有用户新回复";
|
||||
String title = String.format("💬 %s(%s)", notifyRole, now);
|
||||
|
||||
String wecomContent = String.format(
|
||||
"## %s\n" +
|
||||
"> **工单号:** %s\n" +
|
||||
"> **标题:** %s\n" +
|
||||
"> **回复人:** %s(%s)\n" +
|
||||
"> **回复内容:** %s",
|
||||
title,
|
||||
nullSafe(ticket.getTicketNo()),
|
||||
nullSafe(ticket.getTitle()),
|
||||
nullSafe(reply.getUserName()), who,
|
||||
truncate(reply.getContent(), 200)
|
||||
);
|
||||
|
||||
List<String[]> feishuLines = Arrays.asList(
|
||||
new String[]{"工单号:" + nullSafe(ticket.getTicketNo())},
|
||||
new String[]{"标 题:" + nullSafe(ticket.getTitle())},
|
||||
new String[]{"回复人:" + nullSafe(reply.getUserName()) + "(" + who + ")"},
|
||||
new String[]{"回复内容:" + truncate(reply.getContent(), 200)}
|
||||
);
|
||||
|
||||
doSend(title, wecomContent, feishuLines, "ticket_reply");
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景4:状态变更(已解决/已关闭)→ 通知提交人
|
||||
*/
|
||||
@Async
|
||||
public void sendStatusChangedAsync(AppTicket ticket, String status) {
|
||||
String now = now();
|
||||
String emoji = "resolved".equals(status) ? "✅" : "🔒";
|
||||
String statusLabel = "resolved".equals(status) ? "已解决" : "已关闭";
|
||||
String title = String.format("%s 工单%s(%s)", emoji, statusLabel, now);
|
||||
|
||||
String wecomContent = String.format(
|
||||
"## %s\n" +
|
||||
"> **工单号:** %s\n" +
|
||||
"> **标题:** %s\n" +
|
||||
"> **提交人:** %s\n" +
|
||||
"> **处理人:** %s\n" +
|
||||
"> **状态:** <font color=\"%s\">%s</font>",
|
||||
title,
|
||||
nullSafe(ticket.getTicketNo()),
|
||||
nullSafe(ticket.getTitle()),
|
||||
nullSafe(ticket.getSubmitUserName()),
|
||||
nullSafe(ticket.getAssigneeName()),
|
||||
"resolved".equals(status) ? "info" : "comment",
|
||||
statusLabel
|
||||
);
|
||||
|
||||
List<String[]> feishuLines = Arrays.asList(
|
||||
new String[]{"工单号:" + nullSafe(ticket.getTicketNo())},
|
||||
new String[]{"标 题:" + nullSafe(ticket.getTitle())},
|
||||
new String[]{"提交人:" + nullSafe(ticket.getSubmitUserName())},
|
||||
new String[]{"处理人:" + nullSafe(ticket.getAssigneeName())},
|
||||
new String[]{"状 态:" + statusLabel}
|
||||
);
|
||||
|
||||
doSend(title, wecomContent, feishuLines, "ticket_status");
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一发送入口:企业微信 + 飞书
|
||||
*/
|
||||
private void doSend(String title, String wecomContent, List<String[]> feishuLines, String scene) {
|
||||
if (StrUtil.isNotBlank(wecomWebhook)) {
|
||||
try {
|
||||
sendWecom(wecomContent);
|
||||
} catch (Exception e) {
|
||||
log.warn("[工单通知][{}] 企业微信发送失败: {}", scene, e.getMessage());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(feishuWebhook)) {
|
||||
try {
|
||||
sendFeishu(title, feishuLines);
|
||||
} catch (Exception e) {
|
||||
log.warn("[工单通知][{}] 飞书发送失败: {}", scene, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业微信群机器人 - markdown 消息
|
||||
* 文档:https://developer.work.weixin.qq.com/document/path/91770
|
||||
*/
|
||||
private void sendWecom(String content) {
|
||||
Map<String, Object> textMap = new HashMap<>();
|
||||
textMap.put("content", content);
|
||||
Map<String, Object> payload = new HashMap<>();
|
||||
payload.put("msgtype", "markdown");
|
||||
payload.put("markdown", textMap);
|
||||
String resp = HttpUtil.post(wecomWebhook, JSON.toJSONString(payload));
|
||||
log.info("[工单通知] 企业微信推送结果: {}", resp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞书群机器人 - 富文本(post)消息
|
||||
* 文档:https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot
|
||||
*/
|
||||
private void sendFeishu(String title, List<String[]> lines) {
|
||||
List<List<Map<String, String>>> content = new ArrayList<>();
|
||||
for (String[] line : lines) {
|
||||
Map<String, String> node = new HashMap<>();
|
||||
node.put("tag", "text");
|
||||
node.put("text", line[0]);
|
||||
content.add(Collections.singletonList(node));
|
||||
}
|
||||
|
||||
Map<String, Object> zhCn = new HashMap<>();
|
||||
zhCn.put("title", title);
|
||||
zhCn.put("content", content);
|
||||
Map<String, Object> postContent = new HashMap<>();
|
||||
postContent.put("zh_cn", zhCn);
|
||||
Map<String, Object> post = new HashMap<>();
|
||||
post.put("content", postContent);
|
||||
Map<String, Object> payload = new HashMap<>();
|
||||
payload.put("msg_type", "post");
|
||||
payload.put("content", post);
|
||||
|
||||
String resp = HttpUtil.post(feishuWebhook, JSON.toJSONString(payload));
|
||||
log.info("[工单通知] 飞书推送结果: {}", resp);
|
||||
}
|
||||
|
||||
// ════════════════════════════════════════════════════════════
|
||||
// 工具方法
|
||||
// ════════════════════════════════════════════════════════════
|
||||
|
||||
private String now() {
|
||||
return LocalDateTime.now().format(DateTimeFormatter.ofPattern("MM-dd HH:mm"));
|
||||
}
|
||||
|
||||
private String nullSafe(String s) {
|
||||
return StrUtil.isBlank(s) ? "—" : s;
|
||||
}
|
||||
|
||||
private String truncate(String s, int max) {
|
||||
if (StrUtil.isBlank(s)) return "—";
|
||||
return s.length() > max ? s.substring(0, max) + "…" : s;
|
||||
}
|
||||
|
||||
private String categoryLabel(String category) {
|
||||
if (category == null) return "其他";
|
||||
return switch (category) {
|
||||
case "bug" -> "Bug反馈";
|
||||
case "feature" -> "功能需求";
|
||||
case "config" -> "配置问题";
|
||||
case "performance" -> "性能问题";
|
||||
case "security" -> "安全问题";
|
||||
default -> category;
|
||||
};
|
||||
}
|
||||
|
||||
private String priorityLabel(String priority) {
|
||||
if (priority == null) return "普通";
|
||||
return switch (priority) {
|
||||
case "urgent" -> "🔴 紧急";
|
||||
case "high" -> "🟠 高";
|
||||
case "normal" -> "🟡 普通";
|
||||
case "low" -> "🟢 低";
|
||||
default -> priority;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package com.gxwebsoft.app.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.app.mapper.AppUserMapper;
|
||||
import com.gxwebsoft.app.service.AppUserService;
|
||||
import com.gxwebsoft.app.entity.AppUser;
|
||||
import com.gxwebsoft.app.param.AppUserParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用成员Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> implements AppUserService {
|
||||
|
||||
/** 注入同 jar 包内的 UserService,用于写入冗余用户信息,不做跨库 JOIN */
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public PageResult<AppUser> pageRel(AppUserParam param) {
|
||||
PageParam<AppUser, AppUserParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time asc");
|
||||
List<AppUser> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppUser> listRel(AppUserParam param) {
|
||||
List<AppUser> list = baseMapper.selectListRel(param);
|
||||
PageParam<AppUser, AppUserParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time asc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUser getByIdRel(Integer id) {
|
||||
AppUserParam param = new AppUserParam();
|
||||
param.setId(id.longValue());
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUser inviteUser(Long websiteId, Integer userId, String role, Integer inviteBy) {
|
||||
// 检查是否已经是成员
|
||||
if (isMember(websiteId, userId)) {
|
||||
throw new RuntimeException("该用户已经是应用成员");
|
||||
}
|
||||
|
||||
// 查询用户基础信息并冗余写入,避免跨库 JOIN
|
||||
User sysUser = userService.getByIdIgnoreTenant(userId);
|
||||
if (sysUser == null) {
|
||||
throw new RuntimeException("用户不存在,userId=" + userId);
|
||||
}
|
||||
|
||||
AppUser appUser = new AppUser();
|
||||
appUser.setWebsiteId(websiteId);
|
||||
appUser.setUserId(userId);
|
||||
appUser.setRole(role != null ? role : "developer");
|
||||
appUser.setInviteBy(inviteBy.longValue());
|
||||
appUser.setInviteTime(LocalDateTime.now());
|
||||
appUser.setStatus(0);
|
||||
appUser.setSortNumber(0);
|
||||
// 冗余写入用户基础信息,彻底解除跨库 JOIN 依赖
|
||||
appUser.setUsername(sysUser.getUsername());
|
||||
appUser.setNickname(sysUser.getNickname());
|
||||
appUser.setAvatar(sysUser.getAvatar());
|
||||
appUser.setPhone(sysUser.getPhone());
|
||||
|
||||
save(appUser);
|
||||
log.info("邀请成员成功,websiteId={}, userId={}, username={}, role={}", websiteId, userId, sysUser.getUsername(), role);
|
||||
return appUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRole(Long id, String role) {
|
||||
return update(new LambdaUpdateWrapper<AppUser>()
|
||||
.eq(AppUser::getId, id)
|
||||
.set(AppUser::getRole, role));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMember(Long websiteId, Integer userId) {
|
||||
long count = count(new LambdaQueryWrapper<AppUser>()
|
||||
.eq(AppUser::getWebsiteId, websiteId)
|
||||
.eq(AppUser::getUserId, userId)
|
||||
.eq(AppUser::getStatus, 0));
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User findUserByPhone(String phone) {
|
||||
return userService.getByPhone(phone);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package com.gxwebsoft.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.app.mapper.AppVersionMapper;
|
||||
import com.gxwebsoft.app.service.AppVersionService;
|
||||
import com.gxwebsoft.app.entity.AppVersion;
|
||||
import com.gxwebsoft.app.param.AppVersionParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用版本发布记录Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2026-03-28 21:29:44
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVersion> implements AppVersionService {
|
||||
|
||||
@Override
|
||||
public PageResult<AppVersion> pageRel(AppVersionParam param) {
|
||||
PageParam<AppVersion, AppVersionParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
List<AppVersion> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppVersion> listRel(AppVersionParam param) {
|
||||
List<AppVersion> list = baseMapper.selectListRel(param);
|
||||
PageParam<AppVersion, AppVersionParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppVersion getByIdRel(Integer id) {
|
||||
AppVersionParam param = new AppVersionParam();
|
||||
param.setId(id.longValue());
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean publish(Long id, Integer publishBy) {
|
||||
AppVersion version = getById(id);
|
||||
if (version == null) {
|
||||
throw new RuntimeException("版本不存在");
|
||||
}
|
||||
Long websiteId = version.getWebsiteId();
|
||||
|
||||
// 1. 将该应用下所有版本的 isCurrent 设为 false
|
||||
update(new LambdaUpdateWrapper<AppVersion>()
|
||||
.eq(AppVersion::getWebsiteId, websiteId)
|
||||
.set(AppVersion::getIsCurrent, false));
|
||||
|
||||
// 2. 将当前版本设为已发布+当前版本
|
||||
version.setStatus(1);
|
||||
version.setIsCurrent(true);
|
||||
version.setPublishBy(publishBy.longValue());
|
||||
version.setPublishTime(LocalDateTime.now());
|
||||
|
||||
boolean result = updateById(version);
|
||||
log.info("发布版本成功,id={}, versionNo={}", id, version.getVersionNo());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean rollback(Long id, Integer publishBy) {
|
||||
AppVersion targetVersion = getById(id);
|
||||
if (targetVersion == null) {
|
||||
throw new RuntimeException("目标版本不存在");
|
||||
}
|
||||
Long websiteId = targetVersion.getWebsiteId();
|
||||
|
||||
// 1. 将当前版本标记为已回滚
|
||||
update(new LambdaUpdateWrapper<AppVersion>()
|
||||
.eq(AppVersion::getWebsiteId, websiteId)
|
||||
.eq(AppVersion::getIsCurrent, true)
|
||||
.set(AppVersion::getStatus, 2) // 2=已回滚
|
||||
.set(AppVersion::getIsCurrent, false));
|
||||
|
||||
// 2. 将目标版本设为当前版本
|
||||
targetVersion.setStatus(1);
|
||||
targetVersion.setIsCurrent(true);
|
||||
targetVersion.setPublishBy(publishBy.longValue());
|
||||
targetVersion.setPublishTime(LocalDateTime.now());
|
||||
|
||||
boolean result = updateById(targetVersion);
|
||||
log.info("回滚版本成功,id={}, versionNo={}", id, targetVersion.getVersionNo());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppVersion getCurrentVersion(Long websiteId) {
|
||||
return getOne(new LambdaQueryWrapper<AppVersion>()
|
||||
.eq(AppVersion::getWebsiteId, websiteId)
|
||||
.eq(AppVersion::getIsCurrent, true)
|
||||
.last("LIMIT 1"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
-- ----------------------------
|
||||
-- 开发者资源管理表
|
||||
-- 统一存放服务器/数据库/云存储/域名/SSL证书等开发基础设施资源
|
||||
-- ----------------------------
|
||||
CREATE TABLE IF NOT EXISTS `app_resource` (
|
||||
`resource_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '资源ID',
|
||||
`resource_type` VARCHAR(20) NOT NULL COMMENT '资源类型: server/database/storage/domain/ssl',
|
||||
`name` VARCHAR(100) NOT NULL COMMENT '资源名称',
|
||||
`provider` VARCHAR(30) DEFAULT NULL COMMENT '服务商: tencent/aliyun/huawei/other',
|
||||
|
||||
-- 服务器字段
|
||||
`ip` VARCHAR(50) DEFAULT NULL COMMENT 'IP地址(服务器用)',
|
||||
|
||||
-- 数据库字段
|
||||
`db_type` VARCHAR(30) DEFAULT NULL COMMENT '数据库类型: MySQL/PostgreSQL/Redis/MongoDB',
|
||||
`host` VARCHAR(200) DEFAULT NULL COMMENT '连接主机地址(数据库用)',
|
||||
`port` INT DEFAULT NULL COMMENT '连接端口(数据库用)',
|
||||
|
||||
-- 云存储字段
|
||||
`region` VARCHAR(50) DEFAULT NULL COMMENT '地区/Region(云存储用)',
|
||||
`acl` VARCHAR(30) DEFAULT 'private' COMMENT '访问权限: public-read/private(云存储用)',
|
||||
`used_bytes` BIGINT DEFAULT 0 COMMENT '已用空间(字节,云存储用)',
|
||||
|
||||
-- 域名字段
|
||||
`domain` VARCHAR(200) DEFAULT NULL COMMENT '域名(域名/SSL用)',
|
||||
`registrar` VARCHAR(100) DEFAULT NULL COMMENT '注册商(域名用)',
|
||||
`icp` TINYINT(1) DEFAULT 0 COMMENT '是否已备案: 0否 1是(域名用)',
|
||||
`icp_no` VARCHAR(100) DEFAULT NULL COMMENT 'ICP备案号(域名用)',
|
||||
`ssl_bound` TINYINT(1) DEFAULT 0 COMMENT '是否已绑定SSL(域名冗余标记)',
|
||||
|
||||
-- SSL证书字段
|
||||
`cert_type` VARCHAR(10) DEFAULT NULL COMMENT '证书类型: DV/OV/EV(SSL用)',
|
||||
`issuer` VARCHAR(100) DEFAULT NULL COMMENT '颁发机构(SSL用)',
|
||||
|
||||
-- 通用字段
|
||||
`status` VARCHAR(20) NOT NULL DEFAULT 'running' COMMENT '状态: running/stopped/expired/pending',
|
||||
`website_id` BIGINT DEFAULT NULL COMMENT '关联应用ID(可选)',
|
||||
`expire_at` DATE DEFAULT NULL COMMENT '到期时间',
|
||||
`remark` VARCHAR(500) DEFAULT NULL COMMENT '备注',
|
||||
`user_id` INT NOT NULL COMMENT '所属用户ID',
|
||||
`tenant_id` INT DEFAULT NULL COMMENT '租户ID',
|
||||
`deleted` TINYINT NOT NULL DEFAULT 0 COMMENT '是否删除: 0否 1是',
|
||||
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
|
||||
PRIMARY KEY (`resource_id`),
|
||||
KEY `idx_resource_type` (`resource_type`),
|
||||
KEY `idx_user_id` (`user_id`),
|
||||
KEY `idx_tenant_id` (`tenant_id`),
|
||||
KEY `idx_website_id` (`website_id`),
|
||||
KEY `idx_status` (`status`),
|
||||
KEY `idx_expire_at` (`expire_at`),
|
||||
KEY `idx_deleted` (`deleted`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='开发者资源管理(服务器/数据库/云存储/域名/SSL)';
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.gxwebsoft.auto.controller;
|
||||
|
||||
import com.gxwebsoft.auto.dto.QrLoginConfirmRequest;
|
||||
import com.gxwebsoft.auto.dto.QrLoginGenerateResponse;
|
||||
import com.gxwebsoft.auto.dto.QrLoginStatusResponse;
|
||||
import com.gxwebsoft.auto.service.QrLoginService;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 认证模块
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-06 22:50:25
|
||||
*/
|
||||
@Tag(name = "认证模块")
|
||||
@RestController
|
||||
@RequestMapping("/api/qr-login")
|
||||
public class QrLoginController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private QrLoginService qrLoginService;
|
||||
|
||||
/**
|
||||
* 生成扫码登录token
|
||||
*/
|
||||
@Operation(summary = "生成扫码登录token")
|
||||
@PostMapping("/generate")
|
||||
public ApiResult<?> generateQrLoginToken() {
|
||||
try {
|
||||
QrLoginGenerateResponse response = qrLoginService.generateQrLoginToken();
|
||||
return success("生成成功", response);
|
||||
} catch (Exception e) {
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查扫码登录状态
|
||||
*/
|
||||
@Operation(summary = "检查扫码登录状态")
|
||||
@GetMapping("/status/{token}")
|
||||
public ApiResult<?> checkQrLoginStatus(
|
||||
@Parameter(description = "扫码登录token") @PathVariable String token) {
|
||||
try {
|
||||
QrLoginStatusResponse response = qrLoginService.checkQrLoginStatus(token);
|
||||
return success("查询成功", response);
|
||||
} catch (Exception e) {
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认扫码登录
|
||||
*/
|
||||
@Operation(summary = "确认扫码登录")
|
||||
@PostMapping("/confirm")
|
||||
public ApiResult<?> confirmQrLogin(@Valid @RequestBody QrLoginConfirmRequest request) {
|
||||
try {
|
||||
QrLoginStatusResponse response = qrLoginService.confirmQrLogin(request);
|
||||
return success("确认成功", response);
|
||||
} catch (Exception e) {
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码操作(可选接口,用于移动端扫码后更新状态)
|
||||
*/
|
||||
@Operation(summary = "扫码操作")
|
||||
@PostMapping("/scan/{token}")
|
||||
public ApiResult<?> scanQrCode(@Parameter(description = "扫码登录token") @PathVariable String token) {
|
||||
try {
|
||||
boolean result = qrLoginService.scanQrCode(token);
|
||||
return success("操作成功", result);
|
||||
} catch (Exception e) {
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信小程序扫码登录确认(便捷接口)
|
||||
*/
|
||||
@Operation(summary = "微信小程序扫码登录确认")
|
||||
@PostMapping("/wechat-confirm")
|
||||
public ApiResult<?> wechatMiniProgramConfirm(@Valid @RequestBody QrLoginConfirmRequest request) {
|
||||
try {
|
||||
// 设置平台为微信小程序
|
||||
request.setPlatform("miniprogram");
|
||||
QrLoginStatusResponse response = qrLoginService.confirmQrLogin(request);
|
||||
return success("微信小程序登录确认成功", response);
|
||||
} catch (Exception e) {
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.gxwebsoft.auto.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 扫码登录确认请求
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-31
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "扫码登录确认请求")
|
||||
public class QrLoginConfirmRequest {
|
||||
|
||||
@Schema(description = "扫码登录token")
|
||||
@NotBlank(message = "token不能为空")
|
||||
private String token;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "登录平台: web-网页端, app-移动应用, miniprogram-微信小程序")
|
||||
private String platform;
|
||||
|
||||
@Schema(description = "微信小程序相关信息")
|
||||
private WechatMiniProgramInfo wechatInfo;
|
||||
|
||||
/**
|
||||
* 微信小程序信息
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "微信小程序信息")
|
||||
public static class WechatMiniProgramInfo {
|
||||
@Schema(description = "微信openid")
|
||||
private String openid;
|
||||
|
||||
@Schema(description = "微信unionid")
|
||||
private String unionid;
|
||||
|
||||
@Schema(description = "微信昵称")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "微信头像")
|
||||
private String avatar;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.gxwebsoft.auto.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 扫码登录数据模型
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-31
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QrLoginData {
|
||||
|
||||
/**
|
||||
* 扫码登录token
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 状态: pending-等待扫码, scanned-已扫码, confirmed-已确认, expired-已过期
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 用户ID(扫码确认后设置)
|
||||
*/
|
||||
private Integer userId;
|
||||
|
||||
/**
|
||||
* 用户名(扫码确认后设置)
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
private LocalDateTime expireTime;
|
||||
|
||||
/**
|
||||
* JWT访问令牌(确认后生成)
|
||||
*/
|
||||
private String accessToken;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.gxwebsoft.auto.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 扫码登录生成响应
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-31
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "扫码登录生成响应")
|
||||
public class QrLoginGenerateResponse {
|
||||
|
||||
@Schema(description = "扫码登录token")
|
||||
private String token;
|
||||
|
||||
@Schema(description = "二维码内容")
|
||||
private String qrCode;
|
||||
|
||||
@Schema(description = "过期时间(秒)")
|
||||
private Long expiresIn;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.gxwebsoft.auto.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 扫码登录状态响应
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-31
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "扫码登录状态响应")
|
||||
public class QrLoginStatusResponse {
|
||||
|
||||
@Schema(description = "状态: pending-等待扫码, scanned-已扫码, confirmed-已确认, expired-已过期")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "JWT访问令牌(仅在confirmed状态时返回)")
|
||||
private String accessToken;
|
||||
|
||||
@Schema(description = "用户信息(仅在confirmed状态时返回)")
|
||||
private Object userInfo;
|
||||
|
||||
@Schema(description = "剩余过期时间(秒)")
|
||||
private Long expiresIn;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.gxwebsoft.auto.service;
|
||||
|
||||
import com.gxwebsoft.auto.dto.QrLoginConfirmRequest;
|
||||
import com.gxwebsoft.auto.dto.QrLoginGenerateResponse;
|
||||
import com.gxwebsoft.auto.dto.QrLoginStatusResponse;
|
||||
|
||||
/**
|
||||
* 扫码登录服务接口
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-31
|
||||
*/
|
||||
public interface QrLoginService {
|
||||
|
||||
/**
|
||||
* 生成扫码登录token
|
||||
*
|
||||
* @return QrLoginGenerateResponse
|
||||
*/
|
||||
QrLoginGenerateResponse generateQrLoginToken();
|
||||
|
||||
/**
|
||||
* 检查扫码登录状态
|
||||
*
|
||||
* @param token 扫码登录token
|
||||
* @return QrLoginStatusResponse
|
||||
*/
|
||||
QrLoginStatusResponse checkQrLoginStatus(String token);
|
||||
|
||||
/**
|
||||
* 确认扫码登录
|
||||
*
|
||||
* @param request 确认请求
|
||||
* @return QrLoginStatusResponse
|
||||
*/
|
||||
QrLoginStatusResponse confirmQrLogin(QrLoginConfirmRequest request);
|
||||
|
||||
/**
|
||||
* 扫码操作(更新状态为已扫码)
|
||||
*
|
||||
* @param token 扫码登录token
|
||||
* @return boolean
|
||||
*/
|
||||
boolean scanQrCode(String token);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
package com.gxwebsoft.auto.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.gxwebsoft.auto.dto.*;
|
||||
import com.gxwebsoft.auto.service.QrLoginService;
|
||||
import com.gxwebsoft.common.core.security.JwtSubject;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.utils.JSONUtil;
|
||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.RedisConstants.*;
|
||||
|
||||
/**
|
||||
* 扫码登录服务实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-31
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class QrLoginServiceImpl implements QrLoginService {
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Value("${config.jwt.secret:websoft-jwt-secret-key-2025}")
|
||||
private String jwtSecret;
|
||||
|
||||
@Value("${config.jwt.expire:86400}")
|
||||
private Long jwtExpire;
|
||||
|
||||
@Override
|
||||
public QrLoginGenerateResponse generateQrLoginToken() {
|
||||
// 生成唯一的扫码登录token
|
||||
String token = UUID.randomUUID().toString(true);
|
||||
|
||||
// 创建扫码登录数据
|
||||
QrLoginData qrLoginData = new QrLoginData();
|
||||
qrLoginData.setToken(token);
|
||||
qrLoginData.setStatus(QR_LOGIN_STATUS_PENDING);
|
||||
qrLoginData.setCreateTime(LocalDateTime.now());
|
||||
qrLoginData.setExpireTime(LocalDateTime.now().plusSeconds(QR_LOGIN_TOKEN_TTL));
|
||||
|
||||
// 存储到Redis,设置过期时间
|
||||
String redisKey = QR_LOGIN_TOKEN_KEY + token;
|
||||
redisUtil.set(redisKey, qrLoginData, QR_LOGIN_TOKEN_TTL, TimeUnit.SECONDS);
|
||||
|
||||
log.info("生成扫码登录token: {}", token);
|
||||
|
||||
// 构造二维码内容(这里可以是前端登录页面的URL + token参数)
|
||||
String qrCodeContent = "qr-login:" + token;
|
||||
|
||||
return new QrLoginGenerateResponse(token, qrCodeContent, QR_LOGIN_TOKEN_TTL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QrLoginStatusResponse checkQrLoginStatus(String token) {
|
||||
if (StrUtil.isBlank(token)) {
|
||||
return new QrLoginStatusResponse(QR_LOGIN_STATUS_EXPIRED, null, null, 0L);
|
||||
}
|
||||
|
||||
String redisKey = QR_LOGIN_TOKEN_KEY + token;
|
||||
QrLoginData qrLoginData = redisUtil.get(redisKey, QrLoginData.class);
|
||||
|
||||
if (qrLoginData == null) {
|
||||
return new QrLoginStatusResponse(QR_LOGIN_STATUS_EXPIRED, null, null, 0L);
|
||||
}
|
||||
|
||||
// 检查是否过期
|
||||
if (LocalDateTime.now().isAfter(qrLoginData.getExpireTime())) {
|
||||
// 删除过期的token
|
||||
redisUtil.delete(redisKey);
|
||||
return new QrLoginStatusResponse(QR_LOGIN_STATUS_EXPIRED, null, null, 0L);
|
||||
}
|
||||
|
||||
// 计算剩余过期时间
|
||||
long expiresIn = ChronoUnit.SECONDS.between(LocalDateTime.now(), qrLoginData.getExpireTime());
|
||||
|
||||
QrLoginStatusResponse response = new QrLoginStatusResponse();
|
||||
response.setStatus(qrLoginData.getStatus());
|
||||
response.setExpiresIn(expiresIn);
|
||||
|
||||
// 如果已确认,返回token和用户信息
|
||||
if (QR_LOGIN_STATUS_CONFIRMED.equals(qrLoginData.getStatus())) {
|
||||
response.setAccessToken(qrLoginData.getAccessToken());
|
||||
|
||||
// 获取用户信息
|
||||
if (qrLoginData.getUserId() != null) {
|
||||
User user = userService.getByIdRel(qrLoginData.getUserId());
|
||||
if (user != null) {
|
||||
// 清除敏感信息
|
||||
user.setPassword(null);
|
||||
response.setUserInfo(user);
|
||||
}
|
||||
}
|
||||
|
||||
// 确认后删除token,防止重复使用
|
||||
redisUtil.delete(redisKey);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QrLoginStatusResponse confirmQrLogin(QrLoginConfirmRequest request) {
|
||||
String token = request.getToken();
|
||||
Integer userId = request.getUserId();
|
||||
String platform = request.getPlatform();
|
||||
|
||||
if (StrUtil.isBlank(token) || userId == null) {
|
||||
throw new RuntimeException("参数不能为空");
|
||||
}
|
||||
|
||||
String redisKey = QR_LOGIN_TOKEN_KEY + token;
|
||||
QrLoginData qrLoginData = redisUtil.get(redisKey, QrLoginData.class);
|
||||
|
||||
if (qrLoginData == null) {
|
||||
throw new RuntimeException("扫码登录token不存在或已过期");
|
||||
}
|
||||
|
||||
// 检查是否过期
|
||||
if (LocalDateTime.now().isAfter(qrLoginData.getExpireTime())) {
|
||||
redisUtil.delete(redisKey);
|
||||
throw new RuntimeException("扫码登录token已过期");
|
||||
}
|
||||
|
||||
// 获取用户信息
|
||||
User user = userService.getByIdRel(userId);
|
||||
if (user == null) {
|
||||
throw new RuntimeException("用户不存在");
|
||||
}
|
||||
|
||||
// 检查用户状态
|
||||
if (user.getStatus() != null && user.getStatus() != 0) {
|
||||
throw new RuntimeException("用户已被冻结");
|
||||
}
|
||||
|
||||
// 如果是微信小程序登录,处理微信相关信息
|
||||
if ("miniprogram".equals(platform) && request.getWechatInfo() != null) {
|
||||
handleWechatMiniProgramLogin(user, request.getWechatInfo());
|
||||
}
|
||||
|
||||
// 生成JWT token
|
||||
JwtSubject jwtSubject = new JwtSubject(user.getUsername(), user.getTenantId());
|
||||
String accessToken = JwtUtil.buildToken(jwtSubject, jwtExpire, jwtSecret);
|
||||
|
||||
// 更新扫码登录数据
|
||||
qrLoginData.setStatus(QR_LOGIN_STATUS_CONFIRMED);
|
||||
qrLoginData.setUserId(userId);
|
||||
qrLoginData.setUsername(user.getUsername());
|
||||
qrLoginData.setAccessToken(accessToken);
|
||||
|
||||
// 更新Redis中的数据
|
||||
redisUtil.set(redisKey, qrLoginData, 60L, TimeUnit.SECONDS); // 给前端60秒时间获取token
|
||||
|
||||
log.info("用户 {} 通过 {} 平台确认扫码登录,token: {}", user.getUsername(),
|
||||
platform != null ? platform : "unknown", token);
|
||||
|
||||
// 清除敏感信息
|
||||
user.setPassword(null);
|
||||
|
||||
return new QrLoginStatusResponse(QR_LOGIN_STATUS_CONFIRMED, accessToken, user, 60L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理微信小程序登录相关逻辑
|
||||
*/
|
||||
private void handleWechatMiniProgramLogin(User user, QrLoginConfirmRequest.WechatMiniProgramInfo wechatInfo) {
|
||||
// 更新用户的微信信息
|
||||
if (StrUtil.isNotBlank(wechatInfo.getOpenid())) {
|
||||
user.setOpenid(wechatInfo.getOpenid());
|
||||
}
|
||||
if (StrUtil.isNotBlank(wechatInfo.getUnionid())) {
|
||||
user.setUnionid(wechatInfo.getUnionid());
|
||||
}
|
||||
if (StrUtil.isNotBlank(wechatInfo.getNickname()) && StrUtil.isBlank(user.getNickname())) {
|
||||
user.setNickname(wechatInfo.getNickname());
|
||||
}
|
||||
if (StrUtil.isNotBlank(wechatInfo.getAvatar()) && StrUtil.isBlank(user.getAvatar())) {
|
||||
user.setAvatar(wechatInfo.getAvatar());
|
||||
}
|
||||
|
||||
// 更新用户信息到数据库
|
||||
try {
|
||||
userService.updateById(user);
|
||||
log.info("更新用户 {} 的微信小程序信息成功", user.getUsername());
|
||||
} catch (Exception e) {
|
||||
log.warn("更新用户 {} 的微信小程序信息失败: {}", user.getUsername(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean scanQrCode(String token) {
|
||||
if (StrUtil.isBlank(token)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String redisKey = QR_LOGIN_TOKEN_KEY + token;
|
||||
QrLoginData qrLoginData = redisUtil.get(redisKey, QrLoginData.class);
|
||||
|
||||
if (qrLoginData == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查是否过期
|
||||
if (LocalDateTime.now().isAfter(qrLoginData.getExpireTime())) {
|
||||
redisUtil.delete(redisKey);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 只有pending状态才能更新为scanned
|
||||
if (QR_LOGIN_STATUS_PENDING.equals(qrLoginData.getStatus())) {
|
||||
qrLoginData.setStatus(QR_LOGIN_STATUS_SCANNED);
|
||||
|
||||
// 计算剩余过期时间
|
||||
long remainingSeconds = ChronoUnit.SECONDS.between(LocalDateTime.now(), qrLoginData.getExpireTime());
|
||||
redisUtil.set(redisKey, qrLoginData, remainingSeconds, TimeUnit.SECONDS);
|
||||
|
||||
log.info("扫码登录token {} 状态更新为已扫码", token);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.gxwebsoft.clinic.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.clinic.service.ClinicAppointmentService;
|
||||
import com.gxwebsoft.clinic.entity.ClinicAppointment;
|
||||
import com.gxwebsoft.clinic.param.ClinicAppointmentParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 挂号控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-19 09:27:04
|
||||
*/
|
||||
@Tag(name = "挂号管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/clinic/clinic-appointment")
|
||||
public class ClinicAppointmentController extends BaseController {
|
||||
@Resource
|
||||
private ClinicAppointmentService clinicAppointmentService;
|
||||
|
||||
@Operation(summary = "分页查询挂号")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ClinicAppointment>> page(ClinicAppointmentParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicAppointmentService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicAppointment:list')")
|
||||
@Operation(summary = "查询全部挂号")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ClinicAppointment>> list(ClinicAppointmentParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicAppointmentService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicAppointment:list')")
|
||||
@Operation(summary = "根据id查询挂号")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ClinicAppointment> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(clinicAppointmentService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicAppointment:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加挂号")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ClinicAppointment clinicAppointment) {
|
||||
if (clinicAppointmentService.save(clinicAppointment)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicAppointment:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改挂号")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ClinicAppointment clinicAppointment) {
|
||||
if (clinicAppointmentService.updateById(clinicAppointment)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicAppointment:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除挂号")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (clinicAppointmentService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicAppointment:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加挂号")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ClinicAppointment> list) {
|
||||
if (clinicAppointmentService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicAppointment:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改挂号")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ClinicAppointment> batchParam) {
|
||||
if (batchParam.update(clinicAppointmentService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicAppointment:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除挂号")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (clinicAppointmentService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.gxwebsoft.clinic.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.clinic.service.ClinicDoctorApplyService;
|
||||
import com.gxwebsoft.clinic.entity.ClinicDoctorApply;
|
||||
import com.gxwebsoft.clinic.param.ClinicDoctorApplyParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 医生入驻申请控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-19 09:27:04
|
||||
*/
|
||||
@Tag(name = "医生入驻申请管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/clinic/clinic-doctor-apply")
|
||||
public class ClinicDoctorApplyController extends BaseController {
|
||||
@Resource
|
||||
private ClinicDoctorApplyService clinicDoctorApplyService;
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorApply:list')")
|
||||
@Operation(summary = "分页查询医生入驻申请")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ClinicDoctorApply>> page(ClinicDoctorApplyParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicDoctorApplyService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorApply:list')")
|
||||
@Operation(summary = "查询全部医生入驻申请")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ClinicDoctorApply>> list(ClinicDoctorApplyParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicDoctorApplyService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorApply:list')")
|
||||
@Operation(summary = "根据id查询医生入驻申请")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ClinicDoctorApply> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(clinicDoctorApplyService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorApply:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加医生入驻申请")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ClinicDoctorApply clinicDoctorApply) {
|
||||
// 记录当前登录用户id
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// clinicDoctorApply.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (clinicDoctorApplyService.save(clinicDoctorApply)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorApply:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改医生入驻申请")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ClinicDoctorApply clinicDoctorApply) {
|
||||
if (clinicDoctorApplyService.updateById(clinicDoctorApply)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorApply:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除医生入驻申请")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (clinicDoctorApplyService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorApply:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加医生入驻申请")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ClinicDoctorApply> list) {
|
||||
if (clinicDoctorApplyService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorApply:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改医生入驻申请")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ClinicDoctorApply> batchParam) {
|
||||
if (batchParam.update(clinicDoctorApplyService, "apply_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorApply:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除医生入驻申请")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (clinicDoctorApplyService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.gxwebsoft.clinic.controller;
|
||||
|
||||
import com.gxwebsoft.clinic.entity.ClinicDoctorUser;
|
||||
import com.gxwebsoft.clinic.param.ClinicDoctorUserParam;
|
||||
import com.gxwebsoft.clinic.service.ClinicDoctorUserService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分销商用户记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-23 15:58:21
|
||||
*/
|
||||
@Tag(name = "分销商用户记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/clinic/clinic-doctor-user")
|
||||
public class ClinicDoctorUserController extends BaseController {
|
||||
@Resource
|
||||
private ClinicDoctorUserService clinicDoctorUserService;
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorUser:list')")
|
||||
@Operation(summary = "分页查询分销商用户记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ClinicDoctorUser>> page(ClinicDoctorUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicDoctorUserService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorUser:list')")
|
||||
@Operation(summary = "查询全部分销商用户记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ClinicDoctorUser>> list(ClinicDoctorUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicDoctorUserService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorUser:list')")
|
||||
@Operation(summary = "根据id查询分销商用户记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ClinicDoctorUser> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(clinicDoctorUserService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorUser:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加分销商用户记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ClinicDoctorUser clinicDoctorUser) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
clinicDoctorUser.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (clinicDoctorUserService.save(clinicDoctorUser)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorUser:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改分销商用户记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ClinicDoctorUser clinicDoctorUser) {
|
||||
if (clinicDoctorUserService.updateById(clinicDoctorUser)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorUser:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除分销商用户记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (clinicDoctorUserService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorUser:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加分销商用户记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ClinicDoctorUser> list) {
|
||||
if (clinicDoctorUserService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorUser:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改分销商用户记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ClinicDoctorUser> batchParam) {
|
||||
if (batchParam.update(clinicDoctorUserService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicDoctorUser:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除分销商用户记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (clinicDoctorUserService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.gxwebsoft.clinic.controller;
|
||||
|
||||
import com.gxwebsoft.clinic.entity.ClinicMedicine;
|
||||
import com.gxwebsoft.clinic.param.ClinicMedicineParam;
|
||||
import com.gxwebsoft.clinic.service.ClinicMedicineService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 药品库控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-22 02:06:32
|
||||
*/
|
||||
@Tag(name = "药品库管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/clinic/clinic-medicine")
|
||||
public class ClinicMedicineController extends BaseController {
|
||||
@Resource
|
||||
private ClinicMedicineService clinicMedicineService;
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicine:list')")
|
||||
@Operation(summary = "分页查询药品库")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ClinicMedicine>> page(ClinicMedicineParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicMedicineService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicine:list')")
|
||||
@Operation(summary = "查询全部药品库")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ClinicMedicine>> list(ClinicMedicineParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicMedicineService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicine:list')")
|
||||
@Operation(summary = "根据id查询药品库")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ClinicMedicine> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(clinicMedicineService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicine:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加药品库")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ClinicMedicine clinicMedicine) {
|
||||
// 记录当前登录用户id
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// clinicMedicine.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (clinicMedicineService.save(clinicMedicine)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicine:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改药品库")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ClinicMedicine clinicMedicine) {
|
||||
if (clinicMedicineService.updateById(clinicMedicine)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicine:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除药品库")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (clinicMedicineService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicine:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加药品库")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ClinicMedicine> list) {
|
||||
if (clinicMedicineService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicine:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改药品库")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ClinicMedicine> batchParam) {
|
||||
if (batchParam.update(clinicMedicineService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicine:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除药品库")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (clinicMedicineService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.gxwebsoft.clinic.controller;
|
||||
|
||||
import com.gxwebsoft.clinic.entity.ClinicMedicineInout;
|
||||
import com.gxwebsoft.clinic.param.ClinicMedicineInoutParam;
|
||||
import com.gxwebsoft.clinic.service.ClinicMedicineInoutService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 出入库控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-22 02:06:32
|
||||
*/
|
||||
@Tag(name = "出入库管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/clinic/clinic-medicine-inout")
|
||||
public class ClinicMedicineInoutController extends BaseController {
|
||||
@Resource
|
||||
private ClinicMedicineInoutService clinicMedicineInoutService;
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineInout:list')")
|
||||
@Operation(summary = "分页查询出入库")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ClinicMedicineInout>> page(ClinicMedicineInoutParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicMedicineInoutService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineInout:list')")
|
||||
@Operation(summary = "查询全部出入库")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ClinicMedicineInout>> list(ClinicMedicineInoutParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicMedicineInoutService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineInout:list')")
|
||||
@Operation(summary = "根据id查询出入库")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ClinicMedicineInout> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(clinicMedicineInoutService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineInout:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加出入库")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ClinicMedicineInout clinicMedicineInout) {
|
||||
// 记录当前登录用户id
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// clinicMedicineInout.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (clinicMedicineInoutService.save(clinicMedicineInout)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineInout:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改出入库")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ClinicMedicineInout clinicMedicineInout) {
|
||||
if (clinicMedicineInoutService.updateById(clinicMedicineInout)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineInout:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除出入库")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (clinicMedicineInoutService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineInout:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加出入库")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ClinicMedicineInout> list) {
|
||||
if (clinicMedicineInoutService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineInout:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改出入库")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ClinicMedicineInout> batchParam) {
|
||||
if (batchParam.update(clinicMedicineInoutService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineInout:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除出入库")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (clinicMedicineInoutService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.gxwebsoft.clinic.controller;
|
||||
|
||||
import com.gxwebsoft.clinic.entity.ClinicMedicineStock;
|
||||
import com.gxwebsoft.clinic.param.ClinicMedicineStockParam;
|
||||
import com.gxwebsoft.clinic.service.ClinicMedicineStockService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 药品库存控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-22 02:06:32
|
||||
*/
|
||||
@Tag(name = "药品库存管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/clinic/clinic-medicine-stock")
|
||||
public class ClinicMedicineStockController extends BaseController {
|
||||
@Resource
|
||||
private ClinicMedicineStockService clinicMedicineStockService;
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineStock:list')")
|
||||
@Operation(summary = "分页查询药品库存")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ClinicMedicineStock>> page(ClinicMedicineStockParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicMedicineStockService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineStock:list')")
|
||||
@Operation(summary = "查询全部药品库存")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ClinicMedicineStock>> list(ClinicMedicineStockParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicMedicineStockService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineStock:list')")
|
||||
@Operation(summary = "根据id查询药品库存")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ClinicMedicineStock> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(clinicMedicineStockService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineStock:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加药品库存")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ClinicMedicineStock clinicMedicineStock) {
|
||||
// 记录当前登录用户id
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// clinicMedicineStock.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (clinicMedicineStockService.save(clinicMedicineStock)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineStock:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改药品库存")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ClinicMedicineStock clinicMedicineStock) {
|
||||
if (clinicMedicineStockService.updateById(clinicMedicineStock)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineStock:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除药品库存")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (clinicMedicineStockService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineStock:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加药品库存")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ClinicMedicineStock> list) {
|
||||
if (clinicMedicineStockService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineStock:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改药品库存")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ClinicMedicineStock> batchParam) {
|
||||
if (batchParam.update(clinicMedicineStockService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicMedicineStock:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除药品库存")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (clinicMedicineStockService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.gxwebsoft.clinic.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.clinic.service.ClinicPatientUserService;
|
||||
import com.gxwebsoft.clinic.entity.ClinicPatientUser;
|
||||
import com.gxwebsoft.clinic.param.ClinicPatientUserParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 患者控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-19 09:27:04
|
||||
*/
|
||||
@Tag(name = "患者管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/clinic/clinic-patient-user")
|
||||
public class ClinicPatientUserController extends BaseController {
|
||||
@Resource
|
||||
private ClinicPatientUserService clinicPatientUserService;
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPatientUser:list')")
|
||||
@Operation(summary = "分页查询患者")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ClinicPatientUser>> page(ClinicPatientUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicPatientUserService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPatientUser:list')")
|
||||
@Operation(summary = "查询全部患者")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ClinicPatientUser>> list(ClinicPatientUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicPatientUserService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPatientUser:list')")
|
||||
@Operation(summary = "根据id查询患者")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ClinicPatientUser> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(clinicPatientUserService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPatientUser:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加患者")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ClinicPatientUser clinicPatientUser) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
clinicPatientUser.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (clinicPatientUserService.save(clinicPatientUser)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPatientUser:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改患者")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ClinicPatientUser clinicPatientUser) {
|
||||
if (clinicPatientUserService.updateById(clinicPatientUser)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPatientUser:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除患者")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (clinicPatientUserService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPatientUser:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加患者")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ClinicPatientUser> list) {
|
||||
if (clinicPatientUserService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPatientUser:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改患者")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ClinicPatientUser> batchParam) {
|
||||
if (batchParam.update(clinicPatientUserService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPatientUser:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除患者")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (clinicPatientUserService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
package com.gxwebsoft.clinic.controller;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.gxwebsoft.clinic.dto.PrescriptionOrderRequest;
|
||||
import com.gxwebsoft.clinic.entity.ClinicPrescription;
|
||||
import com.gxwebsoft.clinic.param.ClinicPrescriptionParam;
|
||||
import com.gxwebsoft.clinic.service.ClinicPrescriptionService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 处方主表
|
||||
控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-22 02:01:13
|
||||
*/
|
||||
@Tag(name = "处方主表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/clinic/clinic-prescription")
|
||||
public class ClinicPrescriptionController extends BaseController {
|
||||
@Resource
|
||||
private ClinicPrescriptionService clinicPrescriptionService;
|
||||
|
||||
@Operation(summary = "分页查询处方主表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ClinicPrescription>> page(ClinicPrescriptionParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicPrescriptionService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:list')")
|
||||
@Operation(summary = "查询全部处方主表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ClinicPrescription>> list(ClinicPrescriptionParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicPrescriptionService.listRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据id查询处方主表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ClinicPrescription> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(clinicPrescriptionService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加处方主表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ClinicPrescription clinicPrescription) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
clinicPrescription.setDoctorId(loginUser.getUserId());
|
||||
// 生成订单号
|
||||
String orderNo = Long.toString(IdUtil.getSnowflakeNextId());
|
||||
clinicPrescription.setOrderNo(orderNo);
|
||||
}
|
||||
if (clinicPrescriptionService.save(clinicPrescription)) {
|
||||
// 返回处方数据,包含处方ID
|
||||
return success("添加成功",clinicPrescriptionService.getByLastId(clinicPrescription));
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改处方主表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ClinicPrescription clinicPrescription) {
|
||||
if (clinicPrescriptionService.updateById(clinicPrescription)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除处方主表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (clinicPrescriptionService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加处方主表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ClinicPrescription> list) {
|
||||
if (clinicPrescriptionService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改处方主表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ClinicPrescription> batchParam) {
|
||||
if (batchParam.update(clinicPrescriptionService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除处方主表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (clinicPrescriptionService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@Operation(summary = "创建处方订单")
|
||||
@PostMapping("/order")
|
||||
public ApiResult<?> createOrder(@RequestBody PrescriptionOrderRequest request) {
|
||||
try {
|
||||
// 1. 参数校验
|
||||
if (request.getPrescriptionId() == null) {
|
||||
return fail("处方ID不能为空");
|
||||
}
|
||||
if (request.getPayType() == null) {
|
||||
return fail("支付方式不能为空");
|
||||
}
|
||||
|
||||
// 2. 查询处方信息
|
||||
ClinicPrescription prescription = clinicPrescriptionService.getById(request.getPrescriptionId());
|
||||
if (prescription == null) {
|
||||
return fail("处方不存在");
|
||||
}
|
||||
|
||||
// 3. 检查处方状态
|
||||
if (prescription.getStatus() != null && prescription.getStatus() == 2) {
|
||||
return fail("该处方已支付,无需重复支付");
|
||||
}
|
||||
if (prescription.getStatus() != null && prescription.getStatus() == 3) {
|
||||
return fail("该处方已取消,无法支付");
|
||||
}
|
||||
|
||||
// 4. 更新处方订单信息
|
||||
ClinicPrescription updatePrescription = new ClinicPrescription();
|
||||
updatePrescription.setId(request.getPrescriptionId());
|
||||
|
||||
// 根据支付类型更新状态
|
||||
if (request.getPayType() == 1) {
|
||||
// 微信支付,状态保持为正常,等待支付回调
|
||||
updatePrescription.setStatus(0);
|
||||
} else if (request.getPayType() == 4 || request.getPayType() == 5) {
|
||||
// 现金支付或POS机支付,直接标记为已支付
|
||||
updatePrescription.setStatus(2);
|
||||
updatePrescription.setIsSettled(1);
|
||||
updatePrescription.setSettleTime(LocalDateTime.now());
|
||||
} else if (request.getPayType() == 6) {
|
||||
// 免费,直接标记为已完成
|
||||
updatePrescription.setStatus(1);
|
||||
updatePrescription.setIsSettled(1);
|
||||
updatePrescription.setSettleTime(LocalDateTime.now());
|
||||
}
|
||||
|
||||
if (clinicPrescriptionService.updateById(updatePrescription)) {
|
||||
return success("订单创建成功", prescription);
|
||||
}
|
||||
return fail("订单创建失败");
|
||||
|
||||
} catch (Exception e) {
|
||||
return fail("订单创建失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.gxwebsoft.clinic.controller;
|
||||
|
||||
import com.gxwebsoft.clinic.entity.ClinicPrescriptionItem;
|
||||
import com.gxwebsoft.clinic.param.ClinicPrescriptionItemParam;
|
||||
import com.gxwebsoft.clinic.service.ClinicPrescriptionItemService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 处方明细表
|
||||
控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-22 02:01:13
|
||||
*/
|
||||
@Tag(name = "处方明细表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/clinic/clinic-prescription-item")
|
||||
public class ClinicPrescriptionItemController extends BaseController {
|
||||
@Resource
|
||||
private ClinicPrescriptionItemService clinicPrescriptionItemService;
|
||||
|
||||
@Operation(summary = "分页查询处方明细表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ClinicPrescriptionItem>> page(ClinicPrescriptionItemParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicPrescriptionItemService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:list')")
|
||||
@Operation(summary = "查询全部处方明细表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ClinicPrescriptionItem>> list(ClinicPrescriptionItemParam param) {
|
||||
// 使用关联查询
|
||||
return success(clinicPrescriptionItemService.listRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据id查询处方明细表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ClinicPrescriptionItem> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(clinicPrescriptionItemService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加处方明细表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ClinicPrescriptionItem clinicPrescriptionItem) {
|
||||
if (clinicPrescriptionItemService.save(clinicPrescriptionItem)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改处方明细表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ClinicPrescriptionItem clinicPrescriptionItem) {
|
||||
if (clinicPrescriptionItemService.updateById(clinicPrescriptionItem)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除处方明细表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (clinicPrescriptionItemService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加处方明细表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ClinicPrescriptionItem> list) {
|
||||
if (clinicPrescriptionItemService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改处方明细表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ClinicPrescriptionItem> batchParam) {
|
||||
if (batchParam.update(clinicPrescriptionItemService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('clinic:clinicPrescription:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除处方明细表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (clinicPrescriptionItemService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user