28 changed files with 1120 additions and 14 deletions
@ -0,0 +1,94 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.qualification; |
||||
|
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.validation.annotation.Validated; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
import io.swagger.v3.oas.annotations.Parameter; |
||||
import io.swagger.v3.oas.annotations.Operation; |
||||
|
||||
import java.util.*; |
||||
import java.io.IOException; |
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; |
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.qualification.vo.*; |
||||
import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; |
||||
import cn.iocoder.yudao.module.system.service.qualification.EnterpriseQualificationService; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import javax.validation.Valid; |
||||
@Tag(name = "管理后台 - 企业资质") |
||||
@RestController |
||||
@RequestMapping("/system/enterprise-qualification") |
||||
@Validated |
||||
public class EnterpriseQualificationController { |
||||
|
||||
@Resource |
||||
private EnterpriseQualificationService enterpriseQualificationService; |
||||
|
||||
@PostMapping("/create") |
||||
@Operation(summary = "创建企业资质") |
||||
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:create')") |
||||
public CommonResult<Long> createEnterpriseQualification(@Valid @RequestBody EnterpriseQualificationSaveReqVO createReqVO) { |
||||
return success(enterpriseQualificationService.createEnterpriseQualification(createReqVO)); |
||||
} |
||||
|
||||
@PutMapping("/update") |
||||
@Operation(summary = "更新企业资质") |
||||
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:update')") |
||||
public CommonResult<Boolean> updateEnterpriseQualification(@Valid @RequestBody EnterpriseQualificationSaveReqVO updateReqVO) { |
||||
enterpriseQualificationService.updateEnterpriseQualification(updateReqVO); |
||||
return success(true); |
||||
} |
||||
|
||||
@DeleteMapping("/delete") |
||||
@Operation(summary = "删除企业资质") |
||||
@Parameter(name = "id", description = "编号", required = true) |
||||
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:delete')") |
||||
public CommonResult<Boolean> deleteEnterpriseQualification(@RequestParam("id") Long id) { |
||||
enterpriseQualificationService.deleteEnterpriseQualification(id); |
||||
return success(true); |
||||
} |
||||
|
||||
@GetMapping("/get") |
||||
@Operation(summary = "获得企业资质") |
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
||||
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:query')") |
||||
public CommonResult<EnterpriseQualificationRespVO> getEnterpriseQualification(@RequestParam("id") Long id) { |
||||
EnterpriseQualificationDO enterpriseQualification = enterpriseQualificationService.getEnterpriseQualification(id); |
||||
return success(BeanUtils.toBean(enterpriseQualification, EnterpriseQualificationRespVO.class)); |
||||
} |
||||
|
||||
@GetMapping("/page") |
||||
@Operation(summary = "获得企业资质分页") |
||||
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:query')") |
||||
public CommonResult<PageResult<EnterpriseQualificationRespVO>> getEnterpriseQualificationPage(@Valid EnterpriseQualificationPageReqVO pageReqVO) { |
||||
PageResult<EnterpriseQualificationDO> pageResult = enterpriseQualificationService.getEnterpriseQualificationPage(pageReqVO); |
||||
return success(BeanUtils.toBean(pageResult, EnterpriseQualificationRespVO.class)); |
||||
} |
||||
|
||||
@GetMapping("/export-excel") |
||||
@Operation(summary = "导出企业资质 Excel") |
||||
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:export')") |
||||
@ApiAccessLog(operateType = EXPORT) |
||||
public void exportEnterpriseQualificationExcel(@Valid EnterpriseQualificationPageReqVO pageReqVO, |
||||
HttpServletResponse response) throws IOException { |
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
||||
List<EnterpriseQualificationDO> list = enterpriseQualificationService.getEnterpriseQualificationPage(pageReqVO).getList(); |
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "企业资质.xls", "数据", EnterpriseQualificationRespVO.class, |
||||
BeanUtils.toBean(list, EnterpriseQualificationRespVO.class)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,52 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.qualification.vo; |
||||
|
||||
import lombok.*; |
||||
|
||||
import java.time.LocalDate; |
||||
import java.util.*; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
import java.time.LocalDateTime; |
||||
|
||||
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
||||
|
||||
@Schema(description = "管理后台 - 企业资质分页 Request VO") |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ToString(callSuper = true) |
||||
public class EnterpriseQualificationPageReqVO extends PageParam { |
||||
|
||||
@Schema(description = "企业ID", example = "28564") |
||||
private Long enterpriseId; |
||||
|
||||
@Schema(description = "资质名称,例如:排污许可证、环保合格证", example = "张三") |
||||
private String qualificationName; |
||||
|
||||
@Schema(description = "资质到期日期") |
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
||||
private LocalDateTime[] expiryDate; |
||||
|
||||
@Schema(description = "资质描述,详细说明资质信息", example = "随便") |
||||
private String qualificationDescription; |
||||
|
||||
@Schema(description = "创建时间") |
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
||||
private LocalDateTime[] createTime; |
||||
|
||||
@Schema(description = "修改人") |
||||
private String updater; |
||||
|
||||
@Schema(description = "创建人") |
||||
private String creator; |
||||
|
||||
@Schema(description = "办理日期") |
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
||||
private LocalDate[] handleDate; |
||||
|
||||
@Schema(description = "资质编号") |
||||
private String enterpriseAuth; |
||||
|
||||
} |
@ -0,0 +1,57 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.qualification.vo; |
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.*; |
||||
|
||||
import java.time.LocalDate; |
||||
import java.util.*; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
import java.time.LocalDateTime; |
||||
import com.alibaba.excel.annotation.*; |
||||
|
||||
@Schema(description = "管理后台 - 企业资质 Response VO") |
||||
@Data |
||||
@ExcelIgnoreUnannotated |
||||
public class EnterpriseQualificationRespVO { |
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16561") |
||||
@ExcelProperty("主键") |
||||
private Long id; |
||||
|
||||
@Schema(description = "企业ID", example = "28564") |
||||
@ExcelProperty("企业ID") |
||||
private Long enterpriseId; |
||||
|
||||
@Schema(description = "资质名称,例如:排污许可证、环保合格证", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") |
||||
@ExcelProperty("资质名称,例如:排污许可证、环保合格证") |
||||
private Integer qualificationName; |
||||
|
||||
@Schema(description = "资质到期日期") |
||||
@ExcelProperty("资质到期日期") |
||||
private LocalDate expiryDate; |
||||
|
||||
@Schema(description = "资质描述,详细说明资质信息", example = "随便") |
||||
@ExcelProperty("资质描述,详细说明资质信息") |
||||
private String qualificationDescription; |
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
||||
@ExcelProperty("创建时间") |
||||
private LocalDateTime createTime; |
||||
|
||||
@Schema(description = "修改人") |
||||
@ExcelProperty("修改人") |
||||
private String updater; |
||||
|
||||
@Schema(description = "创建人") |
||||
@ExcelProperty("创建人") |
||||
private String creator; |
||||
|
||||
@Schema(description = "办理日期") |
||||
@ExcelProperty("办理日期") |
||||
private LocalDate handleDate; |
||||
|
||||
@Schema(description = "资质编号") |
||||
@ExcelProperty("资质编号") |
||||
private String enterpriseAuth; |
||||
|
||||
} |
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.qualification.vo; |
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.*; |
||||
|
||||
import java.time.LocalDate; |
||||
import java.util.*; |
||||
|
||||
@Schema(description = "管理后台 - 企业资质新增/修改 Request VO") |
||||
@Data |
||||
public class EnterpriseQualificationSaveReqVO { |
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16561") |
||||
private Long id; |
||||
|
||||
@Schema(description = "企业ID", example = "28564") |
||||
private Long enterpriseId; |
||||
|
||||
@Schema(description = "资质名称,例如:排污许可证、环保合格证", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") |
||||
private Integer qualificationName; |
||||
|
||||
@Schema(description = "资质到期日期") |
||||
private LocalDate expiryDate; |
||||
|
||||
@Schema(description = "资质描述,详细说明资质信息", example = "随便") |
||||
private String qualificationDescription; |
||||
|
||||
@Schema(description = "修改人") |
||||
private String updater; |
||||
|
||||
@Schema(description = "创建人") |
||||
private String creator; |
||||
|
||||
@Schema(description = "办理日期") |
||||
private LocalDate handleDate; |
||||
|
||||
@Schema(description = "资质编号") |
||||
private String enterpriseAuth; |
||||
|
||||
} |
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.qualification; |
||||
|
||||
import lombok.*; |
||||
import java.util.*; |
||||
import java.time.LocalDateTime; |
||||
import java.time.LocalDateTime; |
||||
import com.baomidou.mybatisplus.annotation.*; |
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
||||
|
||||
/** |
||||
* 企业资质 DO |
||||
* |
||||
* @author 芋道源码 |
||||
*/ |
||||
@TableName("enterprise_qualification") |
||||
@KeySequence("enterprise_qualification_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ToString(callSuper = true) |
||||
@Builder |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
public class EnterpriseQualificationDO extends BaseDO { |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@TableId |
||||
private Long id; |
||||
/** |
||||
* 企业ID |
||||
*/ |
||||
private Long enterpriseId; |
||||
/** |
||||
* 资质名称,例如:排污许可证、环保合格证 |
||||
*/ |
||||
private Integer qualificationName; |
||||
/** |
||||
* 资质到期日期 |
||||
*/ |
||||
private LocalDateTime expiryDate; |
||||
/** |
||||
* 资质描述,详细说明资质信息 |
||||
*/ |
||||
private String qualificationDescription; |
||||
|
||||
/** |
||||
* 办理日期 |
||||
*/ |
||||
private LocalDateTime handleDate; |
||||
/** |
||||
* 资质编号 |
||||
*/ |
||||
private String enterpriseAuth; |
||||
|
||||
} |
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.qualification; |
||||
|
||||
import java.util.*; |
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
||||
import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import cn.iocoder.yudao.module.system.controller.admin.qualification.vo.*; |
||||
|
||||
/** |
||||
* 企业资质 Mapper |
||||
* |
||||
* @author 芋道源码 |
||||
*/ |
||||
@Mapper |
||||
public interface EnterpriseQualificationMapper extends BaseMapperX<EnterpriseQualificationDO> { |
||||
|
||||
default PageResult<EnterpriseQualificationDO> selectPage(EnterpriseQualificationPageReqVO reqVO) { |
||||
return selectPage(reqVO, new LambdaQueryWrapperX<EnterpriseQualificationDO>() |
||||
.eqIfPresent(EnterpriseQualificationDO::getEnterpriseId, reqVO.getEnterpriseId()) |
||||
.likeIfPresent(EnterpriseQualificationDO::getQualificationName, reqVO.getQualificationName()) |
||||
.betweenIfPresent(EnterpriseQualificationDO::getExpiryDate, reqVO.getExpiryDate()) |
||||
.eqIfPresent(EnterpriseQualificationDO::getQualificationDescription, reqVO.getQualificationDescription()) |
||||
.betweenIfPresent(EnterpriseQualificationDO::getCreateTime, reqVO.getCreateTime()) |
||||
.eqIfPresent(EnterpriseQualificationDO::getUpdater, reqVO.getUpdater()) |
||||
.eqIfPresent(EnterpriseQualificationDO::getCreator, reqVO.getCreator()) |
||||
.betweenIfPresent(EnterpriseQualificationDO::getHandleDate, reqVO.getHandleDate()) |
||||
.eqIfPresent(EnterpriseQualificationDO::getEnterpriseAuth, reqVO.getEnterpriseAuth()) |
||||
.orderByDesc(EnterpriseQualificationDO::getId)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.system.service.qualification; |
||||
|
||||
import java.util.*; |
||||
import cn.iocoder.yudao.module.system.controller.admin.qualification.vo.*; |
||||
import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; |
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
||||
|
||||
import javax.validation.Valid; |
||||
/** |
||||
* 企业资质 Service 接口 |
||||
* |
||||
* @author 芋道源码 |
||||
*/ |
||||
public interface EnterpriseQualificationService { |
||||
|
||||
/** |
||||
* 创建企业资质 |
||||
* |
||||
* @param createReqVO 创建信息 |
||||
* @return 编号 |
||||
*/ |
||||
Long createEnterpriseQualification(@Valid EnterpriseQualificationSaveReqVO createReqVO); |
||||
|
||||
/** |
||||
* 更新企业资质 |
||||
* |
||||
* @param updateReqVO 更新信息 |
||||
*/ |
||||
void updateEnterpriseQualification(@Valid EnterpriseQualificationSaveReqVO updateReqVO); |
||||
|
||||
/** |
||||
* 删除企业资质 |
||||
* |
||||
* @param id 编号 |
||||
*/ |
||||
void deleteEnterpriseQualification(Long id); |
||||
|
||||
/** |
||||
* 获得企业资质 |
||||
* |
||||
* @param id 编号 |
||||
* @return 企业资质 |
||||
*/ |
||||
EnterpriseQualificationDO getEnterpriseQualification(Long id); |
||||
|
||||
/** |
||||
* 获得企业资质分页 |
||||
* |
||||
* @param pageReqVO 分页查询 |
||||
* @return 企业资质分页 |
||||
*/ |
||||
PageResult<EnterpriseQualificationDO> getEnterpriseQualificationPage(EnterpriseQualificationPageReqVO pageReqVO); |
||||
|
||||
} |
@ -0,0 +1,76 @@
|
||||
package cn.iocoder.yudao.module.system.service.qualification; |
||||
|
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.validation.annotation.Validated; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import java.util.*; |
||||
import cn.iocoder.yudao.module.system.controller.admin.qualification.vo.*; |
||||
import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; |
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
||||
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.qualification.EnterpriseQualificationMapper; |
||||
|
||||
import javax.annotation.Resource; |
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; |
||||
|
||||
|
||||
/** |
||||
* 企业资质 Service 实现类 |
||||
* |
||||
* @author 芋道源码 |
||||
*/ |
||||
@Service |
||||
@Validated |
||||
public class EnterpriseQualificationServiceImpl implements EnterpriseQualificationService { |
||||
|
||||
@Resource |
||||
private EnterpriseQualificationMapper enterpriseQualificationMapper; |
||||
|
||||
@Override |
||||
public Long createEnterpriseQualification(EnterpriseQualificationSaveReqVO createReqVO) { |
||||
// 插入
|
||||
EnterpriseQualificationDO enterpriseQualification = BeanUtils.toBean(createReqVO, EnterpriseQualificationDO.class); |
||||
enterpriseQualificationMapper.insert(enterpriseQualification); |
||||
// 返回
|
||||
return enterpriseQualification.getId(); |
||||
} |
||||
|
||||
@Override |
||||
public void updateEnterpriseQualification(EnterpriseQualificationSaveReqVO updateReqVO) { |
||||
// 校验存在
|
||||
validateEnterpriseQualificationExists(updateReqVO.getId()); |
||||
// 更新
|
||||
EnterpriseQualificationDO updateObj = BeanUtils.toBean(updateReqVO, EnterpriseQualificationDO.class); |
||||
enterpriseQualificationMapper.updateById(updateObj); |
||||
} |
||||
|
||||
@Override |
||||
public void deleteEnterpriseQualification(Long id) { |
||||
// 校验存在
|
||||
validateEnterpriseQualificationExists(id); |
||||
// 删除
|
||||
enterpriseQualificationMapper.deleteById(id); |
||||
} |
||||
|
||||
private void validateEnterpriseQualificationExists(Long id) { |
||||
if (enterpriseQualificationMapper.selectById(id) == null) { |
||||
throw exception(ENTERPRISE_QUALIFICATION_NOT_EXISTS); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public EnterpriseQualificationDO getEnterpriseQualification(Long id) { |
||||
return enterpriseQualificationMapper.selectById(id); |
||||
} |
||||
|
||||
@Override |
||||
public PageResult<EnterpriseQualificationDO> getEnterpriseQualificationPage(EnterpriseQualificationPageReqVO pageReqVO) { |
||||
return enterpriseQualificationMapper.selectPage(pageReqVO); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,12 @@
|
||||
<?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="cn.iocoder.yudao.module.system.dal.mysql.qualification.EnterpriseQualificationMapper"> |
||||
|
||||
<!-- |
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 |
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 |
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ |
||||
--> |
||||
|
||||
</mapper> |
@ -0,0 +1,3 @@
|
||||
// TODO 待办:请将下面的错误码复制到 yudao-module-system-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!!
|
||||
// ========== 企业资质 TODO 补充编号 ==========
|
||||
ErrorCode ENTERPRISE_QUALIFICATION_NOT_EXISTS = new ErrorCode(TODO 补充编号, "企业资质不存在"); |
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.qualification; |
||||
|
||||
import org.springframework.web.bind.annotation.*; |
||||
import jakarta.annotation.Resource; |
||||
import org.springframework.validation.annotation.Validated; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
import io.swagger.v3.oas.annotations.Parameter; |
||||
import io.swagger.v3.oas.annotations.Operation; |
||||
|
||||
import jakarta.validation.constraints.*; |
||||
import jakarta.validation.*; |
||||
import jakarta.servlet.http.*; |
||||
import java.util.*; |
||||
import java.io.IOException; |
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; |
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.qualification.vo.*; |
||||
import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; |
||||
import cn.iocoder.yudao.module.system.service.qualification.EnterpriseQualificationService; |
||||
|
||||
@Tag(name = "管理后台 - 企业资质") |
||||
@RestController |
||||
@RequestMapping("/system/enterprise-qualification") |
||||
@Validated |
||||
public class EnterpriseQualificationController { |
||||
|
||||
@Resource |
||||
private EnterpriseQualificationService enterpriseQualificationService; |
||||
|
||||
@PostMapping("/create") |
||||
@Operation(summary = "创建企业资质") |
||||
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:create')") |
||||
public CommonResult<Long> createEnterpriseQualification(@Valid @RequestBody EnterpriseQualificationSaveReqVO createReqVO) { |
||||
return success(enterpriseQualificationService.createEnterpriseQualification(createReqVO)); |
||||
} |
||||
|
||||
@PutMapping("/update") |
||||
@Operation(summary = "更新企业资质") |
||||
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:update')") |
||||
public CommonResult<Boolean> updateEnterpriseQualification(@Valid @RequestBody EnterpriseQualificationSaveReqVO updateReqVO) { |
||||
enterpriseQualificationService.updateEnterpriseQualification(updateReqVO); |
||||
return success(true); |
||||
} |
||||
|
||||
@DeleteMapping("/delete") |
||||
@Operation(summary = "删除企业资质") |
||||
@Parameter(name = "id", description = "编号", required = true) |
||||
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:delete')") |
||||
public CommonResult<Boolean> deleteEnterpriseQualification(@RequestParam("id") Long id) { |
||||
enterpriseQualificationService.deleteEnterpriseQualification(id); |
||||
return success(true); |
||||
} |
||||
|
||||
@GetMapping("/get") |
||||
@Operation(summary = "获得企业资质") |
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
||||
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:query')") |
||||
public CommonResult<EnterpriseQualificationRespVO> getEnterpriseQualification(@RequestParam("id") Long id) { |
||||
EnterpriseQualificationDO enterpriseQualification = enterpriseQualificationService.getEnterpriseQualification(id); |
||||
return success(BeanUtils.toBean(enterpriseQualification, EnterpriseQualificationRespVO.class)); |
||||
} |
||||
|
||||
@GetMapping("/page") |
||||
@Operation(summary = "获得企业资质分页") |
||||
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:query')") |
||||
public CommonResult<PageResult<EnterpriseQualificationRespVO>> getEnterpriseQualificationPage(@Valid EnterpriseQualificationPageReqVO pageReqVO) { |
||||
PageResult<EnterpriseQualificationDO> pageResult = enterpriseQualificationService.getEnterpriseQualificationPage(pageReqVO); |
||||
return success(BeanUtils.toBean(pageResult, EnterpriseQualificationRespVO.class)); |
||||
} |
||||
|
||||
@GetMapping("/export-excel") |
||||
@Operation(summary = "导出企业资质 Excel") |
||||
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:export')") |
||||
@ApiAccessLog(operateType = EXPORT) |
||||
public void exportEnterpriseQualificationExcel(@Valid EnterpriseQualificationPageReqVO pageReqVO, |
||||
HttpServletResponse response) throws IOException { |
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
||||
List<EnterpriseQualificationDO> list = enterpriseQualificationService.getEnterpriseQualificationPage(pageReqVO).getList(); |
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "企业资质.xls", "数据", EnterpriseQualificationRespVO.class, |
||||
BeanUtils.toBean(list, EnterpriseQualificationRespVO.class)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,48 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.qualification.vo; |
||||
|
||||
import lombok.*; |
||||
import java.util.*; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
import java.time.LocalDateTime; |
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
||||
|
||||
@Schema(description = "管理后台 - 企业资质分页 Request VO") |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ToString(callSuper = true) |
||||
public class EnterpriseQualificationPageReqVO extends PageParam { |
||||
|
||||
@Schema(description = "企业ID", example = "28564") |
||||
private Long enterpriseId; |
||||
|
||||
@Schema(description = "资质名称,例如:排污许可证、环保合格证", example = "张三") |
||||
private Integer qualificationName; |
||||
|
||||
@Schema(description = "资质到期日期") |
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
||||
private LocalDate[] expiryDate; |
||||
|
||||
@Schema(description = "资质描述,详细说明资质信息", example = "随便") |
||||
private String qualificationDescription; |
||||
|
||||
@Schema(description = "创建时间") |
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
||||
private LocalDateTime[] createTime; |
||||
|
||||
@Schema(description = "修改人") |
||||
private String updateBy; |
||||
|
||||
@Schema(description = "创建人") |
||||
private String createBy; |
||||
|
||||
@Schema(description = "办理日期") |
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
||||
private LocalDate[] handleDate; |
||||
|
||||
@Schema(description = "资质编号") |
||||
private String enterpriseAuth; |
||||
|
||||
} |
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.qualification.vo; |
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.*; |
||||
import java.util.*; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
import java.time.LocalDateTime; |
||||
import com.alibaba.excel.annotation.*; |
||||
|
||||
@Schema(description = "管理后台 - 企业资质 Response VO") |
||||
@Data |
||||
@ExcelIgnoreUnannotated |
||||
public class EnterpriseQualificationRespVO { |
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16561") |
||||
@ExcelProperty("主键") |
||||
private Long id; |
||||
|
||||
@Schema(description = "企业ID", example = "28564") |
||||
@ExcelProperty("企业ID") |
||||
private Long enterpriseId; |
||||
|
||||
@Schema(description = "资质名称,例如:排污许可证、环保合格证", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") |
||||
@ExcelProperty("资质名称,例如:排污许可证、环保合格证") |
||||
private Integer qualificationName; |
||||
|
||||
@Schema(description = "资质到期日期") |
||||
@ExcelProperty("资质到期日期") |
||||
private LocalDate expiryDate; |
||||
|
||||
@Schema(description = "资质描述,详细说明资质信息", example = "随便") |
||||
@ExcelProperty("资质描述,详细说明资质信息") |
||||
private String qualificationDescription; |
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
||||
@ExcelProperty("创建时间") |
||||
private LocalDateTime createTime; |
||||
|
||||
@Schema(description = "修改人") |
||||
@ExcelProperty("修改人") |
||||
private String updateBy; |
||||
|
||||
@Schema(description = "创建人") |
||||
@ExcelProperty("创建人") |
||||
private String createBy; |
||||
|
||||
@Schema(description = "办理日期") |
||||
@ExcelProperty("办理日期") |
||||
private LocalDate handleDate; |
||||
|
||||
@Schema(description = "资质编号") |
||||
@ExcelProperty("资质编号") |
||||
private String enterpriseAuth; |
||||
|
||||
} |
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.qualification.vo; |
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.*; |
||||
import java.util.*; |
||||
import jakarta.validation.constraints.*; |
||||
|
||||
@Schema(description = "管理后台 - 企业资质新增/修改 Request VO") |
||||
@Data |
||||
public class EnterpriseQualificationSaveReqVO { |
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16561") |
||||
private Long id; |
||||
|
||||
@Schema(description = "企业ID", example = "28564") |
||||
private Long enterpriseId; |
||||
|
||||
@Schema(description = "资质名称,例如:排污许可证、环保合格证", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") |
||||
@NotNull(message = "资质名称,例如:排污许可证、环保合格证不能为空") |
||||
private Integer qualificationName; |
||||
|
||||
@Schema(description = "资质到期日期") |
||||
private LocalDate expiryDate; |
||||
|
||||
@Schema(description = "资质描述,详细说明资质信息", example = "随便") |
||||
private String qualificationDescription; |
||||
|
||||
@Schema(description = "修改人") |
||||
private String updateBy; |
||||
|
||||
@Schema(description = "创建人") |
||||
private String createBy; |
||||
|
||||
@Schema(description = "办理日期") |
||||
private LocalDate handleDate; |
||||
|
||||
@Schema(description = "资质编号") |
||||
private String enterpriseAuth; |
||||
|
||||
} |
@ -0,0 +1,63 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.qualification; |
||||
|
||||
import lombok.*; |
||||
import java.util.*; |
||||
import java.time.LocalDateTime; |
||||
import java.time.LocalDateTime; |
||||
import com.baomidou.mybatisplus.annotation.*; |
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
||||
|
||||
/** |
||||
* 企业资质 DO |
||||
* |
||||
* @author 芋道源码 |
||||
*/ |
||||
@TableName("enterprise_qualification") |
||||
@KeySequence("enterprise_qualification_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ToString(callSuper = true) |
||||
@Builder |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
public class EnterpriseQualificationDO extends BaseDO { |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@TableId |
||||
private Long id; |
||||
/** |
||||
* 企业ID |
||||
*/ |
||||
private Long enterpriseId; |
||||
/** |
||||
* 资质名称,例如:排污许可证、环保合格证 |
||||
*/ |
||||
private Integer qualificationName; |
||||
/** |
||||
* 资质到期日期 |
||||
*/ |
||||
private LocalDate expiryDate; |
||||
/** |
||||
* 资质描述,详细说明资质信息 |
||||
*/ |
||||
private String qualificationDescription; |
||||
/** |
||||
* 修改人 |
||||
*/ |
||||
private String updateBy; |
||||
/** |
||||
* 创建人 |
||||
*/ |
||||
private String createBy; |
||||
/** |
||||
* 办理日期 |
||||
*/ |
||||
private LocalDate handleDate; |
||||
/** |
||||
* 资质编号 |
||||
*/ |
||||
private String enterpriseAuth; |
||||
|
||||
} |
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.qualification; |
||||
|
||||
import java.util.*; |
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
||||
import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import cn.iocoder.yudao.module.system.controller.admin.qualification.vo.*; |
||||
|
||||
/** |
||||
* 企业资质 Mapper |
||||
* |
||||
* @author 芋道源码 |
||||
*/ |
||||
@Mapper |
||||
public interface EnterpriseQualificationMapper extends BaseMapperX<EnterpriseQualificationDO> { |
||||
|
||||
default PageResult<EnterpriseQualificationDO> selectPage(EnterpriseQualificationPageReqVO reqVO) { |
||||
return selectPage(reqVO, new LambdaQueryWrapperX<EnterpriseQualificationDO>() |
||||
.eqIfPresent(EnterpriseQualificationDO::getEnterpriseId, reqVO.getEnterpriseId()) |
||||
.likeIfPresent(EnterpriseQualificationDO::getQualificationName, reqVO.getQualificationName()) |
||||
.betweenIfPresent(EnterpriseQualificationDO::getExpiryDate, reqVO.getExpiryDate()) |
||||
.eqIfPresent(EnterpriseQualificationDO::getQualificationDescription, reqVO.getQualificationDescription()) |
||||
.betweenIfPresent(EnterpriseQualificationDO::getCreateTime, reqVO.getCreateTime()) |
||||
.eqIfPresent(EnterpriseQualificationDO::getUpdateBy, reqVO.getUpdateBy()) |
||||
.eqIfPresent(EnterpriseQualificationDO::getCreateBy, reqVO.getCreateBy()) |
||||
.betweenIfPresent(EnterpriseQualificationDO::getHandleDate, reqVO.getHandleDate()) |
||||
.eqIfPresent(EnterpriseQualificationDO::getEnterpriseAuth, reqVO.getEnterpriseAuth()) |
||||
.orderByDesc(EnterpriseQualificationDO::getId)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.system.service.qualification; |
||||
|
||||
import java.util.*; |
||||
import jakarta.validation.*; |
||||
import cn.iocoder.yudao.module.system.controller.admin.qualification.vo.*; |
||||
import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; |
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
||||
|
||||
/** |
||||
* 企业资质 Service 接口 |
||||
* |
||||
* @author 芋道源码 |
||||
*/ |
||||
public interface EnterpriseQualificationService { |
||||
|
||||
/** |
||||
* 创建企业资质 |
||||
* |
||||
* @param createReqVO 创建信息 |
||||
* @return 编号 |
||||
*/ |
||||
Long createEnterpriseQualification(@Valid EnterpriseQualificationSaveReqVO createReqVO); |
||||
|
||||
/** |
||||
* 更新企业资质 |
||||
* |
||||
* @param updateReqVO 更新信息 |
||||
*/ |
||||
void updateEnterpriseQualification(@Valid EnterpriseQualificationSaveReqVO updateReqVO); |
||||
|
||||
/** |
||||
* 删除企业资质 |
||||
* |
||||
* @param id 编号 |
||||
*/ |
||||
void deleteEnterpriseQualification(Long id); |
||||
|
||||
/** |
||||
* 获得企业资质 |
||||
* |
||||
* @param id 编号 |
||||
* @return 企业资质 |
||||
*/ |
||||
EnterpriseQualificationDO getEnterpriseQualification(Long id); |
||||
|
||||
/** |
||||
* 获得企业资质分页 |
||||
* |
||||
* @param pageReqVO 分页查询 |
||||
* @return 企业资质分页 |
||||
*/ |
||||
PageResult<EnterpriseQualificationDO> getEnterpriseQualificationPage(EnterpriseQualificationPageReqVO pageReqVO); |
||||
|
||||
} |
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.system.service.qualification; |
||||
|
||||
import org.springframework.stereotype.Service; |
||||
import jakarta.annotation.Resource; |
||||
import org.springframework.validation.annotation.Validated; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import java.util.*; |
||||
import cn.iocoder.yudao.module.system.controller.admin.qualification.vo.*; |
||||
import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; |
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
||||
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.qualification.EnterpriseQualificationMapper; |
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; |
||||
|
||||
/** |
||||
* 企业资质 Service 实现类 |
||||
* |
||||
* @author 芋道源码 |
||||
*/ |
||||
@Service |
||||
@Validated |
||||
public class EnterpriseQualificationServiceImpl implements EnterpriseQualificationService { |
||||
|
||||
@Resource |
||||
private EnterpriseQualificationMapper enterpriseQualificationMapper; |
||||
|
||||
@Override |
||||
public Long createEnterpriseQualification(EnterpriseQualificationSaveReqVO createReqVO) { |
||||
// 插入
|
||||
EnterpriseQualificationDO enterpriseQualification = BeanUtils.toBean(createReqVO, EnterpriseQualificationDO.class); |
||||
enterpriseQualificationMapper.insert(enterpriseQualification); |
||||
// 返回
|
||||
return enterpriseQualification.getId(); |
||||
} |
||||
|
||||
@Override |
||||
public void updateEnterpriseQualification(EnterpriseQualificationSaveReqVO updateReqVO) { |
||||
// 校验存在
|
||||
validateEnterpriseQualificationExists(updateReqVO.getId()); |
||||
// 更新
|
||||
EnterpriseQualificationDO updateObj = BeanUtils.toBean(updateReqVO, EnterpriseQualificationDO.class); |
||||
enterpriseQualificationMapper.updateById(updateObj); |
||||
} |
||||
|
||||
@Override |
||||
public void deleteEnterpriseQualification(Long id) { |
||||
// 校验存在
|
||||
validateEnterpriseQualificationExists(id); |
||||
// 删除
|
||||
enterpriseQualificationMapper.deleteById(id); |
||||
} |
||||
|
||||
private void validateEnterpriseQualificationExists(Long id) { |
||||
if (enterpriseQualificationMapper.selectById(id) == null) { |
||||
throw exception(ENTERPRISE_QUALIFICATION_NOT_EXISTS); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public EnterpriseQualificationDO getEnterpriseQualification(Long id) { |
||||
return enterpriseQualificationMapper.selectById(id); |
||||
} |
||||
|
||||
@Override |
||||
public PageResult<EnterpriseQualificationDO> getEnterpriseQualificationPage(EnterpriseQualificationPageReqVO pageReqVO) { |
||||
return enterpriseQualificationMapper.selectPage(pageReqVO); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,12 @@
|
||||
<?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="cn.iocoder.yudao.module.system.dal.mysql.qualification.EnterpriseQualificationMapper"> |
||||
|
||||
<!-- |
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 |
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 |
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ |
||||
--> |
||||
|
||||
</mapper> |
Loading…
Reference in new issue