feat: 申请license

This commit is contained in:
caiyuchao
2025-07-07 10:02:05 +08:00
parent 2b61b69c1b
commit a9043b2d39
5 changed files with 67 additions and 3 deletions

View File

@@ -0,0 +1,27 @@
package org.agt.module.license.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 角色标识枚举
*/
@Getter
@AllArgsConstructor
public enum LicenseStatusEnum {
NOT_APPLIED(0, "未申请"),
IN_APPLICATION(1, "申请中"),
COMPLETED(2, "已完成"); // CRM 系统专用
;
/**
* code
*/
private final Integer code;
/**
* name
*/
private final String name;
}

View File

@@ -58,6 +58,14 @@ public class LicenseController {
return success(true);
}
@PutMapping("/apply")
@Operation(summary = "申请License")
@PreAuthorize("@ss.hasPermission('license:license:apply')")
public CommonResult<Boolean> applyLicense(@Valid @RequestBody LicenseSaveReqVO updateReqVO) {
licenseService.applyLicense(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除License")
@Parameter(name = "id", description = "编号", required = true)

View File

@@ -11,6 +11,7 @@ import org.agt.framework.excel.core.annotations.DictFormat;
import org.agt.framework.excel.core.convert.DictConvert;
import org.agt.module.license.dal.dataobject.customer.CustomerDO;
import org.agt.module.license.dal.dataobject.project.ProjectDO;
import org.agt.module.system.api.user.AdminUserApi;
import java.time.LocalDateTime;
import java.util.List;
@@ -69,18 +70,26 @@ public class LicenseRespVO implements VO {
@ExcelProperty("License内容")
private String licenseContent;
@Schema(description = "申请人")
@ExcelProperty("申请人")
@Schema(description = "申请人ID")
@Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "applicantName")
private Long applicant;
@Schema(description = "申请人", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("申请人")
private String applicantName;
@Schema(description = "申请时间")
@ExcelProperty("申请时间")
private LocalDateTime applicationTime;
@Schema(description = "审批人")
@ExcelProperty("审批人")
@Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "approverName")
private Long approver;
@Schema(description = "审批人", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("审批人")
private String approverName;
@Schema(description = "状态", example = "1")
@ExcelProperty(value = "状态", converter = DictConvert.class)
@DictFormat("lic_license_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中

View File

@@ -28,6 +28,13 @@ public interface LicenseService {
*/
void updateLicense(@Valid LicenseSaveReqVO updateReqVO);
/**
* 申请License
*
* @param updateReqVO 更新信息
*/
void applyLicense(@Valid LicenseSaveReqVO updateReqVO);
/**
* 删除License
*

View File

@@ -4,13 +4,17 @@ import cn.hutool.core.util.StrUtil;
import jakarta.annotation.Resource;
import org.agt.framework.common.pojo.PageResult;
import org.agt.framework.common.util.object.BeanUtils;
import org.agt.framework.web.core.util.WebFrameworkUtils;
import org.agt.module.license.controller.admin.license.vo.LicensePageReqVO;
import org.agt.module.license.controller.admin.license.vo.LicenseSaveReqVO;
import org.agt.module.license.dal.dataobject.license.LicenseDO;
import org.agt.module.license.dal.mysql.license.LicenseMapper;
import org.agt.module.license.enums.LicenseStatusEnum;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.time.LocalDateTime;
import static org.agt.framework.common.exception.util.ServiceExceptionUtil.exception;
import static org.agt.module.license.enums.ErrorCodeConstants.LICENSE_NOT_EXISTS;
import static org.agt.module.license.enums.ErrorCodeConstants.LICENSE_SN_DUPLICATE;
@@ -35,6 +39,7 @@ public class LicenseServiceImpl implements LicenseService {
}
// 插入
LicenseDO license = BeanUtils.toBean(createReqVO, LicenseDO.class);
license.setStatus(LicenseStatusEnum.NOT_APPLIED.getCode());
licenseMapper.insert(license);
// 返回
return license.getId();
@@ -53,6 +58,14 @@ public class LicenseServiceImpl implements LicenseService {
licenseMapper.updateById(updateObj);
}
@Override
public void applyLicense(LicenseSaveReqVO updateReqVO) {
updateReqVO.setStatus(LicenseStatusEnum.IN_APPLICATION.getCode());
updateReqVO.setApplicant(WebFrameworkUtils.getLoginUserId());
updateReqVO.setApplicationTime(LocalDateTime.now());
updateLicense(updateReqVO);
}
@Override
public void deleteLicense(Long id) {
// 校验存在