Commit 59ef3fa065ad913a031b516ce14bc2c83c67f849
1 parent
511bc085
refactor(mes): 精简假期设置模块,优化接口和字段定义
1. type 从 String(varchar) 改为 Integer(tinyint),1=工作日 2=节假日 2. 移除 startTime/endTime 字段,theDay 重命名为 day 3. 精简为 3 个接口:save(upsert)、get-by-day、list 4. 删除 update/delete/get/page/export-excel 及 PageReqVO 5. RespVO 移除 Excel 注解,createHoliday 重命名为 saveHoliday
Showing
10 changed files
with
36 additions
and
227 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/holiday/MesCalHolidayController.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.controller.admin.cal.holiday; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | |
| 4 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 6 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 7 | 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 9 | -import cn.iocoder.yudao.module.mes.controller.admin.cal.holiday.vo.MesCalHolidayPageReqVO; | |
| 10 | 5 | import cn.iocoder.yudao.module.mes.controller.admin.cal.holiday.vo.MesCalHolidayRespVO; |
| 11 | 6 | import cn.iocoder.yudao.module.mes.controller.admin.cal.holiday.vo.MesCalHolidaySaveReqVO; |
| 12 | 7 | import cn.iocoder.yudao.module.mes.dal.dataobject.cal.holiday.MesCalHolidayDO; |
| ... | ... | @@ -15,16 +10,17 @@ import io.swagger.v3.oas.annotations.Operation; |
| 15 | 10 | import io.swagger.v3.oas.annotations.Parameter; |
| 16 | 11 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 17 | 12 | import jakarta.annotation.Resource; |
| 18 | -import jakarta.servlet.http.HttpServletResponse; | |
| 19 | 13 | import jakarta.validation.Valid; |
| 14 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 20 | 15 | import org.springframework.security.access.prepost.PreAuthorize; |
| 21 | 16 | import org.springframework.validation.annotation.Validated; |
| 22 | 17 | import org.springframework.web.bind.annotation.*; |
| 23 | 18 | |
| 24 | -import java.io.IOException; | |
| 19 | +import java.time.LocalDateTime; | |
| 25 | 20 | import java.util.List; |
| 26 | 21 | |
| 27 | -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | |
| 22 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 23 | + | |
| 28 | 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 29 | 25 | |
| 30 | 26 | @Tag(name = "管理后台 - MES 假期设置") |
| ... | ... | @@ -36,50 +32,23 @@ public class MesCalHolidayController { |
| 36 | 32 | @Resource |
| 37 | 33 | private MesCalHolidayService holidayService; |
| 38 | 34 | |
| 39 | - // TODO @AI:是不是只有 save,没有 update 和 delete,以及 create? | |
| 40 | - | |
| 41 | - @PostMapping("/create") | |
| 42 | - @Operation(summary = "创建假期设置", description = "如果该日期已存在记录,则更新") | |
| 35 | + @PostMapping("/save") | |
| 36 | + @Operation(summary = "保存假期设置", description = "如果该日期已存在记录,则更新") | |
| 43 | 37 | @PreAuthorize("@ss.hasPermission('mes:cal-holiday:create')") |
| 44 | - public CommonResult<Long> createHoliday(@Valid @RequestBody MesCalHolidaySaveReqVO createReqVO) { | |
| 45 | - return success(holidayService.createHoliday(createReqVO)); | |
| 46 | - } | |
| 47 | - | |
| 48 | - @PutMapping("/update") | |
| 49 | - @Operation(summary = "更新假期设置") | |
| 50 | - @PreAuthorize("@ss.hasPermission('mes:cal-holiday:update')") | |
| 51 | - public CommonResult<Boolean> updateHoliday(@Valid @RequestBody MesCalHolidaySaveReqVO updateReqVO) { | |
| 52 | - holidayService.updateHoliday(updateReqVO); | |
| 53 | - return success(true); | |
| 54 | - } | |
| 55 | - | |
| 56 | - @DeleteMapping("/delete") | |
| 57 | - @Operation(summary = "删除假期设置") | |
| 58 | - @Parameter(name = "id", description = "编号", required = true) | |
| 59 | - @PreAuthorize("@ss.hasPermission('mes:cal-holiday:delete')") | |
| 60 | - public CommonResult<Boolean> deleteHoliday(@RequestParam("id") Long id) { | |
| 61 | - holidayService.deleteHoliday(id); | |
| 62 | - return success(true); | |
| 38 | + public CommonResult<Long> saveHoliday(@Valid @RequestBody MesCalHolidaySaveReqVO saveReqVO) { | |
| 39 | + return success(holidayService.saveHoliday(saveReqVO)); | |
| 63 | 40 | } |
| 64 | 41 | |
| 65 | - @GetMapping("/get") | |
| 66 | - @Operation(summary = "获得假期设置") | |
| 67 | - @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 42 | + @GetMapping("/get-by-day") | |
| 43 | + @Operation(summary = "根据日期获得假期设置") | |
| 44 | + @Parameter(name = "day", description = "日期", required = true) | |
| 68 | 45 | @PreAuthorize("@ss.hasPermission('mes:cal-holiday:query')") |
| 69 | - public CommonResult<MesCalHolidayRespVO> getHoliday(@RequestParam("id") Long id) { | |
| 70 | - MesCalHolidayDO holiday = holidayService.getHoliday(id); | |
| 46 | + public CommonResult<MesCalHolidayRespVO> getHolidayByDay( | |
| 47 | + @RequestParam("day") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) LocalDateTime day) { | |
| 48 | + MesCalHolidayDO holiday = holidayService.getHolidayByDay(day); | |
| 71 | 49 | return success(BeanUtils.toBean(holiday, MesCalHolidayRespVO.class)); |
| 72 | 50 | } |
| 73 | 51 | |
| 74 | - // TODO @AI:对齐下,/Users/yunai/Java/ktg-mes 界面(不是后端),是否需要该接口。 | |
| 75 | - @GetMapping("/page") | |
| 76 | - @Operation(summary = "获得假期设置分页") | |
| 77 | - @PreAuthorize("@ss.hasPermission('mes:cal-holiday:query')") | |
| 78 | - public CommonResult<PageResult<MesCalHolidayRespVO>> getHolidayPage(@Valid MesCalHolidayPageReqVO pageReqVO) { | |
| 79 | - PageResult<MesCalHolidayDO> pageResult = holidayService.getHolidayPage(pageReqVO); | |
| 80 | - return success(BeanUtils.toBean(pageResult, MesCalHolidayRespVO.class)); | |
| 81 | - } | |
| 82 | - | |
| 83 | 52 | @GetMapping("/list") |
| 84 | 53 | @Operation(summary = "获得所有假期设置列表", description = "日历组件使用,返回全量数据") |
| 85 | 54 | @PreAuthorize("@ss.hasPermission('mes:cal-holiday:query')") |
| ... | ... | @@ -88,18 +57,4 @@ public class MesCalHolidayController { |
| 88 | 57 | return success(BeanUtils.toBean(list, MesCalHolidayRespVO.class)); |
| 89 | 58 | } |
| 90 | 59 | |
| 91 | - // TODO @AI:对齐下,/Users/yunai/Java/ktg-mes 界面(不是后端),是否需要该接口。 | |
| 92 | - @GetMapping("/export-excel") | |
| 93 | - @Operation(summary = "导出假期设置 Excel") | |
| 94 | - @PreAuthorize("@ss.hasPermission('mes:cal-holiday:export')") | |
| 95 | - @ApiAccessLog(operateType = EXPORT) | |
| 96 | - public void exportHolidayExcel(@Valid MesCalHolidayPageReqVO pageReqVO, | |
| 97 | - HttpServletResponse response) throws IOException { | |
| 98 | - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 99 | - List<MesCalHolidayDO> list = holidayService.getHolidayPage(pageReqVO).getList(); | |
| 100 | - // 导出 Excel | |
| 101 | - ExcelUtils.write(response, "假期设置.xls", "数据", MesCalHolidayRespVO.class, | |
| 102 | - BeanUtils.toBean(list, MesCalHolidayRespVO.class)); | |
| 103 | - } | |
| 104 | - | |
| 105 | 60 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/holiday/vo/MesCalHolidayPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.mes.controller.admin.cal.holiday.vo; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | -import lombok.Data; | |
| 6 | -import lombok.EqualsAndHashCode; | |
| 7 | -import lombok.ToString; | |
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | - | |
| 10 | -import java.time.LocalDateTime; | |
| 11 | - | |
| 12 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | - | |
| 14 | -@Schema(description = "管理后台 - MES 假期设置分页 Request VO") | |
| 15 | -@Data | |
| 16 | -@EqualsAndHashCode(callSuper = true) | |
| 17 | -@ToString(callSuper = true) | |
| 18 | -public class MesCalHolidayPageReqVO extends PageParam { | |
| 19 | - | |
| 20 | - @Schema(description = "日期类型", example = "HOLIDAY") | |
| 21 | - private String type; | |
| 22 | - | |
| 23 | - @Schema(description = "日期(起)") | |
| 24 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 25 | - private LocalDateTime theDayStart; | |
| 26 | - | |
| 27 | - @Schema(description = "日期(止)") | |
| 28 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 29 | - private LocalDateTime theDayEnd; | |
| 30 | - | |
| 31 | -} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/holiday/vo/MesCalHolidayRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.controller.admin.cal.holiday.vo; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 4 | -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 5 | -import cn.iocoder.yudao.module.mes.enums.DictTypeConstants; | |
| 6 | -import cn.idev.excel.annotation.ExcelIgnoreUnannotated; | |
| 7 | -import cn.idev.excel.annotation.ExcelProperty; | |
| 8 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 9 | 4 | import lombok.Data; |
| 10 | 5 | |
| ... | ... | @@ -12,36 +7,15 @@ import java.time.LocalDateTime; |
| 12 | 7 | |
| 13 | 8 | @Schema(description = "管理后台 - MES 假期设置 Response VO") |
| 14 | 9 | @Data |
| 15 | -@ExcelIgnoreUnannotated | |
| 16 | 10 | public class MesCalHolidayRespVO { |
| 17 | 11 | |
| 18 | - @Schema(description = "编号") | |
| 19 | - @ExcelProperty("编号") | |
| 20 | - private Long id; | |
| 21 | - | |
| 22 | 12 | @Schema(description = "日期") |
| 23 | - @ExcelProperty("日期") | |
| 24 | - private LocalDateTime theDay; | |
| 13 | + private LocalDateTime day; | |
| 25 | 14 | |
| 26 | 15 | @Schema(description = "日期类型") |
| 27 | - @ExcelProperty(value = "日期类型", converter = DictConvert.class) | |
| 28 | - @DictFormat(DictTypeConstants.MES_CAL_HOLIDAY_TYPE) | |
| 29 | - private String type; | |
| 30 | - | |
| 31 | - @Schema(description = "开始时间") | |
| 32 | - @ExcelProperty("开始时间") | |
| 33 | - private LocalDateTime startTime; | |
| 34 | - | |
| 35 | - @Schema(description = "结束时间") | |
| 36 | - @ExcelProperty("结束时间") | |
| 37 | - private LocalDateTime endTime; | |
| 16 | + private Integer type; | |
| 38 | 17 | |
| 39 | 18 | @Schema(description = "备注") |
| 40 | - @ExcelProperty("备注") | |
| 41 | 19 | private String remark; |
| 42 | 20 | |
| 43 | - @Schema(description = "创建时间") | |
| 44 | - @ExcelProperty("创建时间") | |
| 45 | - private LocalDateTime createTime; | |
| 46 | - | |
| 47 | 21 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/holiday/vo/MesCalHolidaySaveReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.controller.admin.cal.holiday.vo; |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | -import jakarta.validation.constraints.NotEmpty; | |
| 5 | 4 | import jakarta.validation.constraints.NotNull; |
| 6 | 5 | import lombok.Data; |
| 7 | 6 | |
| 8 | 7 | import java.time.LocalDateTime; |
| 9 | 8 | |
| 10 | -// TODO @AI:ktg 里,支持按照范围添加么?/cal/holiday 界面 | |
| 11 | 9 | @Schema(description = "管理后台 - MES 假期设置新增/修改 Request VO") |
| 12 | 10 | @Data |
| 13 | 11 | public class MesCalHolidaySaveReqVO { |
| ... | ... | @@ -17,17 +15,11 @@ public class MesCalHolidaySaveReqVO { |
| 17 | 15 | |
| 18 | 16 | @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED) |
| 19 | 17 | @NotNull(message = "日期不能为空") |
| 20 | - private LocalDateTime theDay; | |
| 18 | + private LocalDateTime day; | |
| 21 | 19 | |
| 22 | - @Schema(description = "日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "HOLIDAY") | |
| 23 | - @NotEmpty(message = "日期类型不能为空") | |
| 24 | - private String type; | |
| 25 | - | |
| 26 | - @Schema(description = "开始时间") | |
| 27 | - private LocalDateTime startTime; | |
| 28 | - | |
| 29 | - @Schema(description = "结束时间") | |
| 30 | - private LocalDateTime endTime; | |
| 20 | + @Schema(description = "日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 21 | + @NotNull(message = "日期类型不能为空") | |
| 22 | + private Integer type; | |
| 31 | 23 | |
| 32 | 24 | @Schema(description = "备注") |
| 33 | 25 | private String remark; | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/holiday/MesCalHolidayDO.java
| ... | ... | @@ -31,21 +31,13 @@ public class MesCalHolidayDO extends BaseDO { |
| 31 | 31 | /** |
| 32 | 32 | * 日期 |
| 33 | 33 | */ |
| 34 | - private LocalDateTime theDay; | |
| 34 | + private LocalDateTime day; | |
| 35 | 35 | /** |
| 36 | 36 | * 日期类型 |
| 37 | 37 | * |
| 38 | 38 | * 字典 {@link cn.iocoder.yudao.module.mes.enums.DictTypeConstants#MES_CAL_HOLIDAY_TYPE} |
| 39 | 39 | */ |
| 40 | - private String type; | |
| 41 | - /** | |
| 42 | - * 开始时间 | |
| 43 | - */ | |
| 44 | - private LocalDateTime startTime; | |
| 45 | - /** | |
| 46 | - * 结束时间 | |
| 47 | - */ | |
| 48 | - private LocalDateTime endTime; | |
| 40 | + private Integer type; | |
| 49 | 41 | /** |
| 50 | 42 | * 备注 |
| 51 | 43 | */ | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/holiday/MesCalHolidayMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.dal.mysql.cal.holiday; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 4 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.mes.controller.admin.cal.holiday.vo.MesCalHolidayPageReqVO; | |
| 7 | 5 | import cn.iocoder.yudao.module.mes.dal.dataobject.cal.holiday.MesCalHolidayDO; |
| 8 | 6 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 7 | |
| ... | ... | @@ -18,21 +16,13 @@ import java.util.List; |
| 18 | 16 | @Mapper |
| 19 | 17 | public interface MesCalHolidayMapper extends BaseMapperX<MesCalHolidayDO> { |
| 20 | 18 | |
| 21 | - default PageResult<MesCalHolidayDO> selectPage(MesCalHolidayPageReqVO reqVO) { | |
| 22 | - return selectPage(reqVO, new LambdaQueryWrapperX<MesCalHolidayDO>() | |
| 23 | - .eqIfPresent(MesCalHolidayDO::getType, reqVO.getType()) | |
| 24 | - .geIfPresent(MesCalHolidayDO::getTheDay, reqVO.getTheDayStart()) | |
| 25 | - .leIfPresent(MesCalHolidayDO::getTheDay, reqVO.getTheDayEnd()) | |
| 26 | - .orderByAsc(MesCalHolidayDO::getTheDay)); | |
| 27 | - } | |
| 28 | - | |
| 29 | - default MesCalHolidayDO selectByTheDay(LocalDateTime theDay) { | |
| 30 | - return selectOne(MesCalHolidayDO::getTheDay, theDay); | |
| 19 | + default MesCalHolidayDO selectByDay(LocalDateTime day) { | |
| 20 | + return selectOne(MesCalHolidayDO::getDay, day); | |
| 31 | 21 | } |
| 32 | 22 | |
| 33 | 23 | default List<MesCalHolidayDO> selectList() { |
| 34 | 24 | return selectList(new LambdaQueryWrapperX<MesCalHolidayDO>() |
| 35 | - .orderByAsc(MesCalHolidayDO::getTheDay)); | |
| 25 | + .orderByAsc(MesCalHolidayDO::getDay)); | |
| 36 | 26 | } |
| 37 | 27 | |
| 38 | 28 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java
| ... | ... | @@ -10,5 +10,7 @@ public interface DictTypeConstants { |
| 10 | 10 | String MES_CLIENT_TYPE = "mes_client_type"; // MES 客户类型 |
| 11 | 11 | String MES_VENDOR_LEVEL = "mes_vendor_level"; // MES 供应商级别 |
| 12 | 12 | String MES_CAL_HOLIDAY_TYPE = "mes_cal_holiday_type"; // MES 假期类型 |
| 13 | + String MES_TM_TOOL_STATUS = "mes_tm_tool_status"; // MES 工具状态 | |
| 14 | + String MES_TM_MAINTEN_TYPE = "mes_tm_mainten_type"; // MES 保养维护类型 | |
| 13 | 15 | |
| 14 | 16 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java
| ... | ... | @@ -107,9 +107,13 @@ public interface ErrorCodeConstants { |
| 107 | 107 | |
| 108 | 108 | // ========== MES 工具管理-工具类型(1-040-400-000) ========== |
| 109 | 109 | ErrorCode TM_TOOL_TYPE_NOT_EXISTS = new ErrorCode(1_040_400_000, "工具类型不存在"); |
| 110 | + ErrorCode TM_TOOL_TYPE_CODE_DUPLICATE = new ErrorCode(1_040_400_001, "工具类型编码已存在"); | |
| 111 | + ErrorCode TM_TOOL_TYPE_NAME_DUPLICATE = new ErrorCode(1_040_400_002, "工具类型名称已存在"); | |
| 112 | + ErrorCode TM_TOOL_TYPE_HAS_TOOL = new ErrorCode(1_040_400_003, "该工具类型下存在工具,无法删除"); | |
| 110 | 113 | |
| 111 | 114 | // ========== MES 工具管理-工具台账(1-040-401-000) ========== |
| 112 | 115 | ErrorCode TM_TOOL_NOT_EXISTS = new ErrorCode(1_040_401_000, "工具不存在"); |
| 116 | + ErrorCode TM_TOOL_CODE_DUPLICATE = new ErrorCode(1_040_401_001, "工具编码已存在"); | |
| 113 | 117 | |
| 114 | 118 | // ========== MES 生产管理-工序(1-040-500-000) ========== |
| 115 | 119 | ErrorCode PRO_PROCESS_NOT_EXISTS = new ErrorCode(1_040_500_000, "工序不存在"); | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/holiday/MesCalHolidayService.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.service.cal.holiday; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.module.mes.controller.admin.cal.holiday.vo.MesCalHolidayPageReqVO; | |
| 5 | 3 | import cn.iocoder.yudao.module.mes.controller.admin.cal.holiday.vo.MesCalHolidaySaveReqVO; |
| 6 | 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.cal.holiday.MesCalHolidayDO; |
| 7 | 5 | import jakarta.validation.Valid; |
| ... | ... | @@ -24,36 +22,6 @@ public interface MesCalHolidayService { |
| 24 | 22 | Long createHoliday(@Valid MesCalHolidaySaveReqVO createReqVO); |
| 25 | 23 | |
| 26 | 24 | /** |
| 27 | - * 更新假期设置 | |
| 28 | - * | |
| 29 | - * @param updateReqVO 更新信息 | |
| 30 | - */ | |
| 31 | - void updateHoliday(@Valid MesCalHolidaySaveReqVO updateReqVO); | |
| 32 | - | |
| 33 | - /** | |
| 34 | - * 删除假期设置 | |
| 35 | - * | |
| 36 | - * @param id 编号 | |
| 37 | - */ | |
| 38 | - void deleteHoliday(Long id); | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * 获得假期设置 | |
| 42 | - * | |
| 43 | - * @param id 编号 | |
| 44 | - * @return 假期设置 | |
| 45 | - */ | |
| 46 | - MesCalHolidayDO getHoliday(Long id); | |
| 47 | - | |
| 48 | - /** | |
| 49 | - * 获得假期设置分页 | |
| 50 | - * | |
| 51 | - * @param pageReqVO 分页查询 | |
| 52 | - * @return 假期设置分页 | |
| 53 | - */ | |
| 54 | - PageResult<MesCalHolidayDO> getHolidayPage(MesCalHolidayPageReqVO pageReqVO); | |
| 55 | - | |
| 56 | - /** | |
| 57 | 25 | * 获得所有假期设置列表(用于日历显示,不分页) |
| 58 | 26 | * |
| 59 | 27 | * @return 假期设置列表 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/holiday/MesCalHolidayServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.service.cal.holiday; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | 3 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | -import cn.iocoder.yudao.module.mes.controller.admin.cal.holiday.vo.MesCalHolidayPageReqVO; | |
| 6 | 4 | import cn.iocoder.yudao.module.mes.controller.admin.cal.holiday.vo.MesCalHolidaySaveReqVO; |
| 7 | 5 | import cn.iocoder.yudao.module.mes.dal.dataobject.cal.holiday.MesCalHolidayDO; |
| 8 | 6 | import cn.iocoder.yudao.module.mes.dal.mysql.cal.holiday.MesCalHolidayMapper; |
| ... | ... | @@ -12,9 +10,6 @@ import org.springframework.validation.annotation.Validated; |
| 12 | 10 | |
| 13 | 11 | import java.util.List; |
| 14 | 12 | |
| 15 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 16 | -import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.CAL_HOLIDAY_NOT_EXISTS; | |
| 17 | - | |
| 18 | 13 | /** |
| 19 | 14 | * MES 假期设置 Service 实现类 |
| 20 | 15 | * |
| ... | ... | @@ -28,55 +23,23 @@ public class MesCalHolidayServiceImpl implements MesCalHolidayService { |
| 28 | 23 | private MesCalHolidayMapper holidayMapper; |
| 29 | 24 | |
| 30 | 25 | @Override |
| 31 | - public Long createHoliday(MesCalHolidaySaveReqVO createReqVO) { | |
| 26 | + public Long saveHoliday(MesCalHolidaySaveReqVO saveReqVO) { | |
| 32 | 27 | // Upsert 逻辑:如果该日期已有记录,则更新 |
| 33 | - MesCalHolidayDO existing = holidayMapper.selectByTheDay(createReqVO.getTheDay()); | |
| 28 | + MesCalHolidayDO existing = holidayMapper.selectByDay(saveReqVO.getDay()); | |
| 34 | 29 | if (existing != null) { |
| 35 | - MesCalHolidayDO updateObj = BeanUtils.toBean(createReqVO, MesCalHolidayDO.class); | |
| 30 | + MesCalHolidayDO updateObj = BeanUtils.toBean(saveReqVO, MesCalHolidayDO.class); | |
| 36 | 31 | updateObj.setId(existing.getId()); |
| 37 | 32 | holidayMapper.updateById(updateObj); |
| 38 | 33 | return existing.getId(); |
| 39 | 34 | } |
| 35 | + | |
| 40 | 36 | // 插入新记录 |
| 41 | - MesCalHolidayDO holiday = BeanUtils.toBean(createReqVO, MesCalHolidayDO.class); | |
| 37 | + MesCalHolidayDO holiday = BeanUtils.toBean(saveReqVO, MesCalHolidayDO.class); | |
| 42 | 38 | holidayMapper.insert(holiday); |
| 43 | 39 | return holiday.getId(); |
| 44 | 40 | } |
| 45 | 41 | |
| 46 | 42 | @Override |
| 47 | - public void updateHoliday(MesCalHolidaySaveReqVO updateReqVO) { | |
| 48 | - // 校验存在 | |
| 49 | - validateHolidayExists(updateReqVO.getId()); | |
| 50 | - // 更新 | |
| 51 | - MesCalHolidayDO updateObj = BeanUtils.toBean(updateReqVO, MesCalHolidayDO.class); | |
| 52 | - holidayMapper.updateById(updateObj); | |
| 53 | - } | |
| 54 | - | |
| 55 | - @Override | |
| 56 | - public void deleteHoliday(Long id) { | |
| 57 | - // 校验存在 | |
| 58 | - validateHolidayExists(id); | |
| 59 | - // 删除 | |
| 60 | - holidayMapper.deleteById(id); | |
| 61 | - } | |
| 62 | - | |
| 63 | - private void validateHolidayExists(Long id) { | |
| 64 | - if (holidayMapper.selectById(id) == null) { | |
| 65 | - throw exception(CAL_HOLIDAY_NOT_EXISTS); | |
| 66 | - } | |
| 67 | - } | |
| 68 | - | |
| 69 | - @Override | |
| 70 | - public MesCalHolidayDO getHoliday(Long id) { | |
| 71 | - return holidayMapper.selectById(id); | |
| 72 | - } | |
| 73 | - | |
| 74 | - @Override | |
| 75 | - public PageResult<MesCalHolidayDO> getHolidayPage(MesCalHolidayPageReqVO pageReqVO) { | |
| 76 | - return holidayMapper.selectPage(pageReqVO); | |
| 77 | - } | |
| 78 | - | |
| 79 | - @Override | |
| 80 | 43 | public List<MesCalHolidayDO> getHolidayList() { |
| 81 | 44 | return holidayMapper.selectList(); |
| 82 | 45 | } | ... | ... |