Compare commits
No commits in common. "e1e37657f0868505d8db7bc8cd3fec872f414b80" and "100022251e85ee48cf4ed5336f7514eb288ce11e" have entirely different histories.
e1e37657f0
...
100022251e
@ -44,7 +44,5 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode ITEMS_NOT_EXISTS = new ErrorCode(1_011_016_000,"办公用品管理不存在");
|
||||
// ========== 工作日历数据 1_011_017_000 ==========
|
||||
ErrorCode CALENDAR_NOT_EXISTS = new ErrorCode(1_011_017_000, "工作日历数据不存在");
|
||||
// ========== 年假管理 1_011_018_000 ==========
|
||||
ErrorCode NJGL_NOT_EXISTS = new ErrorCode(1_011_018_000, "年假管理不存在");
|
||||
|
||||
}
|
||||
|
@ -1,94 +0,0 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.njgl;
|
||||
|
||||
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.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.*;
|
||||
import javax.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.home.controller.admin.njgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.njgl.NjglDO;
|
||||
import cn.iocoder.yudao.module.home.service.njgl.NjglService;
|
||||
|
||||
@Tag(name = "管理后台 - 年假管理")
|
||||
@RestController
|
||||
@RequestMapping("/home/njgl")
|
||||
@Validated
|
||||
public class NjglController {
|
||||
|
||||
@Resource
|
||||
private NjglService njglService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建年假管理")
|
||||
@PreAuthorize("@ss.hasPermission('home:njgl:create')")
|
||||
public CommonResult<Long> createNjgl(@Valid @RequestBody NjglSaveReqVO createReqVO) {
|
||||
return success(njglService.createNjgl(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新年假管理")
|
||||
@PreAuthorize("@ss.hasPermission('home:njgl:update')")
|
||||
public CommonResult<Boolean> updateNjgl(@Valid @RequestBody NjglSaveReqVO updateReqVO) {
|
||||
njglService.updateNjgl(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除年假管理")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('home:njgl:delete')")
|
||||
public CommonResult<Boolean> deleteNjgl(@RequestParam("id") Long id) {
|
||||
njglService.deleteNjgl(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得年假管理")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('home:njgl:query')")
|
||||
public CommonResult<NjglRespVO> getNjgl(@RequestParam("id") Long id) {
|
||||
NjglDO njgl = njglService.getNjgl(id);
|
||||
return success(BeanUtils.toBean(njgl, NjglRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得年假管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('home:njgl:query')")
|
||||
public CommonResult<PageResult<NjglRespVO>> getNjglPage(@Valid NjglPageReqVO pageReqVO) {
|
||||
PageResult<NjglDO> pageResult = njglService.getNjglPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, NjglRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出年假管理 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('home:njgl:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportNjglExcel(@Valid NjglPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<NjglDO> list = njglService.getNjglPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "年假管理.xls", "数据", NjglRespVO.class,
|
||||
BeanUtils.toBean(list, NjglRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.njgl.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 NjglPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "id", example = "4820")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "员工名字", example = "赵六")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "员工id", example = "16826")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "部门名字", example = "张三")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "数据年份", example = "张三")
|
||||
private String year;
|
||||
|
||||
@Schema(description = "部门id", example = "14416")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "年假总天数")
|
||||
private Integer annualDays;
|
||||
|
||||
@Schema(description = "已用年假天数")
|
||||
private Integer usedDays;
|
||||
|
||||
@Schema(description = "剩余年假天数")
|
||||
private Integer remainingDays;
|
||||
|
||||
@Schema(description = "年假开始日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] startDate;
|
||||
|
||||
@Schema(description = "年假结束日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] endDate;
|
||||
|
||||
@Schema(description = "是否锁定年假信息", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否启用年假数据", example = "1")
|
||||
private Integer dataStatus;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.njgl.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.*;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
|
||||
@Schema(description = "管理后台 - 年假管理 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class NjglRespVO {
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "4820")
|
||||
@ExcelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "员工名字", example = "赵六")
|
||||
@ExcelProperty("员工名字")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "员工id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16826")
|
||||
@ExcelProperty("员工id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "部门名字", example = "张三")
|
||||
@ExcelProperty("部门名字")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "数据年份", example = "张三")
|
||||
@ExcelProperty("数据年份")
|
||||
private String year;
|
||||
|
||||
@Schema(description = "部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "14416")
|
||||
@ExcelProperty("部门id")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "年假总天数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("年假总天数")
|
||||
private Integer annualDays;
|
||||
|
||||
@Schema(description = "已用年假天数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("已用年假天数")
|
||||
private Integer usedDays;
|
||||
|
||||
@Schema(description = "剩余年假天数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("剩余年假天数")
|
||||
private Integer remainingDays;
|
||||
|
||||
@Schema(description = "年假开始日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("年假开始日期")
|
||||
private LocalDateTime startDate;
|
||||
|
||||
@Schema(description = "年假结束日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("年假结束日期")
|
||||
private LocalDateTime endDate;
|
||||
|
||||
@Schema(description = "是否锁定年假信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "是否锁定年假信息", converter = DictConvert.class)
|
||||
@DictFormat("njgl_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否启用年假数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "是否启用年假信息", converter = DictConvert.class)
|
||||
@DictFormat("njgl_data_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer dataStatus;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.njgl.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 年假管理新增/修改 Request VO")
|
||||
@Data
|
||||
public class NjglSaveReqVO {
|
||||
|
||||
@AssertTrue(message = "开始时间,需要在结束时间之后")
|
||||
public boolean isEndTimeValid() {
|
||||
return !getEndDate().isBefore(getStartDate());
|
||||
}
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "4820")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "员工名字", example = "赵六")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "员工id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16826")
|
||||
@NotNull(message = "员工id不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "部门名字", example = "张三")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "数据年份", example = "张三")
|
||||
private String year;
|
||||
|
||||
@Schema(description = "部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "14416")
|
||||
@NotNull(message = "部门id不能为空")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "年假总天数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "年假总天数不能为空")
|
||||
private Integer annualDays;
|
||||
|
||||
@Schema(description = "已用年假天数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "已用年假天数不能为空")
|
||||
private Integer usedDays;
|
||||
|
||||
@Schema(description = "剩余年假天数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "剩余年假天数不能为空")
|
||||
private Integer remainingDays;
|
||||
|
||||
@Schema(description = "年假开始日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "年假开始日期不能为空")
|
||||
private LocalDateTime startDate;
|
||||
|
||||
@Schema(description = "年假结束日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "年假结束日期不能为空")
|
||||
private LocalDateTime endDate;
|
||||
|
||||
@Schema(description = "是否锁定年假信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "是否锁定年假信息不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否启用年假信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "是否启用年假信息不能为空")
|
||||
private Integer dataStatus;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
package cn.iocoder.yudao.module.home.dal.dataobject.njgl;
|
||||
|
||||
import com.sun.xml.bind.v2.TODO;
|
||||
import lombok.*;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 年假管理 DO
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@TableName("oa_njgl")
|
||||
@KeySequence("oa_njgl_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class NjglDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 数据状态
|
||||
*/
|
||||
private Integer dataStatus;
|
||||
/**
|
||||
* 员工名字
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 数据年份
|
||||
*/
|
||||
private String year;
|
||||
/**
|
||||
* 员工id
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 部门名字
|
||||
*/
|
||||
private String deptName;
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
private Long deptId;
|
||||
/**
|
||||
* 年假总天数
|
||||
*/
|
||||
private Integer annualDays;
|
||||
/**
|
||||
* 已用年假天数
|
||||
*/
|
||||
private Integer usedDays;
|
||||
/**
|
||||
* 剩余年假天数
|
||||
*/
|
||||
private Integer remainingDays;
|
||||
/**
|
||||
* 年假开始日期
|
||||
*/
|
||||
private LocalDateTime startDate;
|
||||
/**
|
||||
* 年假结束日期
|
||||
*/
|
||||
private LocalDateTime endDate;
|
||||
/**
|
||||
* 是否锁定年假信息
|
||||
*
|
||||
* 枚举 {@link TODO njgl_status 对应的类}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package cn.iocoder.yudao.module.home.dal.mysql.njgl;
|
||||
|
||||
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.home.dal.dataobject.njgl.NjglDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.home.controller.admin.njgl.vo.*;
|
||||
|
||||
/**
|
||||
* 年假管理 Mapper
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Mapper
|
||||
public interface NjglMapper extends BaseMapperX<NjglDO> {
|
||||
|
||||
default PageResult<NjglDO> selectPage(NjglPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<NjglDO>()
|
||||
.eqIfPresent(NjglDO::getId, reqVO.getId())
|
||||
.likeIfPresent(NjglDO::getUserName, reqVO.getUserName())
|
||||
.eqIfPresent(NjglDO::getUserId, reqVO.getUserId())
|
||||
.likeIfPresent(NjglDO::getDeptName, reqVO.getDeptName())
|
||||
.likeIfPresent(NjglDO::getYear, reqVO.getYear())
|
||||
.eqIfPresent(NjglDO::getDeptId, reqVO.getDeptId())
|
||||
.eqIfPresent(NjglDO::getAnnualDays, reqVO.getAnnualDays())
|
||||
.eqIfPresent(NjglDO::getUsedDays, reqVO.getUsedDays())
|
||||
.eqIfPresent(NjglDO::getRemainingDays, reqVO.getRemainingDays())
|
||||
.betweenIfPresent(NjglDO::getStartDate, reqVO.getStartDate())
|
||||
.betweenIfPresent(NjglDO::getEndDate, reqVO.getEndDate())
|
||||
.eqIfPresent(NjglDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(NjglDO::getDataStatus, reqVO.getDataStatus())
|
||||
.eqIfPresent(NjglDO::getRemark, reqVO.getRemark())
|
||||
.betweenIfPresent(NjglDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(NjglDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package cn.iocoder.yudao.module.home.service.njgl;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.home.controller.admin.njgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.njgl.NjglDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 年假管理 Service 接口
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
public interface NjglService {
|
||||
/**
|
||||
* 创建年假管理
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createNjgl(@Valid NjglSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新年假管理
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateNjgl(@Valid NjglSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除年假管理
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteNjgl(Long id);
|
||||
|
||||
/**
|
||||
* 获得年假管理
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 年假管理
|
||||
*/
|
||||
NjglDO getNjgl(Long id);
|
||||
|
||||
/**
|
||||
* 获得年假管理分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 年假管理分页
|
||||
*/
|
||||
PageResult<NjglDO> getNjglPage(NjglPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -1,169 +0,0 @@
|
||||
package cn.iocoder.yudao.module.home.service.njgl;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
|
||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.home.controller.admin.njgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.njgl.NjglDO;
|
||||
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.home.dal.mysql.njgl.NjglMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.module.home.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 年假管理 Service 实现类
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class NjglServiceImpl implements NjglService {
|
||||
|
||||
@Resource
|
||||
private NjglMapper njglMapper;
|
||||
@Resource
|
||||
private DeptService deptService;
|
||||
@Resource
|
||||
private AdminUserMapper userMapper;
|
||||
|
||||
/**
|
||||
* 获得用户列表后生成所有员工年假数据
|
||||
*/
|
||||
public void getUserList() {
|
||||
|
||||
//创建pageVo设置size-1
|
||||
UserPageReqVO userPageReqVO = new UserPageReqVO();
|
||||
userPageReqVO.setPageSize(-1);
|
||||
//获取全部成员列表
|
||||
List<AdminUserDO> userList = getUserPage(userPageReqVO).getList();
|
||||
createdNjData(userList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建年假数据
|
||||
* @param userList
|
||||
*/
|
||||
private void createdNjData(List<AdminUserDO> userList) {
|
||||
//创建saveVo对象,固定资源固定创建
|
||||
NjglSaveReqVO createReqVO = new NjglSaveReqVO();
|
||||
int date = LocalDateTime.now().getYear()-1;
|
||||
|
||||
createReqVO.setAnnualDays(10);
|
||||
createReqVO.setUsedDays(0);
|
||||
createReqVO.setRemainingDays(10);
|
||||
createReqVO.setYear(String.valueOf(date));
|
||||
createReqVO.setDataStatus(1);
|
||||
createReqVO.setStatus(1);
|
||||
createReqVO.setStartDate(LocalDateTime.now());
|
||||
createReqVO.setEndDate(LocalDateTime.now());
|
||||
createReqVO.setRemark("备注");
|
||||
|
||||
//创建NjglDo对象列表储存所有创建的年假对象
|
||||
List<NjglDO> njglList = new ArrayList<>();
|
||||
|
||||
//循环创建对象储存在njglList
|
||||
for (AdminUserDO adminUserDO : userList) {
|
||||
|
||||
DeptDO deptDO = deptService.getDept(adminUserDO.getDeptId());
|
||||
|
||||
if (deptDO != null) {
|
||||
createReqVO.setUserName(adminUserDO.getNickname());
|
||||
createReqVO.setUserId(adminUserDO.getId());
|
||||
createReqVO.setDeptId(adminUserDO.getDeptId());
|
||||
createReqVO.setDeptName(deptDO.getName());
|
||||
|
||||
// 转换为 NjglDO 对象并加入到批量列表
|
||||
NjglDO njgl = BeanUtils.toBean(createReqVO, NjglDO.class);
|
||||
njglList.add(njgl);
|
||||
}
|
||||
|
||||
}
|
||||
// 批量插入数据更快
|
||||
if (!njglList.isEmpty()) {
|
||||
njglMapper.insertBatch(njglList); // 假设有批量插入方法
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public PageResult<AdminUserDO> getUserPage(UserPageReqVO reqVO) {
|
||||
return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得部门条件:查询指定部门的子部门编号们,包括自身
|
||||
* @param deptId 部门编号
|
||||
* @return 部门编号集合
|
||||
*/
|
||||
private Set<Long> getDeptCondition(Long deptId) {
|
||||
if (deptId == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
Set<Long> deptIds = convertSet(deptService.getChildDeptList(deptId), DeptDO::getId);
|
||||
deptIds.add(deptId); // 包括自身
|
||||
return deptIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createNjgl(NjglSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
NjglDO njgl = BeanUtils.toBean(createReqVO, NjglDO.class);
|
||||
njglMapper.insert(njgl);
|
||||
// 返回
|
||||
return njgl.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNjgl(NjglSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateNjglExists(updateReqVO.getId());
|
||||
// 更新
|
||||
NjglDO updateObj = BeanUtils.toBean(updateReqVO, NjglDO.class);
|
||||
njglMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteNjgl(Long id) {
|
||||
// 校验存在
|
||||
validateNjglExists(id);
|
||||
// 删除
|
||||
njglMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateNjglExists(Long id) {
|
||||
if (njglMapper.selectById(id) == null) {
|
||||
throw exception(NJGL_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NjglDO getNjgl(Long id) {
|
||||
return njglMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<NjglDO> getNjglPage(NjglPageReqVO pageReqVO) {
|
||||
// getUserList();
|
||||
return njglMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
<?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.home.dal.mysql.njgl.NjglMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -1,178 +0,0 @@
|
||||
package cn.iocoder.yudao.module.home.service.njgl;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.iocoder.yudao.module.home.controller.admin.njgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.njgl.NjglDO;
|
||||
import cn.iocoder.yudao.module.home.dal.mysql.njgl.NjglMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.iocoder.yudao.module.home.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link NjglServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Import(NjglServiceImpl.class)
|
||||
public class NjglServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private NjglServiceImpl njglService;
|
||||
|
||||
@Resource
|
||||
private NjglMapper njglMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateNjgl_success() {
|
||||
// 准备参数
|
||||
NjglSaveReqVO createReqVO = randomPojo(NjglSaveReqVO.class).setId(null);
|
||||
|
||||
// 调用
|
||||
Long njglId = njglService.createNjgl(createReqVO);
|
||||
// 断言
|
||||
assertNotNull(njglId);
|
||||
// 校验记录的属性是否正确
|
||||
NjglDO njgl = njglMapper.selectById(njglId);
|
||||
assertPojoEquals(createReqVO, njgl, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateNjgl_success() {
|
||||
// mock 数据
|
||||
NjglDO dbNjgl = randomPojo(NjglDO.class);
|
||||
njglMapper.insert(dbNjgl);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
NjglSaveReqVO updateReqVO = randomPojo(NjglSaveReqVO.class, o -> {
|
||||
o.setId(dbNjgl.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
njglService.updateNjgl(updateReqVO);
|
||||
// 校验是否更新正确
|
||||
NjglDO njgl = njglMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(updateReqVO, njgl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateNjgl_notExists() {
|
||||
// 准备参数
|
||||
NjglSaveReqVO updateReqVO = randomPojo(NjglSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> njglService.updateNjgl(updateReqVO), NJGL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteNjgl_success() {
|
||||
// mock 数据
|
||||
NjglDO dbNjgl = randomPojo(NjglDO.class);
|
||||
njglMapper.insert(dbNjgl);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbNjgl.getId();
|
||||
|
||||
// 调用
|
||||
njglService.deleteNjgl(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(njglMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteNjgl_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> njglService.deleteNjgl(id), NJGL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetNjglPage() {
|
||||
// mock 数据
|
||||
NjglDO dbNjgl = randomPojo(NjglDO.class, o -> { // 等会查询到
|
||||
o.setId(null);
|
||||
o.setUserName(null);
|
||||
o.setUserId(null);
|
||||
o.setDeptName(null);
|
||||
o.setDeptId(null);
|
||||
o.setAnnualDays(null);
|
||||
o.setUsedDays(null);
|
||||
o.setRemainingDays(null);
|
||||
o.setStartDate(null);
|
||||
o.setEndDate(null);
|
||||
o.setStatus(null);
|
||||
o.setRemark(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
njglMapper.insert(dbNjgl);
|
||||
// 测试 id 不匹配
|
||||
njglMapper.insert(cloneIgnoreId(dbNjgl, o -> o.setId(null)));
|
||||
// 测试 userName 不匹配
|
||||
njglMapper.insert(cloneIgnoreId(dbNjgl, o -> o.setUserName(null)));
|
||||
// 测试 userId 不匹配
|
||||
njglMapper.insert(cloneIgnoreId(dbNjgl, o -> o.setUserId(null)));
|
||||
// 测试 deptName 不匹配
|
||||
njglMapper.insert(cloneIgnoreId(dbNjgl, o -> o.setDeptName(null)));
|
||||
// 测试 deptId 不匹配
|
||||
njglMapper.insert(cloneIgnoreId(dbNjgl, o -> o.setDeptId(null)));
|
||||
// 测试 annualDays 不匹配
|
||||
njglMapper.insert(cloneIgnoreId(dbNjgl, o -> o.setAnnualDays(null)));
|
||||
// 测试 usedDays 不匹配
|
||||
njglMapper.insert(cloneIgnoreId(dbNjgl, o -> o.setUsedDays(null)));
|
||||
// 测试 remainingDays 不匹配
|
||||
njglMapper.insert(cloneIgnoreId(dbNjgl, o -> o.setRemainingDays(null)));
|
||||
// 测试 startDate 不匹配
|
||||
njglMapper.insert(cloneIgnoreId(dbNjgl, o -> o.setStartDate(null)));
|
||||
// 测试 endDate 不匹配
|
||||
njglMapper.insert(cloneIgnoreId(dbNjgl, o -> o.setEndDate(null)));
|
||||
// 测试 status 不匹配
|
||||
njglMapper.insert(cloneIgnoreId(dbNjgl, o -> o.setStatus(null)));
|
||||
// 测试 remark 不匹配
|
||||
njglMapper.insert(cloneIgnoreId(dbNjgl, o -> o.setRemark(null)));
|
||||
// 测试 createTime 不匹配
|
||||
njglMapper.insert(cloneIgnoreId(dbNjgl, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
NjglPageReqVO reqVO = new NjglPageReqVO();
|
||||
reqVO.setId(null);
|
||||
reqVO.setUserName(null);
|
||||
reqVO.setUserId(null);
|
||||
reqVO.setDeptName(null);
|
||||
reqVO.setDeptId(null);
|
||||
reqVO.setAnnualDays(null);
|
||||
reqVO.setUsedDays(null);
|
||||
reqVO.setRemainingDays(null);
|
||||
reqVO.setStartDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setEndDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<NjglDO> pageResult = njglService.getNjglPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbNjgl, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
@ -13,4 +13,3 @@ DELETE FROM "oa_carinfo";
|
||||
DELETE FROM "oa_Driver";
|
||||
DELETE FROM "oa_items";
|
||||
DELETE FROM "oa_calendar";
|
||||
DELETE FROM "oa_njgl";
|
||||
|
@ -310,24 +310,3 @@ CREATE TABLE IF NOT EXISTS "oa_calendar" (
|
||||
"tenant_id" bigint NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '工作日历数据表';
|
||||
CREATE TABLE IF NOT EXISTS "oa_njgl" (
|
||||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"user_name" varchar,
|
||||
"user_id" bigint NOT NULL,
|
||||
"dept_name" varchar,
|
||||
"dept_id" bigint NOT NULL,
|
||||
"annual_days" int NOT NULL,
|
||||
"used_days" int NOT NULL,
|
||||
"remaining_days" int NOT NULL,
|
||||
"start_date" varchar NOT NULL,
|
||||
"end_date" varchar NOT NULL,
|
||||
"status" int NOT NULL,
|
||||
"remark" varchar,
|
||||
"creator" varchar DEFAULT '',
|
||||
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updater" varchar DEFAULT '',
|
||||
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
"deleted" bit NOT NULL DEFAULT FALSE,
|
||||
"tenant_id" bigint NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '年假管理表';
|
||||
|
Loading…
Reference in New Issue
Block a user