会议室管理
This commit is contained in:
parent
37a8817c44
commit
3e69db2127
@ -24,4 +24,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode BGYP_NOT_EXISTS = new ErrorCode(1_011_005_000, "办公用品管理不存在");
|
||||
// ========== 加班管理 1_011_006_000 ==========
|
||||
ErrorCode JBGL_NOT_EXISTS = new ErrorCode(1_011_006_000, "加班管理不存在");
|
||||
// ========== 会议室管理 1_011_007_000 ==========
|
||||
ErrorCode HSGL_NOT_EXISTS = new ErrorCode(1_011_007_000, "会议室管理不存在");
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.hsgl;
|
||||
|
||||
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.constraints.*;
|
||||
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.hsgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.hsgl.HsglDO;
|
||||
import cn.iocoder.yudao.module.home.service.hsgl.HsglService;
|
||||
|
||||
@Tag(name = "管理后台 - 会议室管理")
|
||||
@RestController
|
||||
@RequestMapping("/home/hsgl")
|
||||
@Validated
|
||||
public class HsglController {
|
||||
|
||||
@Resource
|
||||
private HsglService hsglService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建会议室管理")
|
||||
@PreAuthorize("@ss.hasPermission('home:hsgl:create')")
|
||||
public CommonResult<Long> createHsgl(@Valid @RequestBody HsglSaveReqVO createReqVO) {
|
||||
return success(hsglService.createHsgl(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新会议室管理")
|
||||
@PreAuthorize("@ss.hasPermission('home:hsgl:update')")
|
||||
public CommonResult<Boolean> updateHsgl(@Valid @RequestBody HsglSaveReqVO updateReqVO) {
|
||||
hsglService.updateHsgl(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除会议室管理")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('home:hsgl:delete')")
|
||||
public CommonResult<Boolean> deleteHsgl(@RequestParam("id") Long id) {
|
||||
hsglService.deleteHsgl(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得会议室管理")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('home:hsgl:query')")
|
||||
public CommonResult<HsglRespVO> getHsgl(@RequestParam("id") Long id) {
|
||||
HsglDO hsgl = hsglService.getHsgl(id);
|
||||
return success(BeanUtils.toBean(hsgl, HsglRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得会议室管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('home:hsgl:query')")
|
||||
public CommonResult<PageResult<HsglRespVO>> getHsglPage(@Valid HsglPageReqVO pageReqVO) {
|
||||
PageResult<HsglDO> pageResult = hsglService.getHsglPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, HsglRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出会议室管理 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('home:hsgl:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportHsglExcel(@Valid HsglPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<HsglDO> list = hsglService.getHsglPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "会议室管理.xls", "数据", HsglRespVO.class,
|
||||
BeanUtils.toBean(list, HsglRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.hsgl.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 HsglPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "会议室管理id", example = "532")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "会议室名", example = "赵六")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "会议室地址")
|
||||
private String location;
|
||||
|
||||
@Schema(description = "会议室类型", example = "1")
|
||||
private Integer roomType;
|
||||
|
||||
@Schema(description = "会议室管理员")
|
||||
private String manager;
|
||||
|
||||
@Schema(description = "会议室大小")
|
||||
private String roomMax;
|
||||
|
||||
@Schema(description = "容纳人数")
|
||||
private Integer capacity;
|
||||
|
||||
@Schema(description = "会议室设备")
|
||||
private String facilities;
|
||||
|
||||
@Schema(description = "使用状态", example = "1")
|
||||
private Integer roomStatus;
|
||||
|
||||
@Schema(description = "会议室照片")
|
||||
private String photo;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "审批状态", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "申请人id", example = "30966")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "12679")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.hsgl.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 HsglRespVO {
|
||||
|
||||
@Schema(description = "会议室管理id", requiredMode = Schema.RequiredMode.REQUIRED, example = "532")
|
||||
@ExcelProperty("会议室管理id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "会议室名", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@ExcelProperty("会议室名")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "会议室地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("会议室地址")
|
||||
private String location;
|
||||
|
||||
@Schema(description = "会议室类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "会议室类型", converter = DictConvert.class)
|
||||
@DictFormat("hsgl-type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer roomType;
|
||||
|
||||
@Schema(description = "会议室管理员", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("会议室管理员")
|
||||
private String manager;
|
||||
|
||||
@Schema(description = "会议室大小")
|
||||
@ExcelProperty("会议室大小")
|
||||
private String roomMax;
|
||||
|
||||
@Schema(description = "容纳人数")
|
||||
@ExcelProperty("容纳人数")
|
||||
private Integer capacity;
|
||||
|
||||
@Schema(description = "会议室设备")
|
||||
@ExcelProperty("会议室设备")
|
||||
private String facilities;
|
||||
|
||||
@Schema(description = "使用状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "使用状态", converter = DictConvert.class)
|
||||
@DictFormat("hsgl_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer roomStatus;
|
||||
|
||||
@Schema(description = "会议室照片")
|
||||
@ExcelProperty("会议室照片")
|
||||
private String photo;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "审批状态", example = "1")
|
||||
@ExcelProperty("审批状态")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "申请人id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30966")
|
||||
@ExcelProperty("申请人id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "12679")
|
||||
@ExcelProperty("流程实例的编号")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.hsgl.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 会议室管理新增/修改 Request VO")
|
||||
@Data
|
||||
public class HsglSaveReqVO {
|
||||
|
||||
@Schema(description = "会议室管理id", requiredMode = Schema.RequiredMode.REQUIRED, example = "532")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "标题不能为空")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "会议室名", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@NotEmpty(message = "会议室名不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "会议室地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "会议室地址不能为空")
|
||||
private String location;
|
||||
|
||||
@Schema(description = "会议室类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "会议室类型不能为空")
|
||||
private Integer roomType;
|
||||
|
||||
@Schema(description = "会议室管理员", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "会议室管理员不能为空")
|
||||
private String manager;
|
||||
|
||||
@Schema(description = "会议室大小")
|
||||
private String roomMax;
|
||||
|
||||
@Schema(description = "容纳人数")
|
||||
private Integer capacity;
|
||||
|
||||
@Schema(description = "会议室设备")
|
||||
private String facilities;
|
||||
|
||||
@Schema(description = "使用状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "使用状态不能为空")
|
||||
private Integer roomStatus;
|
||||
|
||||
@Schema(description = "会议室照片")
|
||||
private String photo;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "审批状态", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "申请人id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30966")
|
||||
@NotNull(message = "申请人id不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "12679")
|
||||
private String processInstanceId;
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package cn.iocoder.yudao.module.home.dal.dataobject.hsgl;
|
||||
|
||||
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("oa_hsgl")
|
||||
@KeySequence("oa_hsgl_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HsglDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 会议室管理id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 会议室名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 会议室地址
|
||||
*/
|
||||
private String location;
|
||||
/**
|
||||
* 会议室类型
|
||||
*
|
||||
* 枚举 {@link TODO hsgl-type 对应的类}
|
||||
*/
|
||||
private Integer roomType;
|
||||
/**
|
||||
* 会议室管理员
|
||||
*/
|
||||
private String manager;
|
||||
/**
|
||||
* 会议室大小
|
||||
*/
|
||||
private String roomMax;
|
||||
/**
|
||||
* 容纳人数
|
||||
*/
|
||||
private Integer capacity;
|
||||
/**
|
||||
* 会议室设备
|
||||
*/
|
||||
private String facilities;
|
||||
/**
|
||||
* 使用状态
|
||||
*
|
||||
* 枚举 {@link TODO hsgl_status 对应的类}
|
||||
*/
|
||||
private Integer roomStatus;
|
||||
/**
|
||||
* 会议室照片
|
||||
*/
|
||||
private String photo;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 审批状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 申请人id
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 流程实例的编号
|
||||
*/
|
||||
private String processInstanceId;
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package cn.iocoder.yudao.module.home.dal.mysql.hsgl;
|
||||
|
||||
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.hsgl.HsglDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.home.controller.admin.hsgl.vo.*;
|
||||
|
||||
/**
|
||||
* 会议室管理 Mapper
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Mapper
|
||||
public interface HsglMapper extends BaseMapperX<HsglDO> {
|
||||
|
||||
default PageResult<HsglDO> selectPage(HsglPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<HsglDO>()
|
||||
.eqIfPresent(HsglDO::getId, reqVO.getId())
|
||||
.eqIfPresent(HsglDO::getTitle, reqVO.getTitle())
|
||||
.likeIfPresent(HsglDO::getName, reqVO.getName())
|
||||
.eqIfPresent(HsglDO::getLocation, reqVO.getLocation())
|
||||
.eqIfPresent(HsglDO::getRoomType, reqVO.getRoomType())
|
||||
.eqIfPresent(HsglDO::getManager, reqVO.getManager())
|
||||
.eqIfPresent(HsglDO::getRoomMax, reqVO.getRoomMax())
|
||||
.eqIfPresent(HsglDO::getCapacity, reqVO.getCapacity())
|
||||
.eqIfPresent(HsglDO::getFacilities, reqVO.getFacilities())
|
||||
.eqIfPresent(HsglDO::getRoomStatus, reqVO.getRoomStatus())
|
||||
.eqIfPresent(HsglDO::getPhoto, reqVO.getPhoto())
|
||||
.eqIfPresent(HsglDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(HsglDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(HsglDO::getUserId, reqVO.getUserId())
|
||||
.eqIfPresent(HsglDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
||||
.betweenIfPresent(HsglDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(HsglDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.home.service.hsgl;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.home.controller.admin.hsgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.hsgl.HsglDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 会议室管理 Service 接口
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
public interface HsglService {
|
||||
|
||||
/**
|
||||
* 创建会议室管理
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createHsgl(@Valid HsglSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新会议室管理
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateHsgl(@Valid HsglSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除会议室管理
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteHsgl(Long id);
|
||||
|
||||
/**
|
||||
* 获得会议室管理
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 会议室管理
|
||||
*/
|
||||
HsglDO getHsgl(Long id);
|
||||
|
||||
/**
|
||||
* 获得会议室管理分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 会议室管理分页
|
||||
*/
|
||||
PageResult<HsglDO> getHsglPage(HsglPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.home.service.hsgl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.home.controller.admin.hsgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.hsgl.HsglDO;
|
||||
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.hsgl.HsglMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.home.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 会议室管理 Service 实现类
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class HsglServiceImpl implements HsglService {
|
||||
|
||||
@Resource
|
||||
private HsglMapper hsglMapper;
|
||||
|
||||
@Override
|
||||
public Long createHsgl(HsglSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
HsglDO hsgl = BeanUtils.toBean(createReqVO, HsglDO.class);
|
||||
hsglMapper.insert(hsgl);
|
||||
// 返回
|
||||
return hsgl.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHsgl(HsglSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateHsglExists(updateReqVO.getId());
|
||||
// 更新
|
||||
HsglDO updateObj = BeanUtils.toBean(updateReqVO, HsglDO.class);
|
||||
hsglMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteHsgl(Long id) {
|
||||
// 校验存在
|
||||
validateHsglExists(id);
|
||||
// 删除
|
||||
hsglMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateHsglExists(Long id) {
|
||||
if (hsglMapper.selectById(id) == null) {
|
||||
throw exception(HSGL_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HsglDO getHsgl(Long id) {
|
||||
return hsglMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<HsglDO> getHsglPage(HsglPageReqVO pageReqVO) {
|
||||
return hsglMapper.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.home.dal.mysql.hsgl.HsglMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,190 @@
|
||||
package cn.iocoder.yudao.module.home.service.hsgl;
|
||||
|
||||
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.hsgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.hsgl.HsglDO;
|
||||
import cn.iocoder.yudao.module.home.dal.mysql.hsgl.HsglMapper;
|
||||
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 HsglServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Import(HsglServiceImpl.class)
|
||||
public class HsglServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private HsglServiceImpl hsglService;
|
||||
|
||||
@Resource
|
||||
private HsglMapper hsglMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateHsgl_success() {
|
||||
// 准备参数
|
||||
HsglSaveReqVO createReqVO = randomPojo(HsglSaveReqVO.class).setId(null);
|
||||
|
||||
// 调用
|
||||
Long hsglId = hsglService.createHsgl(createReqVO);
|
||||
// 断言
|
||||
assertNotNull(hsglId);
|
||||
// 校验记录的属性是否正确
|
||||
HsglDO hsgl = hsglMapper.selectById(hsglId);
|
||||
assertPojoEquals(createReqVO, hsgl, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateHsgl_success() {
|
||||
// mock 数据
|
||||
HsglDO dbHsgl = randomPojo(HsglDO.class);
|
||||
hsglMapper.insert(dbHsgl);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
HsglSaveReqVO updateReqVO = randomPojo(HsglSaveReqVO.class, o -> {
|
||||
o.setId(dbHsgl.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
hsglService.updateHsgl(updateReqVO);
|
||||
// 校验是否更新正确
|
||||
HsglDO hsgl = hsglMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(updateReqVO, hsgl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateHsgl_notExists() {
|
||||
// 准备参数
|
||||
HsglSaveReqVO updateReqVO = randomPojo(HsglSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> hsglService.updateHsgl(updateReqVO), HSGL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteHsgl_success() {
|
||||
// mock 数据
|
||||
HsglDO dbHsgl = randomPojo(HsglDO.class);
|
||||
hsglMapper.insert(dbHsgl);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbHsgl.getId();
|
||||
|
||||
// 调用
|
||||
hsglService.deleteHsgl(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(hsglMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteHsgl_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> hsglService.deleteHsgl(id), HSGL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetHsglPage() {
|
||||
// mock 数据
|
||||
HsglDO dbHsgl = randomPojo(HsglDO.class, o -> { // 等会查询到
|
||||
o.setId(null);
|
||||
o.setTitle(null);
|
||||
o.setName(null);
|
||||
o.setLocation(null);
|
||||
o.setRoomType(null);
|
||||
o.setManager(null);
|
||||
o.setRoomMax(null);
|
||||
o.setCapacity(null);
|
||||
o.setFacilities(null);
|
||||
o.setRoomStatus(null);
|
||||
o.setPhoto(null);
|
||||
o.setRemark(null);
|
||||
o.setStatus(null);
|
||||
o.setUserId(null);
|
||||
o.setProcessInstanceId(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
hsglMapper.insert(dbHsgl);
|
||||
// 测试 id 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setId(null)));
|
||||
// 测试 title 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setTitle(null)));
|
||||
// 测试 name 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setName(null)));
|
||||
// 测试 location 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setLocation(null)));
|
||||
// 测试 roomType 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setRoomType(null)));
|
||||
// 测试 manager 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setManager(null)));
|
||||
// 测试 roomMax 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setRoomMax(null)));
|
||||
// 测试 capacity 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setCapacity(null)));
|
||||
// 测试 facilities 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setFacilities(null)));
|
||||
// 测试 roomStatus 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setRoomStatus(null)));
|
||||
// 测试 photo 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setPhoto(null)));
|
||||
// 测试 remark 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setRemark(null)));
|
||||
// 测试 status 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setStatus(null)));
|
||||
// 测试 userId 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setUserId(null)));
|
||||
// 测试 processInstanceId 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setProcessInstanceId(null)));
|
||||
// 测试 createTime 不匹配
|
||||
hsglMapper.insert(cloneIgnoreId(dbHsgl, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
HsglPageReqVO reqVO = new HsglPageReqVO();
|
||||
reqVO.setId(null);
|
||||
reqVO.setTitle(null);
|
||||
reqVO.setName(null);
|
||||
reqVO.setLocation(null);
|
||||
reqVO.setRoomType(null);
|
||||
reqVO.setManager(null);
|
||||
reqVO.setRoomMax(null);
|
||||
reqVO.setCapacity(null);
|
||||
reqVO.setFacilities(null);
|
||||
reqVO.setRoomStatus(null);
|
||||
reqVO.setPhoto(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setUserId(null);
|
||||
reqVO.setProcessInstanceId(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<HsglDO> pageResult = hsglService.getHsglPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbHsgl, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
@ -4,3 +4,4 @@ DELETE FROM "des_homeimg";
|
||||
DELETE FROM "oa_clgl";
|
||||
DELETE FROM "oa-bgyp";
|
||||
DELETE FROM "oa_jbgl";
|
||||
DELETE FROM "oa_hsgl";
|
||||
|
@ -131,3 +131,27 @@ CREATE TABLE IF NOT EXISTS "oa_jbgl" (
|
||||
"tenant_id" bigint NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '加班管理表';
|
||||
CREATE TABLE IF NOT EXISTS "oa_hsgl" (
|
||||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"title" varchar NOT NULL,
|
||||
"name" varchar NOT NULL,
|
||||
"location" varchar NOT NULL,
|
||||
"room_type" int NOT NULL,
|
||||
"manager" varchar NOT NULL,
|
||||
"room_max" varchar,
|
||||
"capacity" int,
|
||||
"facilities" varchar,
|
||||
"room_status" int NOT NULL,
|
||||
"photo" varchar,
|
||||
"remark" varchar,
|
||||
"status" int,
|
||||
"user_id" bigint NOT NULL,
|
||||
"process_instance_id" 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