Browse Source

refactor(cms): 重构网站信息获取接口

- 移除 CmsMainController 中的 getSiteInfo 方法
- 新增 ShopMainController 控制器用于获取商城信息
- 重构 CmsWebsiteController 中的 getSiteInfo 方法,使用 Redis 缓存
- 更新 CmsWebsiteService 接口和实现类,返回 ShopVo 对象- 删除 TestController 和 WechatCertTestController
- 更新 SecurityConfig 中的放行接口列表
main
科技小王子 2 weeks ago
parent
commit
a5eed3e2bb
  1. 21
      src/main/java/com/gxwebsoft/cms/controller/CmsMainController.java
  2. 230
      src/main/java/com/gxwebsoft/cms/controller/CmsWebsiteController.java
  3. 3
      src/main/java/com/gxwebsoft/cms/service/CmsWebsiteService.java
  4. 3
      src/main/java/com/gxwebsoft/cms/service/impl/CmsWebsiteServiceImpl.java
  5. 35
      src/main/java/com/gxwebsoft/common/core/controller/TestController.java
  6. 211
      src/main/java/com/gxwebsoft/common/core/controller/WechatCertTestController.java
  7. 4
      src/main/java/com/gxwebsoft/common/core/security/SecurityConfig.java
  8. 39
      src/main/java/com/gxwebsoft/common/task/AddUserTaskController.java
  9. 54
      src/main/java/com/gxwebsoft/shop/controller/ShopMainController.java
  10. 1
      src/main/java/com/gxwebsoft/shop/controller/ShopUserCouponController.java
  11. 55
      src/main/java/com/gxwebsoft/shop/vo/MenuVo.java
  12. 92
      src/main/java/com/gxwebsoft/shop/vo/ShopVo.java

21
src/main/java/com/gxwebsoft/cms/controller/CmsMainController.java

@ -26,25 +26,4 @@ public class CmsMainController extends BaseController {
@Resource
private CmsWebsiteService cmsWebsiteService;
@Operation(summary = "网站基本信息", description = "获取网站的基本信息,包括配置、导航、设置和过期状态等")
@GetMapping("/getSiteInfo")
public ApiResult<CmsVO> getSiteInfo() {
try {
Integer tenantId = getTenantId();
if (ObjectUtil.isEmpty(tenantId)) {
return fail("租户ID不能为空", null);
}
CmsVO websiteVO = cmsWebsiteService.getSiteInfo(tenantId);
return success(websiteVO);
} catch (IllegalArgumentException e) {
return fail(e.getMessage(), null);
} catch (RuntimeException e) {
return fail(e.getMessage(), null);
} catch (Exception e) {
log.error("获取网站信息失败", e);
return fail("获取网站信息失败", null);
}
}
}

230
src/main/java/com/gxwebsoft/cms/controller/CmsWebsiteController.java

@ -1,40 +1,60 @@
package com.gxwebsoft.cms.controller;
import cn.hutool.core.util.ObjectUtil;
import com.gxwebsoft.cms.entity.CmsWebsite;
import com.gxwebsoft.cms.param.CmsWebsiteParam;
import com.gxwebsoft.cms.service.CmsWebsiteService;
import com.gxwebsoft.cms.vo.CmsVO;
import com.gxwebsoft.common.core.utils.RedisUtil;
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.util.List;
/**
package com.gxwebsoft.cms.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gxwebsoft.cms.entity.CmsNavigation;
import com.gxwebsoft.cms.entity.CmsWebsite;
import com.gxwebsoft.cms.entity.CmsWebsiteField;
import com.gxwebsoft.cms.entity.CmsWebsiteSetting;
import com.gxwebsoft.cms.param.CmsNavigationParam;
import com.gxwebsoft.cms.param.CmsWebsiteParam;
import com.gxwebsoft.cms.service.CmsNavigationService;
import com.gxwebsoft.cms.service.CmsWebsiteFieldService;
import com.gxwebsoft.cms.service.CmsWebsiteService;
import com.gxwebsoft.cms.service.CmsWebsiteSettingService;
import com.gxwebsoft.cms.vo.CmsVO;
import com.gxwebsoft.common.core.utils.CommonUtil;
import com.gxwebsoft.common.core.utils.RedisUtil;
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.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* 网站信息记录表控制器
*
* @author 科技小王子
* @since 2024-09-10 20:36:14
*/
@Slf4j
@Tag(name = "网站信息记录表管理")
@RestController
@RequestMapping("/api/cms/cms-website")
public class CmsWebsiteController extends BaseController {
@Slf4j
@Tag(name = "网站信息记录表管理")
@RestController
@RequestMapping("/api/cms/cms-website")
public class CmsWebsiteController extends BaseController {
@Resource
private CmsWebsiteService cmsWebsiteService;
@Resource
private RedisUtil redisUtil;
@Resource
private CmsNavigationService cmsNavigationService;
@Resource
private CmsWebsiteSettingService cmsWebsiteSettingService;
@Resource
private CmsWebsiteFieldService cmsWebsiteFieldService;
private static final String SITE_INFO_KEY_PREFIX = "SiteInfo:";
private static final String MP_INFO_KEY_PREFIX = "MpInfo:";
@ -159,28 +179,150 @@ public class CmsWebsiteController extends BaseController {
return fail("删除失败");
}
@Operation(summary = "网站基本信息", description = "获取网站的基本信息,包括配置、导航、设置和过期状态等")
@Operation(summary = "网站基本信息")
@GetMapping("/getSiteInfo")
public ApiResult<CmsVO> getSiteInfo() {
try {
Integer tenantId = getTenantId();
if (ObjectUtil.isEmpty(tenantId)) {
return fail("租户ID不能为空", null);
public ApiResult<CmsWebsite> getSiteInfo() {
if (ObjectUtil.isEmpty(getTenantId())) {
return fail("参数不正确", null);
}
String key = SITE_INFO_KEY_PREFIX + getTenantId();
final String siteInfo = redisUtil.get(key);
if (StrUtil.isNotBlank(siteInfo)) {
log.info("从缓存获取网站信息: = {}", key);
// return success(JSONUtil.parseObject(siteInfo, CmsWebsite.class));
}
// 获取站点信息
CmsWebsite website = cmsWebsiteService.getOne(new LambdaQueryWrapper<CmsWebsite>().eq(CmsWebsite::getDeleted, 0).last("limit 1"));
// 创建默认站点
if (ObjectUtil.isEmpty(website)) {
return success("请先创建站点...", null);
}
// 站点异常状态
setWebsiteStatus(website);
// 站点配置参数
HashMap<String, Object> config = buildWebsiteConfig(website);
website.setConfig(config);
// 网站导航
setWebsiteNavigation(website);
// 网站设置信息
setWebsiteSetting(website);
// 服务器时间
HashMap<String, Object> serverTime = buildServerTime();
website.setServerTime(serverTime);
// 即将过期(一周内过期的)
website.setSoon(DateUtil.offsetDay(website.getExpirationTime(), -30).compareTo(DateUtil.date()));
// 是否过期 -1已过期 大于0 未过期
website.setExpired(website.getExpirationTime().compareTo(DateUtil.date()));
// 剩余天数
website.setExpiredDays(DateUtil.betweenDay(website.getExpirationTime(), DateUtil.date(), false));
redisUtil.set(key, website, 1L, TimeUnit.DAYS);
return success(website);
}
private void setWebsiteStatus(CmsWebsite website) {
if (!website.getRunning().equals(1)) {
// 未开通
if (website.getRunning().equals(0)) {
website.setStatusIcon("error");
website.setStatusText("该站点未开通");
}
// 维护中
if (website.getRunning().equals(2)) {
website.setStatusIcon("warning");
}
// 已关闭
if (website.getRunning().equals(3)) {
website.setStatusIcon("error");
website.setStatusText("已关闭");
}
// 已欠费停机
if (website.getRunning().equals(4)) {
website.setStatusIcon("error");
website.setStatusText("已欠费停机");
}
// 违规关停
if (website.getRunning().equals(5)) {
website.setStatusIcon("error");
website.setStatusText("违规关停");
}
}
}
CmsVO websiteVO = cmsWebsiteService.getSiteInfo(tenantId);
private HashMap<String, Object> buildWebsiteConfig(CmsWebsite website) {
HashMap<String, Object> config = new HashMap<>();
LambdaQueryWrapper<CmsWebsiteField> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CmsWebsiteField::getDeleted, 0);
final List<CmsWebsiteField> fields = cmsWebsiteFieldService.list(wrapper);
fields.forEach(d -> {
config.put(d.getName(), d.getValue());
});
config.put("SysDomain", getSysDomain(website));
config.put("Domain", getDomain(website));
return config;
}
return success(websiteVO);
} catch (IllegalArgumentException e) {
return fail(e.getMessage(), null);
} catch (RuntimeException e) {
return fail(e.getMessage(), null);
} catch (Exception e) {
log.error("获取网站信息失败", e);
return fail("获取网站信息失败", null);
private String getSysDomain(CmsWebsite website) {
return StrUtil.isNotBlank(website.getWebsiteCode()) ? website.getWebsiteCode() + SYS_DOMAIN_SUFFIX : website.getTenantId() + SYS_DOMAIN_SUFFIX;
}
private String getDomain(CmsWebsite website) {
return StrUtil.isNotBlank(website.getDomain()) ? website.getDomain() : website.getWebsiteCode() + DOMAIN_SUFFIX;
}
private void setWebsiteNavigation(CmsWebsite website) {
final CmsNavigationParam navigationParam = new CmsNavigationParam();
navigationParam.setHide(0);
navigationParam.setTop(0);
navigationParam.setBottom(null);
final List<CmsNavigation> topNavs = cmsNavigationService.listRel(navigationParam);
// 顶部菜单
website.setTopNavs(CommonUtil.toTreeData(topNavs, 0, CmsNavigation::getParentId, CmsNavigation::getNavigationId, CmsNavigation::setChildren));
navigationParam.setTop(null);
navigationParam.setBottom(0);
final List<CmsNavigation> bottomNavs = cmsNavigationService.listRel(navigationParam);
// 底部菜单
website.setBottomNavs(CommonUtil.toTreeData(bottomNavs, 0, CmsNavigation::getParentId, CmsNavigation::getNavigationId, CmsNavigation::setChildren));
}
private void setWebsiteSetting(CmsWebsite website) {
final CmsWebsiteSetting setting = cmsWebsiteSettingService.getOne(new LambdaQueryWrapper<CmsWebsiteSetting>().eq(CmsWebsiteSetting::getWebsiteId, website.getWebsiteId()));
if (ObjectUtil.isNotEmpty(setting)) {
website.setSetting(setting);
}
}
private HashMap<String, Object> buildServerTime() {
HashMap<String, Object> serverTime = new HashMap<>();
// 今天日期
DateTime date = DateUtil.date();
String today = DateUtil.today();
// 明天日期
final DateTime dateTime = DateUtil.tomorrow();
String tomorrow = DateUtil.format(dateTime, "yyyy-MM-dd");
// 后天日期
final DateTime dateTime2 = DateUtil.offsetDay(date, 2);
final String afterDay = DateUtil.format(dateTime2, "yyyy-MM-dd");
// 今天星期几
final int week = DateUtil.thisDayOfWeek();
final DateTime nextWeek = DateUtil.nextWeek();
serverTime.put("now", DateUtil.now());
serverTime.put("today", today);
serverTime.put("tomorrow", tomorrow);
serverTime.put("afterDay", afterDay);
serverTime.put("week", week);
serverTime.put("nextWeek", nextWeek);
return serverTime;
}
@Operation(summary = "清除缓存")
@DeleteMapping("/clearSiteInfo/{key}")
@ -196,4 +338,4 @@ public class CmsWebsiteController extends BaseController {
return success("清除成功");
}
}
}

3
src/main/java/com/gxwebsoft/cms/service/CmsWebsiteService.java

@ -5,6 +5,7 @@ import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.cms.entity.CmsWebsite;
import com.gxwebsoft.cms.param.CmsWebsiteParam;
import com.gxwebsoft.cms.vo.CmsVO;
import com.gxwebsoft.shop.vo.ShopVo;
import java.util.List;
@ -59,7 +60,7 @@ public interface CmsWebsiteService extends IService<CmsWebsite> {
* @param tenantId 租户ID
* @return 网站信息VO
*/
CmsVO getSiteInfo(Integer tenantId);
ShopVo getSiteInfo(Integer tenantId);
/**
* 清除网站信息缓存

3
src/main/java/com/gxwebsoft/cms/service/impl/CmsWebsiteServiceImpl.java

@ -15,6 +15,7 @@ import com.gxwebsoft.common.system.service.CompanyService;
import com.gxwebsoft.common.system.service.UserService;
import com.gxwebsoft.project.entity.Project;
import com.gxwebsoft.project.service.ProjectService;
import com.gxwebsoft.shop.vo.ShopVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -313,7 +314,7 @@ public class CmsWebsiteServiceImpl extends ServiceImpl<CmsWebsiteMapper, CmsWebs
}
@Override
public CmsVO getSiteInfo(Integer tenantId) {
public ShopVo getSiteInfo(Integer tenantId) {
// 参数验证
if (ObjectUtil.isEmpty(tenantId)) {
throw new IllegalArgumentException("租户ID不能为空");

35
src/main/java/com/gxwebsoft/common/core/controller/TestController.java

@ -1,35 +0,0 @@
package com.gxwebsoft.common.core.controller;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
/**
* 测试控制器
* 用于测试LocalDateTime序列化
*
* @author WebSoft
* @since 2025-01-12
*/
@Tag(name = "测试接口")
@RestController
@RequestMapping("/api/test")
public class TestController extends BaseController {
@Operation(summary = "测试LocalDateTime序列化")
@GetMapping("/datetime")
public ApiResult<Map<String, Object>> testDateTime() {
Map<String, Object> result = new HashMap<>();
result.put("currentTime", LocalDateTime.now());
result.put("message", "LocalDateTime序列化测试");
return success(result);
}
}

211
src/main/java/com/gxwebsoft/common/core/controller/WechatCertTestController.java

@ -1,211 +0,0 @@
package com.gxwebsoft.common.core.controller;
import com.gxwebsoft.common.core.utils.WechatCertAutoConfig;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.wechat.pay.java.core.Config;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
/**
* 微信支付证书自动配置测试控制器
*
* @author 科技小王子
* @since 2024-07-26
*/
@Slf4j
@RestController
@RequestMapping("/api/wechat-cert-test")
@Tag(name = "微信支付证书自动配置测试")
public class WechatCertTestController extends BaseController {
@Autowired
private WechatCertAutoConfig wechatCertAutoConfig;
@Operation(summary = "测试默认开发环境证书配置")
@PostMapping("/test-default")
public ApiResult<Map<String, Object>> testDefaultConfig() {
Map<String, Object> result = new HashMap<>();
try {
log.info("开始测试默认开发环境证书配置...");
// 创建自动证书配置
Config config = wechatCertAutoConfig.createDefaultDevConfig();
// 测试配置
boolean testResult = wechatCertAutoConfig.testConfig(config);
result.put("success", true);
result.put("configCreated", config != null);
result.put("testPassed", testResult);
result.put("message", "默认证书配置测试完成");
result.put("instructions", wechatCertAutoConfig.getUsageInstructions());
log.info("✅ 默认证书配置测试成功");
return success("测试成功", result);
} catch (Exception e) {
log.error("❌ 默认证书配置测试失败: {}", e.getMessage(), e);
result.put("success", false);
result.put("error", e.getMessage());
result.put("message", "证书配置测试失败");
result.put("troubleshooting", getTroubleshootingInfo());
return fail("测试失败: " + e.getMessage(), result);
}
}
@Operation(summary = "测试自定义证书配置")
@PostMapping("/test-custom")
public ApiResult<Map<String, Object>> testCustomConfig(
@Parameter(description = "商户号") @RequestParam String merchantId,
@Parameter(description = "私钥文件路径") @RequestParam String privateKeyPath,
@Parameter(description = "证书序列号") @RequestParam String merchantSerialNumber,
@Parameter(description = "APIv3密钥") @RequestParam String apiV3Key) {
Map<String, Object> result = new HashMap<>();
try {
log.info("开始测试自定义证书配置...");
log.info("商户号: {}", merchantId);
log.info("私钥路径: {}", privateKeyPath);
// 创建自动证书配置
Config config = wechatCertAutoConfig.createAutoConfig(
merchantId, privateKeyPath, merchantSerialNumber, apiV3Key);
// 测试配置
boolean testResult = wechatCertAutoConfig.testConfig(config);
result.put("success", true);
result.put("configCreated", config != null);
result.put("testPassed", testResult);
result.put("message", "自定义证书配置测试完成");
result.put("merchantId", merchantId);
result.put("privateKeyPath", privateKeyPath);
log.info("✅ 自定义证书配置测试成功");
return success("测试成功", result);
} catch (Exception e) {
log.error("❌ 自定义证书配置测试失败: {}", e.getMessage(), e);
result.put("success", false);
result.put("error", e.getMessage());
result.put("message", "证书配置测试失败");
result.put("troubleshooting", getTroubleshootingInfo());
return fail("测试失败: " + e.getMessage(), result);
}
}
@Operation(summary = "获取使用说明")
@GetMapping("/instructions")
public ApiResult<String> getInstructions() {
String instructions = wechatCertAutoConfig.getUsageInstructions();
return success("获取使用说明成功", instructions);
}
@Operation(summary = "获取故障排除信息")
@GetMapping("/troubleshooting")
public ApiResult<Map<String, Object>> getTroubleshooting() {
Map<String, Object> troubleshooting = getTroubleshootingInfo();
return success("获取故障排除信息成功", troubleshooting);
}
/**
* 获取故障排除信息
*/
private Map<String, Object> getTroubleshootingInfo() {
Map<String, Object> info = new HashMap<>();
info.put("commonIssues", Map.of(
"404错误", "商户平台未开启API安全功能或未申请使用微信支付公钥",
"证书序列号错误", "请检查商户平台中的证书序列号是否正确",
"APIv3密钥错误", "请确认APIv3密钥是否正确设置",
"私钥文件不存在", "请检查私钥文件路径是否正确",
"网络连接问题", "请检查网络连接是否正常"
));
info.put("solutions", Map.of(
"开启API安全", "登录微信商户平台 -> 账户中心 -> API安全 -> 申请使用微信支付公钥",
"获取证书序列号", "在API安全页面查看或重新下载证书",
"设置APIv3密钥", "在API安全页面设置APIv3密钥",
"检查私钥文件", "确保apiclient_key.pem文件存在且路径正确"
));
info.put("advantages", Map.of(
"自动下载", "RSAAutoCertificateConfig会自动下载平台证书",
"自动更新", "证书过期时会自动更新",
"简化管理", "无需手动管理wechatpay_cert.pem文件",
"官方推荐", "微信支付官方推荐的证书管理方式"
));
info.put("documentation", "https://pay.weixin.qq.com/doc/v3/merchant/4012153196");
return info;
}
@Operation(summary = "检查商户平台配置状态")
@PostMapping("/check-merchant-config")
public ApiResult<Map<String, Object>> checkMerchantConfig(
@RequestParam String merchantId,
@RequestParam String privateKeyPath,
@RequestParam String merchantSerialNumber,
@RequestParam String apiV3Key) {
Map<String, Object> result = new HashMap<>();
try {
log.info("开始检查商户平台配置状态...");
log.info("商户号: {}", merchantId);
// 尝试创建自动证书配置
Config config = wechatCertAutoConfig.createAutoConfig(
merchantId, privateKeyPath, merchantSerialNumber, apiV3Key);
result.put("success", true);
result.put("configCreated", true);
result.put("message", "商户平台配置正常,自动证书配置创建成功");
result.put("merchantId", merchantId);
result.put("recommendation", "配置正常,可以正常使用微信支付功能");
log.info("✅ 商户平台配置检查成功");
return success("配置检查成功", result);
} catch (Exception e) {
log.error("❌ 商户平台配置检查失败: {}", e.getMessage(), e);
result.put("success", false);
result.put("configCreated", false);
result.put("error", e.getMessage());
result.put("merchantId", merchantId);
// 分析错误类型并提供解决方案
if (e.getMessage().contains("404") || e.getMessage().contains("RESOURCE_NOT_EXISTS")) {
result.put("errorType", "商户平台配置问题");
result.put("solution", "请在微信支付商户平台完成以下配置:\n" +
"1. 登录商户平台:https://pay.weixin.qq.com/\n" +
"2. 进入:产品中心 → 开发配置 → API安全\n" +
"3. 申请API证书\n" +
"4. 申请使用微信支付公钥\n" +
"5. 确保API证书和微信支付公钥状态为\"已生效\"");
result.put("documentUrl", "https://pay.weixin.qq.com/doc/v3/merchant/4012153196");
} else {
result.put("errorType", "其他配置问题");
result.put("solution", "请检查商户号、证书序列号、API密钥等配置是否正确");
}
return success("配置检查完成(发现问题)", result);
}
}
}

4
src/main/java/com/gxwebsoft/common/core/security/SecurityConfig.java

@ -74,8 +74,8 @@ public class SecurityConfig {
"/api/shop/merchant-account/getMerchantAccountByPhone",
"/api/hjm/hjm-car/**",
"/api/chat/**",
"/api/shop/shop-order/test",
"/api/cms/getSiteInfo"
"/api/shop/getShopInfo",
"/api/shop/shop-order/test"
)
.permitAll()
.anyRequest()

39
src/main/java/com/gxwebsoft/common/task/AddUserTaskController.java

@ -1,39 +0,0 @@
package com.gxwebsoft.common.task;
import com.gxwebsoft.common.core.utils.RequestUtil;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.service.UserRoleService;
import com.gxwebsoft.common.system.service.UserService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* 定时任务
*
* @author 科技小王子
* @since 2022-12-15 19:11:07
*/
@Tag(name = "定时任务")
@RestController
@RequestMapping("/api/love/scheduling")
public class AddUserTaskController extends BaseController {
@Resource
private RequestUtil requestUtil;
@Resource
private UserRoleService userRoleService;
/**
* 模拟注册用户
* @Scheduled(fixedDelay = 1000, initialDelay = 1000)
*/
@Scheduled(fixedDelay = 1000, initialDelay = 1000)
public void addUserProfile() {
// final User userId = requestUtil.getCoreUserInfoByUserId(27344);
}
}

54
src/main/java/com/gxwebsoft/shop/controller/ShopMainController.java

@ -0,0 +1,54 @@
package com.gxwebsoft.shop.controller;
import cn.hutool.core.util.ObjectUtil;
import com.gxwebsoft.cms.service.CmsWebsiteService;
import com.gxwebsoft.cms.vo.CmsVO;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.shop.vo.ShopVo;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* 商城主入口
*
* @author 科技小王子
* @since 2024-09-10 20:36:14
*/
@Slf4j
@Tag(name = "商城")
@RestController
@RequestMapping("/api/shop")
public class ShopMainController extends BaseController {
@Resource
private CmsWebsiteService cmsWebsiteService;
@Operation(summary = "商城基本信息", description = "获取商城的基本信息,包括配置、导航、设置和过期状态等")
@GetMapping("/getShopInfo")
public ApiResult<ShopVo> getSiteInfo() {
Integer tenantId = getTenantId();
if (ObjectUtil.isEmpty(tenantId)) {
return fail("租户ID不能为空", null);
}
try {
ShopVo vo = cmsWebsiteService.getSiteInfo(tenantId);
return success(vo);
} catch (IllegalArgumentException e) {
return fail(e.getMessage(), null);
} catch (RuntimeException e) {
return fail(e.getMessage(), null);
} catch (Exception e) {
log.error("获取商城信息失败", e);
return fail("获取商城信息失败", null);
}
}
}

1
src/main/java/com/gxwebsoft/shop/controller/ShopUserCouponController.java

@ -122,7 +122,6 @@ public class ShopUserCouponController extends BaseController {
return success("领取成功");
}
@PreAuthorize("hasAuthority('shop:shopUserCoupon:list')")
@Operation(summary = "分页查询用户优惠券")
@GetMapping("/page")
public ApiResult<PageResult<ShopUserCoupon>> page(ShopUserCouponParam param) {

55
src/main/java/com/gxwebsoft/shop/vo/MenuVo.java

@ -0,0 +1,55 @@
package com.gxwebsoft.shop.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 导航信息视图对象
* 专门用于前端展示只包含前端需要的字段
*
* @author WebSoft
* @since 2025-01-12
*/
@Data
@Schema(description = "导航信息视图对象")
public class MenuVo implements Serializable {
@Schema(description = "导航ID")
private Integer navigationId;
@Schema(description = "导航名称")
private String navigationName;
@Schema(description = "导航链接")
private String navigationUrl;
@Schema(description = "导航图标")
private String navigationIcon;
@Schema(description = "导航颜色")
private String navigationColor;
@Schema(description = "父级ID")
private Integer parentId;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "是否隐藏 0显示 1隐藏")
private Integer hide;
@Schema(description = "位置 0顶部 1底部")
private Integer top;
@Schema(description = "打开方式 0当前窗口 1新窗口")
private Integer target;
@Schema(description = "导航类型")
private String navigationType;
@Schema(description = "子导航")
private List<MenuVo> children;
}

92
src/main/java/com/gxwebsoft/shop/vo/ShopVo.java

@ -0,0 +1,92 @@
package com.gxwebsoft.shop.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
/**
* 应用信息
* 专门用于前端展示只包含前端需要的字段
*
* @author WebSoft
* @since 2025-01-12
*/
@Data
@Schema(description = "应用信息视图对象")
public class ShopVo implements Serializable {
@Schema(description = "应用ID")
private Integer appId;
@Schema(description = "应用名称")
private String appName;
@Schema(description = "应用介绍")
private String description;
@Schema(description = "网站关键词")
private String keywords;
@Schema(description = "应用编号")
private String appCode;
@Schema(description = "小程序二维码")
private String mpQrCode;
@Schema(description = "标题")
private String title;
@Schema(description = "LOGO")
private String logo;
@Schema(description = "图标")
private String icon;
@Schema(description = "域名")
private String domain;
@Schema(description = "运行状态 0未开通 1正常 2维护中 3违规关停")
private Integer running;
@Schema(description = "应用版本 10免费版 20授权版 30永久授权")
private Integer version;
@Schema(description = "服务到期时间")
private String expirationTime;
@Schema(description = "创建时间")
private String createTime;
@Schema(description = "是否到期 -1已过期 1未过期")
private Integer expired;
@Schema(description = "剩余天数")
private Long expiredDays;
@Schema(description = "即将过期 0否 1是")
private Integer soon;
@Schema(description = "状态图标")
private String statusIcon;
@Schema(description = "状态文本")
private String statusText;
@Schema(description = "网站配置")
private Object config;
@Schema(description = "服务器时间信息")
private HashMap<String, Object> serverTime;
@Schema(description = "顶部导航")
private List<MenuVo> topNavs;
@Schema(description = "底部导航")
private List<MenuVo> bottomNavs;
@Schema(description = "网站设置")
private Object setting;
}
Loading…
Cancel
Save