Compare commits

...

2 Commits

Author SHA1 Message Date
7dede6f36f feat(app): 完善应用凭证、事件和用户管理功能
- 新增应用密钥凭证的创建、重置和状态管理功能
- 实现AppSecret自动生成功能并添加脱敏显示机制
- 增加应用操作动态的最新记录查询和批量清理功能
- 添加应用成员邀请和角色修改功能
- 优化查询条件支持精确匹配和租户隔离
- 集成网站信息关联查询并完善数据脱敏处理
2026-03-28 21:47:32 +08:00
35cc034af1 feat(generator): 添加代码生成工具及应用实体模块
- 新增 AppGenerator 代码生成工具类,支持多平台模板生成
- 生成 app_credential 应用密钥凭证的完整CRUD功能模块
- 生成 app_event 应用操作动态的完整CRUD功能模块
- 添加对应的 Entity、Controller、Service、Mapper 和 Param 类
- 配置多平台模板支持(Vue、UniApp、移动端页面)
- 实现 app.config.ts 自动更新功能
- 优化后端实现指南文档说明
2026-03-28 21:33:42 +08:00
31 changed files with 2644 additions and 1 deletions

View File

@@ -9,7 +9,8 @@
### 1. 修改 credit_mp_customer 表结构 ### 1. 修改 credit_mp_customer 表结构
```sql ```sql
-- 为第5-7步添加字段第1-4步字段已存在 -- 为第5-7步添加字段第1-4步基础字段已存在;如未包含审核时间/审核人字段,请先补齐 step1-4 的 approved_at/approved_by
-- 参考docs/sql/credit_mp_customer_step1_4_approval_columns.sql
-- 第5步合同签订 -- 第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 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_submitted_at VARCHAR(255) COMMENT '提交时间';

View File

@@ -0,0 +1,24 @@
-- 修复:审核接口(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';

View File

@@ -0,0 +1,151 @@
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("删除失败");
}
}

View File

@@ -0,0 +1,133 @@
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("删除失败");
}
}

View File

@@ -0,0 +1,158 @@
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("添加失败");
}
@PreAuthorize("hasAuthority('app:appUser:save')")
@OperationLog
@Operation(summary = "邀请用户成为应用成员")
@PostMapping("/invite")
public ApiResult<?> invite(@RequestBody AppUser appUser) {
User loginUser = getLoginUser();
if (loginUser == null) {
return fail("请先登录");
}
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("移除失败");
}
}

View File

@@ -0,0 +1,173 @@
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("删除失败");
}
}

View File

@@ -0,0 +1,80 @@
package com.gxwebsoft.app.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
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:43
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Schema(name = "AppCredential对象", description = "应用密钥凭证")
public class AppCredential 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 = "凭证名称,如生产环境密钥")
private String name;
@Schema(description = "App ID公开")
private String appId;
@Schema(description = "App Secret加密存储")
private String appSecret;
@Schema(description = "凭证类型: server/client/webhook")
private String type;
@Schema(description = "权限范围,空格分隔")
private String scopes;
@Schema(description = "到期时间NULL=永不过期")
private LocalDateTime expireTime;
@Schema(description = "最后使用时间")
private LocalDateTime lastUsedAt;
private String remark;
@Schema(description = "排序(数字越小越靠前)")
private Integer sortNumber;
@Schema(description = "状态, 0正常, 1冻结")
private Integer status;
@Schema(description = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@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;
}

View File

@@ -0,0 +1,76 @@
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 = "AppEvent对象", description = "应用操作动态")
public class AppEvent 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 = "事件类型: created/published/updated/domain_bound/member_added/status_changed")
private String eventType;
@Schema(description = "事件标题,如已发布")
private String title;
@Schema(description = "详细描述")
private String content;
@Schema(description = "操作人用户ID")
private Long operatorId;
@Schema(description = "操作人名称(冗余)")
private String operator;
@Schema(description = "关联ID如版本ID")
private Long refId;
@Schema(description = "关联类型")
private String refType;
@Schema(description = "扩展数据")
private String extra;
@Schema(description = "排序(数字越小越靠前)")
private Integer sortNumber;
@Schema(description = "状态, 0正常, 1冻结")
private Integer status;
@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;
}

View File

@@ -0,0 +1,67 @@
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 avatar;
@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;
}

View File

@@ -0,0 +1,85 @@
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;
}

View File

@@ -0,0 +1,37 @@
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);
}

View File

@@ -0,0 +1,37 @@
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);
}

View File

@@ -0,0 +1,37 @@
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);
}

View File

@@ -0,0 +1,37 @@
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);
}

View File

@@ -0,0 +1,71 @@
<?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.AppCredentialMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*, w.website_name, w.website_code, w.website_icon
FROM app_credential 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.name != null and param.name != ''">
AND a.name LIKE CONCAT('%', #{param.name}, '%')
</if>
<if test="param.appId != null and param.appId != ''">
AND a.app_id = #{param.appId}
</if>
<if test="param.type != null and param.type != ''">
AND a.type = #{param.type}
</if>
<if test="param.scopes != null and param.scopes != ''">
AND a.scopes LIKE CONCAT('%', #{param.scopes}, '%')
</if>
<if test="param.remark != null and param.remark != ''">
AND a.remark LIKE CONCAT('%', #{param.remark}, '%')
</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.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null and param.keywords != ''">
AND (a.name LIKE CONCAT('%', #{param.keywords}, '%')
OR a.app_id LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.app.entity.AppCredential">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.app.entity.AppCredential">
<include refid="selectSql"></include>
</select>
</mapper>

View File

@@ -0,0 +1,66 @@
<?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 &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{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>

View File

@@ -0,0 +1,65 @@
<?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 -->
<sql id="selectSql">
SELECT a.*, w.website_name, w.website_code, w.website_icon,
u.nickname, u.avatar AS user_avatar, u.phone
FROM app_user a
LEFT JOIN cms_website w ON a.website_id = w.website_id AND w.deleted = 0
LEFT JOIN sys_user u ON a.user_id = u.user_id
<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 u.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 &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null and param.keywords != ''">
AND (a.username LIKE CONCAT('%', #{param.keywords}, '%')
OR u.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>

View File

@@ -0,0 +1,66 @@
<?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 &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{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>

View File

@@ -0,0 +1,65 @@
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:43
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(name = "AppCredentialParam对象", description = "应用密钥凭证查询参数")
public class AppCredentialParam 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 = "凭证名称,如生产环境密钥")
private String name;
@Schema(description = "App ID公开")
@QueryField(type = QueryType.EQ)
private String appId;
@Schema(description = "凭证类型: server/client/webhook")
@QueryField(type = QueryType.EQ)
private String type;
@Schema(description = "权限范围,空格分隔")
private String scopes;
@Schema(description = "备注")
private String remark;
@Schema(description = "排序(数字越小越靠前)")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
@Schema(description = "状态, 0正常, 1冻结")
@QueryField(type = QueryType.EQ)
private Integer status;
@Schema(description = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
@Schema(description = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
}

View File

@@ -0,0 +1,63 @@
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;
}

View File

@@ -0,0 +1,59 @@
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 = "AppUserParam对象", description = "应用成员查询参数")
public class AppUserParam 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 = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
@Schema(description = "用户名(模糊搜索)")
private String username;
@Schema(description = "角色: owner/admin/developer/viewer")
@QueryField(type = QueryType.EQ)
private String role;
@Schema(description = "邀请人用户ID")
@QueryField(type = QueryType.EQ)
private Long inviteBy;
@Schema(description = "排序(数字越小越靠前)")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
@Schema(description = "状态, 0正常, 1冻结")
@QueryField(type = QueryType.EQ)
private Integer status;
@Schema(description = "租户ID")
@QueryField(type = QueryType.EQ)
private Integer tenantId;
}

View File

@@ -0,0 +1,63 @@
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;
}

View File

@@ -0,0 +1,57 @@
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);
}

View File

@@ -0,0 +1,60 @@
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);
}

View File

@@ -0,0 +1,60 @@
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);
}

View File

@@ -0,0 +1,56 @@
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);
}

View File

@@ -0,0 +1,125 @@
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) {
// 生成 AppIDapp_ + 16位随机字符串
String appId = "app_" + CommonUtil.randomUUID16();
// 生成 AppSecret32位随机字符串大小写字母+数字)
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())) + "**********************");
}
}
}

View File

@@ -0,0 +1,86 @@
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"));
}
}

View File

@@ -0,0 +1,89 @@
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 lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
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 {
@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("该用户已经是应用成员");
}
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);
save(appUser);
log.info("邀请成员成功websiteId={}, userId={}, role={}", websiteId, userId, 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;
}
}

View File

@@ -0,0 +1,112 @@
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"));
}
}

View File

@@ -0,0 +1,384 @@
package com.gxwebsoft.generator;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.gxwebsoft.generator.engine.BeetlTemplateEnginePlus;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* CMS模块-代码生成工具
*
* @author WebSoft
* @since 2021-09-05 00:31:14
*/
public class AppGenerator {
// 输出位置
private static final String OUTPUT_LOCATION = System.getProperty("user.dir");
//private static final String OUTPUT_LOCATION = "D:/codegen"; // 不想生成到项目中可以写磁盘路径
// JAVA输出目录
private static final String OUTPUT_DIR = "/src/main/java";
// Vue文件输出位置
private static final String OUTPUT_LOCATION_VUE = "/Users/gxwebsoft/VUE/mp-vue";
// UniApp文件输出目录
private static final String OUTPUT_LOCATION_UNIAPP = "/Users/gxwebsoft/VUE/template-5";
// Vue文件输出目录
private static final String OUTPUT_DIR_VUE = "/src";
// 作者名称
private static final String AUTHOR = "科技小王子";
// 是否在xml中添加二级缓存配置
private static final boolean ENABLE_CACHE = false;
// 数据库连接配置
private static final String DB_URL = "jdbc:mysql://47.119.165.234:13308/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
private static final String DB_USERNAME = "modules";
private static final String DB_PASSWORD = "P7KsAyDXG8YdLnkA";
// 包名
private static final String PACKAGE_NAME = "com.gxwebsoft";
// 模块名
private static final String MODULE_NAME = "app";
// 需要生成的表
private static final String[] TABLE_NAMES = new String[]{
"app_user",
"app_version",
"app_event",
"app_credential"
};
// 需要去除的表前缀
private static final String[] TABLE_PREFIX = new String[]{
"tb_"
};
// 不需要作为查询参数的字段
private static final String[] PARAM_EXCLUDE_FIELDS = new String[]{
"tenant_id",
"create_time",
"update_time"
};
// 查询参数使用String的类型
private static final String[] PARAM_TO_STRING_TYPE = new String[]{
"Date",
"LocalDate",
"LocalTime",
"LocalDateTime"
};
// 查询参数使用EQ的类型
private static final String[] PARAM_EQ_TYPE = new String[]{
"Integer",
"Boolean",
"BigDecimal"
};
// 是否添加权限注解
private static final boolean AUTH_ANNOTATION = true;
// 是否添加日志注解
private static final boolean LOG_ANNOTATION = true;
// controller的mapping前缀
private static final String CONTROLLER_MAPPING_PREFIX = "/api";
// 模板所在位置
private static final String TEMPLATES_DIR = "/src/test/java/com/gxwebsoft/generator/templates";
public static void main(String[] args) {
// 代码生成器
AutoGenerator mpg = new AutoGenerator();
// 全局配置
GlobalConfig gc = new GlobalConfig();
gc.setOutputDir(OUTPUT_LOCATION + OUTPUT_DIR);
gc.setAuthor(AUTHOR);
gc.setOpen(false);
gc.setFileOverride(true);
gc.setEnableCache(ENABLE_CACHE);
gc.setSwagger2(true);
gc.setIdType(IdType.AUTO);
gc.setServiceName("%sService");
mpg.setGlobalConfig(gc);
// 数据源配置
DataSourceConfig dsc = new DataSourceConfig();
dsc.setUrl(DB_URL);
// dsc.setSchemaName("public");
dsc.setDriverName(DB_DRIVER);
dsc.setUsername(DB_USERNAME);
dsc.setPassword(DB_PASSWORD);
mpg.setDataSource(dsc);
// 包配置
PackageConfig pc = new PackageConfig();
pc.setModuleName(MODULE_NAME);
pc.setParent(PACKAGE_NAME);
mpg.setPackageInfo(pc);
// 策略配置
StrategyConfig strategy = new StrategyConfig();
strategy.setNaming(NamingStrategy.underline_to_camel);
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
strategy.setInclude(TABLE_NAMES);
strategy.setTablePrefix(TABLE_PREFIX);
strategy.setSuperControllerClass(PACKAGE_NAME + ".common.core.web.BaseController");
strategy.setEntityLombokModel(true);
strategy.setRestControllerStyle(true);
strategy.setControllerMappingHyphenStyle(true);
strategy.setLogicDeleteFieldName("deleted");
mpg.setStrategy(strategy);
// 模板配置
TemplateConfig templateConfig = new TemplateConfig();
templateConfig.setController(TEMPLATES_DIR + "/controller.java");
templateConfig.setEntity(TEMPLATES_DIR + "/entity.java");
templateConfig.setMapper(TEMPLATES_DIR + "/mapper.java");
templateConfig.setXml(TEMPLATES_DIR + "/mapper.xml");
templateConfig.setService(TEMPLATES_DIR + "/service.java");
templateConfig.setServiceImpl(TEMPLATES_DIR + "/serviceImpl.java");
mpg.setTemplate(templateConfig);
mpg.setTemplateEngine(new BeetlTemplateEnginePlus());
// 自定义模板配置
InjectionConfig cfg = new InjectionConfig() {
@Override
public void initMap() {
Map<String, Object> map = new HashMap<>();
map.put("packageName", PACKAGE_NAME);
map.put("paramExcludeFields", PARAM_EXCLUDE_FIELDS);
map.put("paramToStringType", PARAM_TO_STRING_TYPE);
map.put("paramEqType", PARAM_EQ_TYPE);
map.put("authAnnotation", AUTH_ANNOTATION);
map.put("logAnnotation", LOG_ANNOTATION);
map.put("controllerMappingPrefix", CONTROLLER_MAPPING_PREFIX);
// 添加项目类型标识,用于模板中的条件判断
map.put("isUniApp", false); // Vue 项目
map.put("isVueAdmin", true); // 后台管理项目
this.setMap(map);
}
};
String templatePath = TEMPLATES_DIR + "/param.java.btl";
List<FileOutConfig> focList = new ArrayList<>();
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION + OUTPUT_DIR + "/"
+ PACKAGE_NAME.replace(".", "/")
+ "/" + pc.getModuleName() + "/param/"
+ tableInfo.getEntityName() + "Param" + StringPool.DOT_JAVA;
}
});
/**
* 以下是生成VUE项目代码
* 生成文件的路径 /api/shop/goods/index.ts
*/
templatePath = TEMPLATES_DIR + "/index.ts.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
+ "/api/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "index.ts";
}
});
// UniApp 使用专门的模板
String uniappTemplatePath = TEMPLATES_DIR + "/index.ts.uniapp.btl";
focList.add(new FileOutConfig(uniappTemplatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
+ "/api/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "index.ts";
}
});
// 生成TS文件 (/api/shop/goods/model/index.ts)
templatePath = TEMPLATES_DIR + "/model.ts.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
+ "/api/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/model/" + "index.ts";
}
});
// UniApp 使用专门的 model 模板
String uniappModelTemplatePath = TEMPLATES_DIR + "/model.ts.uniapp.btl";
focList.add(new FileOutConfig(uniappModelTemplatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
+ "/api/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/model/" + "index.ts";
}
});
// 生成Vue文件(/views/shop/goods/index.vue)
templatePath = TEMPLATES_DIR + "/index.vue.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
+ "/views/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "index.vue";
}
});
// 生成components文件(/views/shop/goods/components/edit.vue)
templatePath = TEMPLATES_DIR + "/components.edit.vue.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
+ "/views/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/components/" + tableInfo.getEntityPath() + "Edit.vue";
}
});
// 生成components文件(/views/shop/goods/components/search.vue)
templatePath = TEMPLATES_DIR + "/components.search.vue.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
+ "/views/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/components/" + "search.vue";
}
});
// ========== 移动端页面文件生成 ==========
// 生成移动端列表页面配置文件 (/src/shop/goods/index.config.ts)
templatePath = TEMPLATES_DIR + "/index.config.ts.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
+ "/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "index.config.ts";
}
});
// 生成移动端列表页面组件文件 (/src/shop/goods/index.tsx)
templatePath = TEMPLATES_DIR + "/index.tsx.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
+ "/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "index.tsx";
}
});
// 生成移动端新增/编辑页面配置文件 (/src/shop/goods/add.config.ts)
templatePath = TEMPLATES_DIR + "/add.config.ts.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
+ "/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "add.config.ts";
}
});
// 生成移动端新增/编辑页面组件文件 (/src/shop/goods/add.tsx)
templatePath = TEMPLATES_DIR + "/add.tsx.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
+ "/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "add.tsx";
}
});
cfg.setFileOutConfigList(focList);
mpg.setCfg(cfg);
mpg.execute();
// 自动更新 app.config.ts
updateAppConfig(TABLE_NAMES, MODULE_NAME);
}
/**
* 自动更新 app.config.ts 文件,添加新生成的页面路径
*/
private static void updateAppConfig(String[] tableNames, String moduleName) {
String appConfigPath = OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE + "/app.config.ts";
try {
// 读取原文件内容
String content = new String(Files.readAllBytes(Paths.get(appConfigPath)));
// 为每个表生成页面路径
StringBuilder newPages = new StringBuilder();
for (String tableName : tableNames) {
String entityPath = tableName.replaceAll("_", "");
// 转换为驼峰命名
String[] parts = tableName.split("_");
StringBuilder camelCase = new StringBuilder(parts[0]);
for (int i = 1; i < parts.length; i++) {
camelCase.append(parts[i].substring(0, 1).toUpperCase()).append(parts[i].substring(1));
}
entityPath = camelCase.toString();
newPages.append(" '").append(entityPath).append("/index',\n");
newPages.append(" '").append(entityPath).append("/add',\n");
}
// 查找对应模块的子包配置
String modulePattern = "\"root\":\\s*\"" + moduleName + "\",\\s*\"pages\":\\s*\\[([^\\]]*)]";
Pattern pattern = Pattern.compile(modulePattern, Pattern.DOTALL);
Matcher matcher = pattern.matcher(content);
if (matcher.find()) {
String existingPages = matcher.group(1);
// 检查页面是否已存在,避免重复添加
boolean needUpdate = false;
String[] newPageArray = newPages.toString().split("\n");
for (String newPage : newPageArray) {
if (!newPage.trim().isEmpty() && !existingPages.contains(newPage.trim().replace(" ", "").replace(",", ""))) {
needUpdate = true;
break;
}
}
if (needUpdate) {
// 备份原文件
String backupPath = appConfigPath + ".backup." + System.currentTimeMillis();
Files.copy(Paths.get(appConfigPath), Paths.get(backupPath));
System.out.println("已备份原文件到: " + backupPath);
// 在现有页面列表末尾添加新页面
String updatedPages = existingPages.trim();
if (!updatedPages.endsWith(",")) {
updatedPages += ",";
}
updatedPages += "\n" + newPages.toString().trim();
// 替换内容
String updatedContent = content.replace(matcher.group(1), updatedPages);
// 写入更新后的内容
Files.write(Paths.get(appConfigPath), updatedContent.getBytes());
System.out.println("✅ 已自动更新 app.config.ts添加了以下页面路径:");
System.out.println(newPages.toString());
} else {
System.out.println(" app.config.ts 中已包含所有页面路径,无需更新");
}
} else {
System.out.println("⚠️ 未找到 " + moduleName + " 模块的子包配置,请手动添加页面路径");
}
} catch (Exception e) {
System.err.println("❌ 更新 app.config.ts 失败: " + e.getMessage());
e.printStackTrace();
}
}
}