merge: integrate latest field updates into shadow v3

This commit is contained in:
zgw
2026-09-03 18:00:46 +08:00
49 changed files with 4621 additions and 367 deletions

View File

@@ -35,6 +35,10 @@
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-license</artifactId>
</dependency>
<!-- 核心模块-->
<dependency>

View File

@@ -0,0 +1,126 @@
package com.ruoyi.web.controller.system.license;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.license.domain.SysLicense;
import com.ruoyi.license.service.ISysLicenseService;
import com.ruoyi.license.util.LicenseUtils;
/**
* 授权码Controller
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/license")
public class SysLicenseController extends BaseController
{
@Autowired
private ISysLicenseService sysLicenseService;
/**
* 查询授权码列表
*/
@PreAuthorize("@ss.hasPermi('system:license:list')")
@GetMapping("/list")
public TableDataInfo list(SysLicense sysLicense)
{
startPage();
List<SysLicense> list = sysLicenseService.selectSysLicenseList(sysLicense);
return getDataTable(list);
}
/**
* 新增授权码
*/
@PreAuthorize("@ss.hasPermi('system:license:add')")
@Log(title = "授权码", businessType = BusinessType.INSERT)
@PostMapping("/add")
public AjaxResult add(SysLicense sysLicense)
{
return toAjax(sysLicenseService.insertSysLicense(sysLicense));
}
/**
* 修改授权码
*/
@PreAuthorize("@ss.hasPermi('system:license:edit')")
@Log(title = "授权码", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
public AjaxResult edit(SysLicense sysLicense)
{
return toAjax(sysLicenseService.updateSysLicense(sysLicense));
}
/**
* 删除授权码
*/
@PreAuthorize("@ss.hasPermi('system:license:remove')")
@Log(title = "授权码", businessType = BusinessType.DELETE)
@PostMapping("/remove")
public AjaxResult remove(String ids)
{
return toAjax(sysLicenseService.deleteSysLicenseByIds(ids));
}
/**
* 激活授权码(无需登录)
*/
@Log(title = "激活授权码", businessType = BusinessType.UPDATE)
@PostMapping("/active")
public AjaxResult active(String licenseCode)
{
if (!LicenseUtils.validateFormat(licenseCode))
{
return error("授权码格式不正确");
}
int result = sysLicenseService.activeLicense(licenseCode);
if (result > 0)
{
return success("授权码激活成功");
}
return error("授权码激活失败,请检查授权码是否正确或已过期");
}
/**
* 获取当前授权信息
* license 未开启或无有效授权时返回 code=200 data=null,前端静默处理
*/
@GetMapping("/info")
public AjaxResult info()
{
SysLicense license = sysLicenseService.getActiveLicense();
return AjaxResult.success(license);
}
/**
* 生成授权码
*/
@PreAuthorize("@ss.hasPermi('system:license:add')")
@GetMapping("/generate")
public AjaxResult generate(String type, String projectNo)
{
if (StringUtils.isEmpty(type) || StringUtils.isEmpty(projectNo))
{
return error("授权类型和项目编号不能为空");
}
String licenseCode = LicenseUtils.generateLicense(type, projectNo);
if (licenseCode == null)
{
return error("授权码生成失败");
}
return AjaxResult.success("授权码生成成功", licenseCode);
}
}

View File

@@ -135,6 +135,10 @@ token:
# 令牌有效期(默认30分钟)
expireTime: 43800
# 授权码配置
license:
# 首次部署需先执行 sql/sys_license.sql 并激活授权码,再改为 true 启用拦截
enabled: false
# MyBatis配置