会议室管理
Some checks are pending
Java CI with Maven / build (11) (push) Waiting to run
Java CI with Maven / build (17) (push) Waiting to run
Java CI with Maven / build (8) (push) Waiting to run
yudao-ui-admin CI / build (14.x) (push) Waiting to run
yudao-ui-admin CI / build (16.x) (push) Waiting to run

This commit is contained in:
XaoLi717 2024-11-12 11:22:27 +08:00
parent ec8d0a6b5b
commit b5377b23f4
14 changed files with 1107 additions and 0 deletions

View File

@ -26,5 +26,7 @@ public interface ErrorCodeConstants {
ErrorCode JBGL_NOT_EXISTS = new ErrorCode(1_011_006_000, "加班管理不存在");
// ========== 会议室管理 1_011_007_000 ==========
ErrorCode HSGL_NOT_EXISTS = new ErrorCode(1_011_007_000, "会议室管理不存在");
// ========== 会议管理 1_011_008_000 ==========
ErrorCode HYGL_NOT_EXISTS = new ErrorCode(1_011_008_000, "会议管理不存在");
}

View File

@ -0,0 +1,97 @@
package cn.iocoder.yudao.module.home.controller.admin.hygl;
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 static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import cn.iocoder.yudao.module.home.controller.admin.hygl.vo.*;
import cn.iocoder.yudao.module.home.dal.dataobject.hygl.HyglDO;
import cn.iocoder.yudao.module.home.service.hygl.HyglService;
@Tag(name = "管理后台 - 会议管理")
@RestController
@RequestMapping("/home/hygl")
@Validated
public class HyglController {
@Resource
private HyglService hyglService;
@PostMapping("/create")
@Operation(summary = "创建会议管理")
@PreAuthorize("@ss.hasPermission('home:hygl:create')")
public CommonResult<Long> createHygl(@Valid @RequestBody HyglSaveReqVO createReqVO) {
return success(hyglService.createHygl(getLoginUserId(), createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新会议管理")
@PreAuthorize("@ss.hasPermission('home:hygl:update')")
public CommonResult<Boolean> updateHygl(@Valid @RequestBody HyglSaveReqVO updateReqVO) {
hyglService.updateHygl(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除会议管理")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('home:hygl:delete')")
public CommonResult<Boolean> deleteHygl(@RequestParam("id") Long id) {
hyglService.deleteHygl(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得会议管理")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('home:hygl:query')")
public CommonResult<HyglRespVO> getHygl(@RequestParam("id") Long id) {
HyglDO hygl = hyglService.getHygl(id);
return success(BeanUtils.toBean(hygl, HyglRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得会议管理分页")
@PreAuthorize("@ss.hasPermission('home:hygl:query')")
public CommonResult<PageResult<HyglRespVO>> getHyglPage(@Valid HyglPageReqVO pageReqVO) {
// PageResult<HyglDO> pageResult = hyglService.getHyglPage(pageReqVO);
PageResult<HyglDO> pageResult = hyglService.getHyglPage(getLoginUserId(), pageReqVO);
return success(BeanUtils.toBean(pageResult, HyglRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出会议管理 Excel")
@PreAuthorize("@ss.hasPermission('home:hygl:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportHyglExcel(@Valid HyglPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<HyglDO> list = hyglService.getHyglPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "会议管理.xls", "数据", HyglRespVO.class,
BeanUtils.toBean(list, HyglRespVO.class));
}
}

View File

@ -0,0 +1,97 @@
package cn.iocoder.yudao.module.home.controller.admin.hygl.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 HyglPageReqVO extends PageParam {
@Schema(description = "会议标题")
private String title;
@Schema(description = "申请人名字", example = "赵六")
private String userName;
@Schema(description = "申请人id", example = "21485")
private Long userId;
@Schema(description = "申请部门名字", example = "赵六")
private String deptName;
@Schema(description = "申请部门id", example = "1237")
private Long deptId;
@Schema(description = "申请时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] time;
@Schema(description = "描述")
private String depict;
@Schema(description = "会议类型", example = "1")
private Integer type;
@Schema(description = "会议主题")
private String theme;
@Schema(description = "会议目标")
private String target;
@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 = "持续时间")
private Integer duration;
@Schema(description = "会议室id", example = "18881")
private Long roomId;
@Schema(description = "会议室名字", example = "王五")
private String roomName;
@Schema(description = "会议室地址")
private String roomAddress;
@Schema(description = "组织者")
private String organizer;
@Schema(description = "主讲人")
private String speaker;
@Schema(description = "记录人员")
private String meetingTaker;
@Schema(description = "参会人数")
private Integer number;
@Schema(description = "设备需求")
private String equipmentList;
@Schema(description = "网络需求")
private String network;
@Schema(description = "审批状态", example = "2")
private Integer status;
@Schema(description = "流程实例的编号", example = "26356")
private String processInstanceId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,122 @@
package cn.iocoder.yudao.module.home.controller.admin.hygl.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 HyglRespVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "19762")
@ExcelProperty("id")
private Long id;
@Schema(description = "会议标题", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("会议标题")
private String title;
@Schema(description = "申请人名字", example = "赵六")
@ExcelProperty("申请人名字")
private String userName;
@Schema(description = "申请人id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21485")
@ExcelProperty("申请人id")
private Long userId;
@Schema(description = "申请部门名字", example = "赵六")
@ExcelProperty("申请部门名字")
private String deptName;
@Schema(description = "申请部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1237")
@ExcelProperty("申请部门id")
private Long deptId;
@Schema(description = "申请时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("申请时间")
private LocalDateTime time;
@Schema(description = "描述")
@ExcelProperty("描述")
private String depict;
@Schema(description = "会议类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty(value = "会议类型", converter = DictConvert.class)
@DictFormat("hygl_type") // TODO 代码优化建议设置到对应的 DictTypeConstants 枚举类中
private Integer type;
@Schema(description = "会议主题")
@ExcelProperty("会议主题")
private String theme;
@Schema(description = "会议目标")
@ExcelProperty("会议目标")
private String target;
@Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("开始时间")
private LocalDateTime startDate;
@Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("结束时间")
private LocalDateTime endDate;
@Schema(description = "持续时间")
@ExcelProperty("持续时间")
private Integer duration;
@Schema(description = "会议室id", requiredMode = Schema.RequiredMode.REQUIRED, example = "18881")
@ExcelProperty("会议室id")
private Long roomId;
@Schema(description = "会议室名字", example = "王五")
@ExcelProperty("会议室名字")
private String roomName;
@Schema(description = "会议室地址", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("会议室地址")
private String roomAddress;
@Schema(description = "组织者", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("组织者")
private String organizer;
@Schema(description = "主讲人")
@ExcelProperty("主讲人")
private String speaker;
@Schema(description = "记录人员")
@ExcelProperty("记录人员")
private String meetingTaker;
@Schema(description = "参会人数", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("参会人数")
private Integer number;
@Schema(description = "设备需求")
@ExcelProperty("设备需求")
private String equipmentList;
@Schema(description = "网络需求")
@ExcelProperty("网络需求")
private String network;
@Schema(description = "审批状态", example = "2")
@ExcelProperty("审批状态")
private Integer status;
@Schema(description = "流程实例的编号", example = "26356")
@ExcelProperty("流程实例的编号")
private String processInstanceId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,102 @@
package cn.iocoder.yudao.module.home.controller.admin.hygl.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 HyglSaveReqVO {
@Schema(description = "发起人自选审批人 Map", example = "{taskKey1: [1, 2]}")
private Map<String, List<Long>> startUserSelectAssignees;
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "19762")
private Long id;
@Schema(description = "会议标题", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "会议标题不能为空")
private String title;
@Schema(description = "申请人名字", example = "赵六")
private String userName;
@Schema(description = "申请人id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21485")
private Long userId;
@Schema(description = "申请部门名字", example = "赵六")
private String deptName;
@Schema(description = "申请部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1237")
@NotNull(message = "申请部门id不能为空")
private Long deptId;
@Schema(description = "申请时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "申请时间不能为空")
private LocalDateTime time;
@Schema(description = "描述")
private String depict;
@Schema(description = "会议类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "会议类型不能为空")
private Integer type;
@Schema(description = "会议主题")
private String theme;
@Schema(description = "会议目标")
private String target;
@Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "开始时间不能为空")
private LocalDateTime startDate;
@Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "结束时间不能为空")
private LocalDateTime endDate;
@Schema(description = "持续时间")
private Integer duration;
@Schema(description = "会议室id", requiredMode = Schema.RequiredMode.REQUIRED, example = "18881")
@NotNull(message = "会议室id不能为空")
private Long roomId;
@Schema(description = "会议室名字", example = "王五")
private String roomName;
@Schema(description = "会议室地址", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "会议室地址不能为空")
private String roomAddress;
@Schema(description = "组织者", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "组织者不能为空")
private String organizer;
@Schema(description = "主讲人")
private String speaker;
@Schema(description = "记录人员")
private String meetingTaker;
@Schema(description = "参会人数", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "参会人数不能为空")
private Integer number;
@Schema(description = "设备需求")
private String equipmentList;
@Schema(description = "网络需求")
private String network;
@Schema(description = "审批状态", example = "2")
private Integer status;
@Schema(description = "流程实例的编号", example = "26356")
private String processInstanceId;
}

View File

@ -0,0 +1,132 @@
package cn.iocoder.yudao.module.home.dal.dataobject.hygl;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
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_hygl")
@KeySequence("oa_hygl_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class HyglDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
* 会议标题
*/
private String title;
/**
* 申请人名字
*/
private String userName;
/**
* 申请人id
*/
private Long userId;
/**
* 申请部门名字
*/
private String deptName;
/**
* 申请部门id
*/
private Long deptId;
/**
* 申请时间
*/
private LocalDateTime time;
/**
* 描述
*/
private String depict;
/**
* 会议类型
*
* 枚举 {@link TODO hygl_type 对应的类}
*/
private Integer type;
/**
* 会议主题
*/
private String theme;
/**
* 会议目标
*/
private String target;
/**
* 开始时间
*/
private LocalDateTime startDate;
/**
* 结束时间
*/
private LocalDateTime endDate;
/**
* 持续时间
*/
private Integer duration;
/**
* 会议室id
*/
private Long roomId;
/**
* 会议室名字
*/
private String roomName;
/**
* 会议室地址
*/
private String roomAddress;
/**
* 组织者
*/
private String organizer;
/**
* 主讲人
*/
private String speaker;
/**
* 记录人员
*/
private String meetingTaker;
/**
* 参会人数
*/
private Integer number;
/**
* 设备需求
*/
private String equipmentList;
/**
* 网络需求
*/
private String network;
/**
* 审批状态
*/
private Integer status;
/**
* 流程实例的编号
*/
private String processInstanceId;
}

View File

@ -0,0 +1,80 @@
package cn.iocoder.yudao.module.home.dal.mysql.hygl;
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.hygl.HyglDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.home.controller.admin.hygl.vo.*;
/**
* 会议管理 Mapper
*
* @author 君风
*/
@Mapper
public interface HyglMapper extends BaseMapperX<HyglDO> {
default PageResult<HyglDO> selectPage(HyglPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<HyglDO>()
.eqIfPresent(HyglDO::getTitle, reqVO.getTitle())
.likeIfPresent(HyglDO::getUserName, reqVO.getUserName())
.eqIfPresent(HyglDO::getUserId, reqVO.getUserId())
.likeIfPresent(HyglDO::getDeptName, reqVO.getDeptName())
.eqIfPresent(HyglDO::getDeptId, reqVO.getDeptId())
.betweenIfPresent(HyglDO::getTime, reqVO.getTime())
.eqIfPresent(HyglDO::getDepict, reqVO.getDepict())
.eqIfPresent(HyglDO::getType, reqVO.getType())
.eqIfPresent(HyglDO::getTheme, reqVO.getTheme())
.eqIfPresent(HyglDO::getTarget, reqVO.getTarget())
.betweenIfPresent(HyglDO::getStartDate, reqVO.getStartDate())
.betweenIfPresent(HyglDO::getEndDate, reqVO.getEndDate())
.eqIfPresent(HyglDO::getDuration, reqVO.getDuration())
.eqIfPresent(HyglDO::getRoomId, reqVO.getRoomId())
.likeIfPresent(HyglDO::getRoomName, reqVO.getRoomName())
.eqIfPresent(HyglDO::getRoomAddress, reqVO.getRoomAddress())
.eqIfPresent(HyglDO::getOrganizer, reqVO.getOrganizer())
.eqIfPresent(HyglDO::getSpeaker, reqVO.getSpeaker())
.eqIfPresent(HyglDO::getMeetingTaker, reqVO.getMeetingTaker())
.eqIfPresent(HyglDO::getNumber, reqVO.getNumber())
.eqIfPresent(HyglDO::getEquipmentList, reqVO.getEquipmentList())
.eqIfPresent(HyglDO::getNetwork, reqVO.getNetwork())
.eqIfPresent(HyglDO::getStatus, reqVO.getStatus())
.eqIfPresent(HyglDO::getProcessInstanceId, reqVO.getProcessInstanceId())
.betweenIfPresent(HyglDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(HyglDO::getId));
}
default PageResult<HyglDO> selectPage(Long userId, HyglPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<HyglDO>()
.eqIfPresent(HyglDO::getTitle, reqVO.getTitle())
.likeIfPresent(HyglDO::getUserName, reqVO.getUserName())
.eqIfPresent(HyglDO::getUserId, userId)
.likeIfPresent(HyglDO::getDeptName, reqVO.getDeptName())
.eqIfPresent(HyglDO::getDeptId, reqVO.getDeptId())
.betweenIfPresent(HyglDO::getTime, reqVO.getTime())
.eqIfPresent(HyglDO::getDepict, reqVO.getDepict())
.eqIfPresent(HyglDO::getType, reqVO.getType())
.eqIfPresent(HyglDO::getTheme, reqVO.getTheme())
.eqIfPresent(HyglDO::getTarget, reqVO.getTarget())
.betweenIfPresent(HyglDO::getStartDate, reqVO.getStartDate())
.betweenIfPresent(HyglDO::getEndDate, reqVO.getEndDate())
.eqIfPresent(HyglDO::getDuration, reqVO.getDuration())
.eqIfPresent(HyglDO::getRoomId, reqVO.getRoomId())
.likeIfPresent(HyglDO::getRoomName, reqVO.getRoomName())
.eqIfPresent(HyglDO::getRoomAddress, reqVO.getRoomAddress())
.eqIfPresent(HyglDO::getOrganizer, reqVO.getOrganizer())
.eqIfPresent(HyglDO::getSpeaker, reqVO.getSpeaker())
.eqIfPresent(HyglDO::getMeetingTaker, reqVO.getMeetingTaker())
.eqIfPresent(HyglDO::getNumber, reqVO.getNumber())
.eqIfPresent(HyglDO::getEquipmentList, reqVO.getEquipmentList())
.eqIfPresent(HyglDO::getNetwork, reqVO.getNetwork())
.eqIfPresent(HyglDO::getStatus, reqVO.getStatus())
.eqIfPresent(HyglDO::getProcessInstanceId, reqVO.getProcessInstanceId())
.betweenIfPresent(HyglDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(HyglDO::getId));
}
}

View File

@ -0,0 +1,59 @@
package cn.iocoder.yudao.module.home.service.hygl;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.home.controller.admin.hygl.vo.*;
import cn.iocoder.yudao.module.home.dal.dataobject.hygl.HyglDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* 会议管理 Service 接口
*
* @author 君风
*/
public interface HyglService {
/**
* 创建会议管理
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createHygl(@Valid HyglSaveReqVO createReqVO);
Long createHygl(Long userId, @Valid HyglSaveReqVO createReqVO);
/**
* 更新会议管理
*
* @param updateReqVO 更新信息
*/
void updateHygl(@Valid HyglSaveReqVO updateReqVO);
/**
* 删除会议管理
*
* @param id 编号
*/
void deleteHygl(Long id);
/**
* 获得会议管理
*
* @param id 编号
* @return 会议管理
*/
HyglDO getHygl(Long id);
/**
* 获得会议管理分页
*
* @param pageReqVO 分页查询
* @return 会议管理分页
*/
PageResult<HyglDO> getHyglPage(HyglPageReqVO pageReqVO);
PageResult<HyglDO> getHyglPage(Long userId, HyglPageReqVO pageReqVO);
void updateHyglStatus(Long id, Integer status);
}

View File

@ -0,0 +1,118 @@
package cn.iocoder.yudao.module.home.service.hygl;
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
import cn.iocoder.yudao.module.home.dal.dataobject.clgl.ClglDO;
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.hygl.vo.*;
import cn.iocoder.yudao.module.home.dal.dataobject.hygl.HyglDO;
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.hygl.HyglMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.KNOWLEDGE_NOT_EXISTS;
import static cn.iocoder.yudao.module.home.enums.ErrorCodeConstants.*;
/**
* 会议管理 Service 实现类
*
* @author 君风
*/
@Service
@Validated
public class HyglServiceImpl implements HyglService {
public static final String PROCESS_KEY = "hygl-001";
@Resource
private HyglMapper hyglMapper;
@Resource
private BpmProcessInstanceApi processInstanceApi;
@Override
public Long createHygl(HyglSaveReqVO createReqVO) {
// 插入
HyglDO hygl = BeanUtils.toBean(createReqVO, HyglDO.class);
hyglMapper.insert(hygl);
// 返回
return hygl.getId();
}
@Override
public Long createHygl(Long userId, HyglSaveReqVO createReqVO) {
// 插入
HyglDO hygl = BeanUtils.toBean(createReqVO, HyglDO.class)
.setUserId(userId).setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
hyglMapper.insert(hygl);
// 发起 BPM 流程
Map<String, Object> processInstanceVariables = new HashMap<>();
String processInstanceId = processInstanceApi.createProcessInstance(userId,
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(hygl.getId()))
.setStartUserSelectAssignees(createReqVO.getStartUserSelectAssignees()));
// 将工作流的编号更新到 OA 请假单中
hyglMapper.updateById(new HyglDO().setId(hygl.getId()).setProcessInstanceId(processInstanceId));
// 返回
return hygl.getId();
}
@Override
public void updateHygl(HyglSaveReqVO updateReqVO) {
// 校验存在
validateHyglExists(updateReqVO.getId());
// 更新
HyglDO updateObj = BeanUtils.toBean(updateReqVO, HyglDO.class);
hyglMapper.updateById(updateObj);
}
@Override
public void deleteHygl(Long id) {
// 校验存在
validateHyglExists(id);
// 删除
hyglMapper.deleteById(id);
}
private void validateHyglExists(Long id) {
if (hyglMapper.selectById(id) == null) {
throw exception(HYGL_NOT_EXISTS);
}
}
@Override
public HyglDO getHygl(Long id) {
return hyglMapper.selectById(id);
}
@Override
public PageResult<HyglDO> getHyglPage(HyglPageReqVO pageReqVO) {
return hyglMapper.selectPage(pageReqVO);
}
public PageResult<HyglDO> getHyglPage(Long userId, HyglPageReqVO pageReqVO) {
return hyglMapper.selectPage(userId, pageReqVO);
}
@Override
public void updateHyglStatus(Long id, Integer status) {
hyglMapper.updateById(new HyglDO().setId(id).setStatus(status));
}
private void validateLeaveExists(Long id) {
if (hyglMapper.selectById(id) == null) {
throw exception(KNOWLEDGE_NOT_EXISTS);
}
}
}

View File

@ -0,0 +1,25 @@
package cn.iocoder.yudao.module.home.service.hygl.listener;
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent;
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener;
import cn.iocoder.yudao.module.home.service.hygl.HyglService;
import cn.iocoder.yudao.module.home.service.hygl.HyglServiceImpl;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class BpmHyglStatusListener extends BpmProcessInstanceStatusEventListener {
@Resource
private HyglService hyglService;
@Override
protected String getProcessDefinitionKey(){
return HyglServiceImpl.PROCESS_KEY;
}
@Override
protected void onEvent(BpmProcessInstanceStatusEvent event) {
hyglService.updateHyglStatus(Long.parseLong(event.getBusinessKey()), event.getStatus());
}
}

View File

@ -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.hygl.HyglMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@ -0,0 +1,226 @@
package cn.iocoder.yudao.module.home.service.hygl;
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.hygl.vo.*;
import cn.iocoder.yudao.module.home.dal.dataobject.hygl.HyglDO;
import cn.iocoder.yudao.module.home.dal.mysql.hygl.HyglMapper;
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 HyglServiceImpl} 的单元测试类
*
* @author 君风
*/
@Import(HyglServiceImpl.class)
public class HyglServiceImplTest extends BaseDbUnitTest {
@Resource
private HyglServiceImpl hyglService;
@Resource
private HyglMapper hyglMapper;
@Test
public void testCreateHygl_success() {
// 准备参数
HyglSaveReqVO createReqVO = randomPojo(HyglSaveReqVO.class).setId(null);
// 调用
Long hyglId = hyglService.createHygl(createReqVO);
// 断言
assertNotNull(hyglId);
// 校验记录的属性是否正确
HyglDO hygl = hyglMapper.selectById(hyglId);
assertPojoEquals(createReqVO, hygl, "id");
}
@Test
public void testUpdateHygl_success() {
// mock 数据
HyglDO dbHygl = randomPojo(HyglDO.class);
hyglMapper.insert(dbHygl);// @Sql: 先插入出一条存在的数据
// 准备参数
HyglSaveReqVO updateReqVO = randomPojo(HyglSaveReqVO.class, o -> {
o.setId(dbHygl.getId()); // 设置更新的 ID
});
// 调用
hyglService.updateHygl(updateReqVO);
// 校验是否更新正确
HyglDO hygl = hyglMapper.selectById(updateReqVO.getId()); // 获取最新的
assertPojoEquals(updateReqVO, hygl);
}
@Test
public void testUpdateHygl_notExists() {
// 准备参数
HyglSaveReqVO updateReqVO = randomPojo(HyglSaveReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> hyglService.updateHygl(updateReqVO), HYGL_NOT_EXISTS);
}
@Test
public void testDeleteHygl_success() {
// mock 数据
HyglDO dbHygl = randomPojo(HyglDO.class);
hyglMapper.insert(dbHygl);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbHygl.getId();
// 调用
hyglService.deleteHygl(id);
// 校验数据不存在了
assertNull(hyglMapper.selectById(id));
}
@Test
public void testDeleteHygl_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> hyglService.deleteHygl(id), HYGL_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值然后删除 @Disabled 注解
public void testGetHyglPage() {
// mock 数据
HyglDO dbHygl = randomPojo(HyglDO.class, o -> { // 等会查询到
o.setTitle(null);
o.setUserName(null);
o.setUserId(null);
o.setDeptName(null);
o.setDeptId(null);
o.setTime(null);
o.setDepict(null);
o.setType(null);
o.setTheme(null);
o.setTarget(null);
o.setStartDate(null);
o.setEndDate(null);
o.setDuration(null);
o.setRoomId(null);
o.setRoomName(null);
o.setRoomAddress(null);
o.setOrganizer(null);
o.setSpeaker(null);
o.setMeetingTaker(null);
o.setNumber(null);
o.setEquipmentList(null);
o.setNetwork(null);
o.setStatus(null);
o.setProcessInstanceId(null);
o.setCreateTime(null);
});
hyglMapper.insert(dbHygl);
// 测试 title 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setTitle(null)));
// 测试 userName 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setUserName(null)));
// 测试 userId 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setUserId(null)));
// 测试 deptName 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setDeptName(null)));
// 测试 deptId 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setDeptId(null)));
// 测试 time 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setTime(null)));
// 测试 depict 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setDepict(null)));
// 测试 type 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setType(null)));
// 测试 theme 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setTheme(null)));
// 测试 target 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setTarget(null)));
// 测试 startDate 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setStartDate(null)));
// 测试 endDate 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setEndDate(null)));
// 测试 duration 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setDuration(null)));
// 测试 roomId 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setRoomId(null)));
// 测试 roomName 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setRoomName(null)));
// 测试 roomAddress 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setRoomAddress(null)));
// 测试 organizer 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setOrganizer(null)));
// 测试 speaker 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setSpeaker(null)));
// 测试 meetingTaker 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setMeetingTaker(null)));
// 测试 number 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setNumber(null)));
// 测试 equipmentList 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setEquipmentList(null)));
// 测试 network 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setNetwork(null)));
// 测试 status 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setStatus(null)));
// 测试 processInstanceId 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setProcessInstanceId(null)));
// 测试 createTime 不匹配
hyglMapper.insert(cloneIgnoreId(dbHygl, o -> o.setCreateTime(null)));
// 准备参数
HyglPageReqVO reqVO = new HyglPageReqVO();
reqVO.setTitle(null);
reqVO.setUserName(null);
reqVO.setUserId(null);
reqVO.setDeptName(null);
reqVO.setDeptId(null);
reqVO.setTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setDepict(null);
reqVO.setType(null);
reqVO.setTheme(null);
reqVO.setTarget(null);
reqVO.setStartDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setEndDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setDuration(null);
reqVO.setRoomId(null);
reqVO.setRoomName(null);
reqVO.setRoomAddress(null);
reqVO.setOrganizer(null);
reqVO.setSpeaker(null);
reqVO.setMeetingTaker(null);
reqVO.setNumber(null);
reqVO.setEquipmentList(null);
reqVO.setNetwork(null);
reqVO.setStatus(null);
reqVO.setProcessInstanceId(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
// 调用
PageResult<HyglDO> pageResult = hyglService.getHyglPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbHygl, pageResult.getList().get(0));
}
}

View File

@ -5,3 +5,4 @@ DELETE FROM "oa_clgl";
DELETE FROM "oa-bgyp";
DELETE FROM "oa_jbgl";
DELETE FROM "oa_hsgl";
DELETE FROM "oa_hygl";

View File

@ -155,3 +155,37 @@ CREATE TABLE IF NOT EXISTS "oa_hsgl" (
"tenant_id" bigint NOT NULL,
PRIMARY KEY ("id")
) COMMENT '会议室管理表';
CREATE TABLE IF NOT EXISTS "oa_hygl" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"title" varchar NOT NULL,
"user_name" varchar,
"user_id" bigint NOT NULL,
"dept_name" varchar,
"dept_id" bigint NOT NULL,
"time" varchar NOT NULL,
"depict" varchar,
"type" int NOT NULL,
"theme" varchar,
"target" varchar,
"start_date" varchar NOT NULL,
"end_date" varchar NOT NULL,
"duration" int,
"room_id" bigint NOT NULL,
"room_name" varchar,
"room_address" varchar NOT NULL,
"organizer" varchar NOT NULL,
"speaker" varchar,
"meeting_taker" varchar,
"number" int NOT NULL,
"equipment_list" varchar,
"network" varchar,
"status" int,
"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 '会议管理表';