From 66489db865164715cda45b48c643ff15b30cce37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E4=B9=85=E5=93=A5?= <787952492@qq.com> Date: Mon, 30 May 2022 19:22:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/farm/enums/ErrorCodeConstants.java | 2 +- .../admin/workHour/WorkHourController.java | 100 ++++++++++++++++++ .../admin/workHour/vo/WorkHourBaseVO.java | 28 +++++ .../workHour/vo/WorkHourCreateReqVO.java | 14 +++ .../admin/workHour/vo/WorkHourExcelVO.java | 35 ++++++ .../workHour/vo/WorkHourExportReqVO.java | 35 ++++++ .../admin/workHour/vo/WorkHourPageReqVO.java | 37 +++++++ .../admin/workHour/vo/WorkHourRespVO.java | 19 ++++ .../workHour/vo/WorkHourUpdateReqVO.java | 18 ++++ .../convert/workHour/WorkHourConvert.java | 34 ++++++ .../dal/dataobject/workHour/WorkHourDO.java | 44 ++++++++ .../dal/mysql/workHour/WorkHourMapper.java | 40 +++++++ .../service/workHour/WorkHourService.java | 70 ++++++++++++ .../service/workHour/WorkHourServiceImpl.java | 82 ++++++++++++++ .../mapper/workHour/WorkHourMapper.xml | 12 +++ 15 files changed, 569 insertions(+), 1 deletion(-) create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/WorkHourController.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourBaseVO.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourCreateReqVO.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourExcelVO.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourExportReqVO.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourPageReqVO.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourRespVO.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourUpdateReqVO.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/convert/workHour/WorkHourConvert.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/workHour/WorkHourDO.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/workHour/WorkHourMapper.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/workHour/WorkHourService.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/workHour/WorkHourServiceImpl.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/resources/mapper/workHour/WorkHourMapper.xml diff --git a/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java b/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java index a0f44473..f253d69f 100644 --- a/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java +++ b/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java @@ -23,7 +23,7 @@ public interface ErrorCodeConstants{ ErrorCode CROP_RECORD_NOT_EXISTS = new ErrorCode(1000007009, "农场作物出入记录不存在"); - + ErrorCode WORK_HOUR_NOT_EXISTS = new ErrorCode(1000007010, "工时不存在"); } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/WorkHourController.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/WorkHourController.java new file mode 100644 index 00000000..f383cff4 --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/WorkHourController.java @@ -0,0 +1,100 @@ +package cn.iocoder.yudao.module.farm.controller.admin.workHour; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.annotations.*; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.farm.controller.admin.workHour.vo.*; +import cn.iocoder.yudao.module.farm.dal.dataobject.workHour.WorkHourDO; +import cn.iocoder.yudao.module.farm.convert.workHour.WorkHourConvert; +import cn.iocoder.yudao.module.farm.service.workHour.WorkHourService; + +@Api(tags = "管理后台 - ") +@RestController +@RequestMapping("/farm/work-hour") +@Validated +public class WorkHourController { + + @Resource + private WorkHourService workHourService; + + @PostMapping("/create") + @ApiOperation("创建") + @PreAuthorize("@ss.hasPermission('farm:work-hour:create')") + public CommonResult createWorkHour(@Valid @RequestBody WorkHourCreateReqVO createReqVO) { + return success(workHourService.createWorkHour(createReqVO)); + } + + @PutMapping("/update") + @ApiOperation("更新") + @PreAuthorize("@ss.hasPermission('farm:work-hour:update')") + public CommonResult updateWorkHour(@Valid @RequestBody WorkHourUpdateReqVO updateReqVO) { + workHourService.updateWorkHour(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @ApiOperation("删除") + @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) + @PreAuthorize("@ss.hasPermission('farm:work-hour:delete')") + public CommonResult deleteWorkHour(@RequestParam("id") Long id) { + workHourService.deleteWorkHour(id); + return success(true); + } + + @GetMapping("/get") + @ApiOperation("获得") + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) + @PreAuthorize("@ss.hasPermission('farm:work-hour:query')") + public CommonResult getWorkHour(@RequestParam("id") Long id) { + WorkHourDO workHour = workHourService.getWorkHour(id); + return success(WorkHourConvert.INSTANCE.convert(workHour)); + } + + @GetMapping("/list") + @ApiOperation("获得列表") + @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) + @PreAuthorize("@ss.hasPermission('farm:work-hour:query')") + public CommonResult> getWorkHourList(@RequestParam("ids") Collection ids) { + List list = workHourService.getWorkHourList(ids); + return success(WorkHourConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @ApiOperation("获得分页") + @PreAuthorize("@ss.hasPermission('farm:work-hour:query')") + public CommonResult> getWorkHourPage(@Valid WorkHourPageReqVO pageVO) { + PageResult pageResult = workHourService.getWorkHourPage(pageVO); + return success(WorkHourConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @ApiOperation("导出 Excel") + @PreAuthorize("@ss.hasPermission('farm:work-hour:export')") + @OperateLog(type = EXPORT) + public void exportWorkHourExcel(@Valid WorkHourExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = workHourService.getWorkHourList(exportReqVO); + // 导出 Excel + List datas = WorkHourConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, ".xls", "数据", WorkHourExcelVO.class, datas); + } + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourBaseVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourBaseVO.java new file mode 100644 index 00000000..91fead14 --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourBaseVO.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.farm.controller.admin.workHour.vo; + +import lombok.*; +import java.util.*; +import io.swagger.annotations.*; +import javax.validation.constraints.*; + +/** +* Base VO,提供给添加、修改、详细的子 VO 使用 +* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 +*/ +@Data +public class WorkHourBaseVO { + + @ApiModelProperty(value = "") + private Integer userId; + + @ApiModelProperty(value = "") + private Integer projectId; + + @ApiModelProperty(value = "") + private Integer taskId; + + @ApiModelProperty(value = "", required = true) + @NotNull(message = "不能为空") + private Integer hour; + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourCreateReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourCreateReqVO.java new file mode 100644 index 00000000..1d5af436 --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.farm.controller.admin.workHour.vo; + +import lombok.*; +import java.util.*; +import io.swagger.annotations.*; +import javax.validation.constraints.*; + +@ApiModel("管理后台 - 创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class WorkHourCreateReqVO extends WorkHourBaseVO { + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourExcelVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourExcelVO.java new file mode 100644 index 00000000..2bfc13be --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourExcelVO.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.farm.controller.admin.workHour.vo; + +import lombok.*; +import java.util.*; +import io.swagger.annotations.*; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * Excel VO + * + * @author 吴蓉 + */ +@Data +public class WorkHourExcelVO { + + @ExcelProperty("") + private Long id; + + @ExcelProperty("") + private Integer userId; + + @ExcelProperty("") + private Integer projectId; + + @ExcelProperty("") + private Integer taskId; + + @ExcelProperty("") + private Integer hour; + + @ExcelProperty("") + private Date createTime; + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourExportReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourExportReqVO.java new file mode 100644 index 00000000..b300e8cc --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourExportReqVO.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.farm.controller.admin.workHour.vo; + +import lombok.*; +import java.util.*; +import io.swagger.annotations.*; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@ApiModel(value = "管理后台 - Excel 导出 Request VO", description = "参数和 WorkHourPageReqVO 是一致的") +@Data +public class WorkHourExportReqVO { + + @ApiModelProperty(value = "") + private Integer userId; + + @ApiModelProperty(value = "") + private Integer projectId; + + @ApiModelProperty(value = "") + private Integer taskId; + + @ApiModelProperty(value = "") + private Integer hour; + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @ApiModelProperty(value = "开始") + private Date beginCreateTime; + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @ApiModelProperty(value = "结束") + private Date endCreateTime; + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourPageReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourPageReqVO.java new file mode 100644 index 00000000..f618f450 --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourPageReqVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.farm.controller.admin.workHour.vo; + +import lombok.*; +import java.util.*; +import io.swagger.annotations.*; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@ApiModel("管理后台 - 分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class WorkHourPageReqVO extends PageParam { + + @ApiModelProperty(value = "") + private Integer userId; + + @ApiModelProperty(value = "") + private Integer projectId; + + @ApiModelProperty(value = "") + private Integer taskId; + + @ApiModelProperty(value = "") + private Integer hour; + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @ApiModelProperty(value = "开始") + private Date beginCreateTime; + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @ApiModelProperty(value = "结束") + private Date endCreateTime; + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourRespVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourRespVO.java new file mode 100644 index 00000000..c9ff333b --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.farm.controller.admin.workHour.vo; + +import lombok.*; +import java.util.*; +import io.swagger.annotations.*; + +@ApiModel("管理后台 - Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class WorkHourRespVO extends WorkHourBaseVO { + + @ApiModelProperty(value = "", required = true) + private Long id; + + @ApiModelProperty(value = "") + private Date createTime; + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourUpdateReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourUpdateReqVO.java new file mode 100644 index 00000000..a6c63832 --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.farm.controller.admin.workHour.vo; + +import lombok.*; +import java.util.*; +import io.swagger.annotations.*; +import javax.validation.constraints.*; + +@ApiModel("管理后台 - 更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class WorkHourUpdateReqVO extends WorkHourBaseVO { + + @ApiModelProperty(value = "", required = true) + @NotNull(message = "不能为空") + private Long id; + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/convert/workHour/WorkHourConvert.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/convert/workHour/WorkHourConvert.java new file mode 100644 index 00000000..d6dced88 --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/convert/workHour/WorkHourConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.farm.convert.workHour; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.farm.controller.admin.workHour.vo.*; +import cn.iocoder.yudao.module.farm.dal.dataobject.workHour.WorkHourDO; + +/** + * Convert + * + * @author 吴蓉 + */ +@Mapper +public interface WorkHourConvert { + + WorkHourConvert INSTANCE = Mappers.getMapper(WorkHourConvert.class); + + WorkHourDO convert(WorkHourCreateReqVO bean); + + WorkHourDO convert(WorkHourUpdateReqVO bean); + + WorkHourRespVO convert(WorkHourDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/workHour/WorkHourDO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/workHour/WorkHourDO.java new file mode 100644 index 00000000..d455340c --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/workHour/WorkHourDO.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.module.farm.dal.dataobject.workHour; + +import lombok.*; +import java.util.*; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * DO + * + * @author 吴蓉 + */ +@TableName("farm_work_hour") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WorkHourDO extends BaseDO { + + /** + * + */ + @TableId + private Long id; + /** + * + */ + private Integer userId; + /** + * + */ + private Integer projectId; + /** + * + */ + private Integer taskId; + /** + * + */ + private Integer hour; + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/workHour/WorkHourMapper.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/workHour/WorkHourMapper.java new file mode 100644 index 00000000..f20bf4f5 --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/workHour/WorkHourMapper.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.farm.dal.mysql.workHour; + +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.farm.dal.dataobject.workHour.WorkHourDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.farm.controller.admin.workHour.vo.*; + +/** + * Mapper + * + * @author 吴蓉 + */ +@Mapper +public interface WorkHourMapper extends BaseMapperX { + + default PageResult selectPage(WorkHourPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(WorkHourDO::getUserId, reqVO.getUserId()) + .eqIfPresent(WorkHourDO::getProjectId, reqVO.getProjectId()) + .eqIfPresent(WorkHourDO::getTaskId, reqVO.getTaskId()) + .eqIfPresent(WorkHourDO::getHour, reqVO.getHour()) + .betweenIfPresent(WorkHourDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) + .orderByDesc(WorkHourDO::getId)); + } + + default List selectList(WorkHourExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(WorkHourDO::getUserId, reqVO.getUserId()) + .eqIfPresent(WorkHourDO::getProjectId, reqVO.getProjectId()) + .eqIfPresent(WorkHourDO::getTaskId, reqVO.getTaskId()) + .eqIfPresent(WorkHourDO::getHour, reqVO.getHour()) + .betweenIfPresent(WorkHourDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) + .orderByDesc(WorkHourDO::getId)); + } + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/workHour/WorkHourService.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/workHour/WorkHourService.java new file mode 100644 index 00000000..e6a6b14a --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/workHour/WorkHourService.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.farm.service.workHour; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.farm.controller.admin.workHour.vo.*; +import cn.iocoder.yudao.module.farm.dal.dataobject.workHour.WorkHourDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * Service 接口 + * + * @author 吴蓉 + */ +public interface WorkHourService { + + /** + * 创建 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createWorkHour(@Valid WorkHourCreateReqVO createReqVO); + + /** + * 更新 + * + * @param updateReqVO 更新信息 + */ + void updateWorkHour(@Valid WorkHourUpdateReqVO updateReqVO); + + /** + * 删除 + * + * @param id 编号 + */ + void deleteWorkHour(Long id); + + /** + * 获得 + * + * @param id 编号 + * @return + */ + WorkHourDO getWorkHour(Long id); + + /** + * 获得列表 + * + * @param ids 编号 + * @return 列表 + */ + List getWorkHourList(Collection ids); + + /** + * 获得分页 + * + * @param pageReqVO 分页查询 + * @return 分页 + */ + PageResult getWorkHourPage(WorkHourPageReqVO pageReqVO); + + /** + * 获得列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 列表 + */ + List getWorkHourList(WorkHourExportReqVO exportReqVO); + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/workHour/WorkHourServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/workHour/WorkHourServiceImpl.java new file mode 100644 index 00000000..4eea0e12 --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/workHour/WorkHourServiceImpl.java @@ -0,0 +1,82 @@ +package cn.iocoder.yudao.module.farm.service.workHour; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import cn.iocoder.yudao.module.farm.controller.admin.workHour.vo.*; +import cn.iocoder.yudao.module.farm.dal.dataobject.workHour.WorkHourDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.farm.convert.workHour.WorkHourConvert; +import cn.iocoder.yudao.module.farm.dal.mysql.workHour.WorkHourMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*; + +/** + * Service 实现类 + * + * @author 吴蓉 + */ +@Service +@Validated +public class WorkHourServiceImpl implements WorkHourService { + + @Resource + private WorkHourMapper workHourMapper; + + @Override + public Long createWorkHour(WorkHourCreateReqVO createReqVO) { + // 插入 + WorkHourDO workHour = WorkHourConvert.INSTANCE.convert(createReqVO); + workHourMapper.insert(workHour); + // 返回 + return workHour.getId(); + } + + @Override + public void updateWorkHour(WorkHourUpdateReqVO updateReqVO) { + // 校验存在 + this.validateWorkHourExists(updateReqVO.getId()); + // 更新 + WorkHourDO updateObj = WorkHourConvert.INSTANCE.convert(updateReqVO); + workHourMapper.updateById(updateObj); + } + + @Override + public void deleteWorkHour(Long id) { + // 校验存在 + this.validateWorkHourExists(id); + // 删除 + workHourMapper.deleteById(id); + } + + private void validateWorkHourExists(Long id) { + if (workHourMapper.selectById(id) == null) { + throw exception(WORK_HOUR_NOT_EXISTS); + } + } + + @Override + public WorkHourDO getWorkHour(Long id) { + return workHourMapper.selectById(id); + } + + @Override + public List getWorkHourList(Collection ids) { + return workHourMapper.selectBatchIds(ids); + } + + @Override + public PageResult getWorkHourPage(WorkHourPageReqVO pageReqVO) { + return workHourMapper.selectPage(pageReqVO); + } + + @Override + public List getWorkHourList(WorkHourExportReqVO exportReqVO) { + return workHourMapper.selectList(exportReqVO); + } + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/resources/mapper/workHour/WorkHourMapper.xml b/zsw-farm/zsw-farm-impl/src/main/resources/mapper/workHour/WorkHourMapper.xml new file mode 100644 index 00000000..ad8c6db8 --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/resources/mapper/workHour/WorkHourMapper.xml @@ -0,0 +1,12 @@ + + + + + + +