feat(新增): 任务调度分组CURD
This commit is contained in:
parent
5b370dd9f1
commit
04273ecf39
|
@ -20,7 +20,7 @@ public class AdminCodeGenerator {
|
|||
public static final String entity = "Bunny";
|
||||
|
||||
public static void main(String[] args) {
|
||||
Generation("v_schedulers");
|
||||
Generation("sys_schedulers_group");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,11 +3,11 @@ package cn.bunny.common.generator.generator;
|
|||
import cn.bunny.common.generator.entity.BaseField;
|
||||
import cn.bunny.common.generator.entity.BaseResultMap;
|
||||
import cn.bunny.common.generator.utils.GeneratorCodeUtils;
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersAddDto;
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersDto;
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersUpdateDto;
|
||||
import cn.bunny.dao.entity.schedulers.Schedulers;
|
||||
import cn.bunny.dao.vo.schedulers.SchedulersVo;
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersGroupAddDto;
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersGroupDto;
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersGroupUpdateDto;
|
||||
import cn.bunny.dao.entity.schedulers.SchedulersGroup;
|
||||
import cn.bunny.dao.vo.schedulers.SchedulersGroupVo;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
@ -51,11 +51,11 @@ public class WebGeneratorCode {
|
|||
public static String resourceMapperPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\resources\\mapper\\";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Class<?> originalClass = Schedulers.class;
|
||||
Class<?> dtoClass = SchedulersDto.class;
|
||||
Class<?> addDtoClass = SchedulersAddDto.class;
|
||||
Class<?> updateDtoClass = SchedulersUpdateDto.class;
|
||||
Class<?> voClass = SchedulersVo.class;
|
||||
Class<?> originalClass = SchedulersGroup.class;
|
||||
Class<?> dtoClass = SchedulersGroupDto.class;
|
||||
Class<?> addDtoClass = SchedulersGroupAddDto.class;
|
||||
Class<?> updateDtoClass = SchedulersGroupUpdateDto.class;
|
||||
Class<?> voClass = SchedulersGroupVo.class;
|
||||
|
||||
// 设置velocity资源加载器
|
||||
Properties prop = new Properties();
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package cn.bunny.dao.dto.schedulers;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "SchedulersGroupAddDto对象", title = "添加任务调度分组", description = "添加任务调度分组")
|
||||
public class SchedulersGroupAddDto {
|
||||
|
||||
@Schema(name = "groupName", title = "分组名称")
|
||||
@NotBlank(message = "分组名称不能为空")
|
||||
@NotNull(message = "分组名称不能为空")
|
||||
private String groupName;
|
||||
|
||||
@Schema(name = "description", title = "分组详情")
|
||||
private String description;
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package cn.bunny.dao.dto.schedulers;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "SchedulersGroupDto对象", title = "分页查询任务调度分组", description = "分页查询任务调度分组")
|
||||
public class SchedulersGroupDto {
|
||||
|
||||
@Schema(name = "groupName", title = "分组名称")
|
||||
private String groupName;
|
||||
|
||||
@Schema(name = "description", title = "分组详情")
|
||||
private String description;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package cn.bunny.dao.dto.schedulers;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "SchedulersGroupUpdateDto对象", title = "更新任务调度分组", description = "更新任务调度分组")
|
||||
public class SchedulersGroupUpdateDto {
|
||||
|
||||
@Schema(name = "id", title = "主键")
|
||||
@NotNull(message = "id不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "groupName", title = "分组名称")
|
||||
@NotBlank(message = "分组名称不能为空")
|
||||
@NotNull(message = "分组名称不能为空")
|
||||
private String groupName;
|
||||
|
||||
@Schema(name = "description", title = "分组详情")
|
||||
private String description;
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package cn.bunny.dao.entity.schedulers;
|
||||
|
||||
import cn.bunny.dao.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 任务调度分组表
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-10-15
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_schedulers_group")
|
||||
@Schema(name = "SchedulersGroup对象", title = "任务调度分组", description = "任务调度分组")
|
||||
public class SchedulersGroup extends BaseEntity {
|
||||
|
||||
@Schema(name = "groupName", title = "分组名称")
|
||||
private String groupName;
|
||||
|
||||
@Schema(name = "description", title = "分组详情")
|
||||
private String description;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package cn.bunny.dao.vo.schedulers;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "SchedulersGroupVo", title = "任务调度分组返回对象", description = "任务调度分组返回对象")
|
||||
public class SchedulersGroupVo {
|
||||
|
||||
@Schema(name = "groupName", title = "分组名称")
|
||||
private String groupName;
|
||||
|
||||
@Schema(name = "description", title = "分组详情")
|
||||
private String description;
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package cn.bunny.services.controller;
|
||||
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersGroupAddDto;
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersGroupDto;
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersGroupUpdateDto;
|
||||
import cn.bunny.dao.entity.schedulers.SchedulersGroup;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.pojo.result.Result;
|
||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.dao.vo.schedulers.SchedulersGroupVo;
|
||||
import cn.bunny.services.service.SchedulersGroupService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 任务调度分组表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-10-15 20:26:32
|
||||
*/
|
||||
@Tag(name = "任务调度分组", description = "任务调度分组相关接口")
|
||||
@RestController
|
||||
@RequestMapping("admin/schedulersGroup")
|
||||
public class SchedulersGroupController {
|
||||
|
||||
@Autowired
|
||||
private SchedulersGroupService schedulersGroupService;
|
||||
|
||||
@Operation(summary = "分页查询任务调度分组", description = "分页查询任务调度分组")
|
||||
@GetMapping("getSchedulersGroupList/{page}/{limit}")
|
||||
public Mono<Result<PageResult<SchedulersGroupVo>>> getSchedulersGroupList(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@PathVariable("page") Integer page,
|
||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||
@PathVariable("limit") Integer limit,
|
||||
SchedulersGroupDto dto) {
|
||||
Page<SchedulersGroup> pageParams = new Page<>(page, limit);
|
||||
PageResult<SchedulersGroupVo> pageResult = schedulersGroupService.getSchedulersGroupList(pageParams, dto);
|
||||
return Mono.just(Result.success(pageResult));
|
||||
}
|
||||
|
||||
@Operation(summary = "添加任务调度分组", description = "添加任务调度分组")
|
||||
@PostMapping("addSchedulersGroup")
|
||||
public Mono<Result<String>> addSchedulersGroup(@Valid @RequestBody SchedulersGroupAddDto dto) {
|
||||
schedulersGroupService.addSchedulersGroup(dto);
|
||||
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新任务调度分组", description = "更新任务调度分组")
|
||||
@PutMapping("updateSchedulersGroup")
|
||||
public Mono<Result<String>> updateSchedulersGroup(@Valid @RequestBody SchedulersGroupUpdateDto dto) {
|
||||
schedulersGroupService.updateSchedulersGroup(dto);
|
||||
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除任务调度分组", description = "删除任务调度分组")
|
||||
@DeleteMapping("deleteSchedulersGroup")
|
||||
public Mono<Result<String>> deleteSchedulersGroup(@RequestBody List<Long> ids) {
|
||||
schedulersGroupService.deleteSchedulersGroup(ids);
|
||||
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package cn.bunny.services.mapper;
|
||||
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersGroupDto;
|
||||
import cn.bunny.dao.entity.schedulers.SchedulersGroup;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 任务调度分组 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-10-15 20:26:32
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchedulersGroupMapper extends BaseMapper<SchedulersGroup> {
|
||||
|
||||
/**
|
||||
* * 分页查询任务调度分组内容
|
||||
*
|
||||
* @param pageParams 任务调度分组分页参数
|
||||
* @param dto 任务调度分组查询表单
|
||||
* @return 任务调度分组分页结果
|
||||
*/
|
||||
IPage<SchedulersGroup> selectListByPage(@Param("page") Page<SchedulersGroup> pageParams, @Param("dto") SchedulersGroupDto dto);
|
||||
|
||||
/**
|
||||
* 物理删除任务调度分组
|
||||
*
|
||||
* @param ids 删除 id 列表
|
||||
*/
|
||||
void deleteBatchIdsWithPhysics(List<Long> ids);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package cn.bunny.services.service;
|
||||
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersGroupAddDto;
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersGroupDto;
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersGroupUpdateDto;
|
||||
import cn.bunny.dao.entity.schedulers.SchedulersGroup;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.schedulers.SchedulersGroupVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 任务调度分组 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-10-15 20:26:32
|
||||
*/
|
||||
public interface SchedulersGroupService extends IService<SchedulersGroup> {
|
||||
|
||||
/**
|
||||
* * 获取任务调度分组列表
|
||||
*
|
||||
* @return 任务调度分组返回列表
|
||||
*/
|
||||
PageResult<SchedulersGroupVo> getSchedulersGroupList(Page<SchedulersGroup> pageParams, SchedulersGroupDto dto);
|
||||
|
||||
/**
|
||||
* * 添加任务调度分组
|
||||
*
|
||||
* @param dto 添加表单
|
||||
*/
|
||||
void addSchedulersGroup(@Valid SchedulersGroupAddDto dto);
|
||||
|
||||
/**
|
||||
* * 更新任务调度分组
|
||||
*
|
||||
* @param dto 更新表单
|
||||
*/
|
||||
void updateSchedulersGroup(@Valid SchedulersGroupUpdateDto dto);
|
||||
|
||||
/**
|
||||
* * 删除|批量删除任务调度分组类型
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
void deleteSchedulersGroup(List<Long> ids);
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package cn.bunny.services.service.impl;
|
||||
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersGroupAddDto;
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersGroupDto;
|
||||
import cn.bunny.dao.dto.schedulers.SchedulersGroupUpdateDto;
|
||||
import cn.bunny.dao.entity.schedulers.SchedulersGroup;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.schedulers.SchedulersGroupVo;
|
||||
import cn.bunny.services.mapper.SchedulersGroupMapper;
|
||||
import cn.bunny.services.service.SchedulersGroupService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 任务调度分组 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-10-15 20:26:32
|
||||
*/
|
||||
@Service
|
||||
public class SchedulersGroupServiceImpl extends ServiceImpl<SchedulersGroupMapper, SchedulersGroup> implements SchedulersGroupService {
|
||||
|
||||
/**
|
||||
* * 任务调度分组 服务实现类
|
||||
*
|
||||
* @param pageParams 任务调度分组分页查询page对象
|
||||
* @param dto 任务调度分组分页查询对象
|
||||
* @return 查询分页任务调度分组返回对象
|
||||
*/
|
||||
@Override
|
||||
public PageResult<SchedulersGroupVo> getSchedulersGroupList(Page<SchedulersGroup> pageParams, SchedulersGroupDto dto) {
|
||||
// 分页查询菜单图标
|
||||
IPage<SchedulersGroup> page = baseMapper.selectListByPage(pageParams, dto);
|
||||
|
||||
List<SchedulersGroupVo> voList = page.getRecords().stream().map(schedulersGroup -> {
|
||||
SchedulersGroupVo schedulersGroupVo = new SchedulersGroupVo();
|
||||
BeanUtils.copyProperties(schedulersGroup, schedulersGroupVo);
|
||||
return schedulersGroupVo;
|
||||
}).toList();
|
||||
|
||||
return PageResult.<SchedulersGroupVo>builder()
|
||||
.list(voList)
|
||||
.pageNo(page.getCurrent())
|
||||
.pageSize(page.getSize())
|
||||
.total(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加任务调度分组
|
||||
*
|
||||
* @param dto 任务调度分组添加
|
||||
*/
|
||||
@Override
|
||||
public void addSchedulersGroup(@Valid SchedulersGroupAddDto dto) {
|
||||
// 保存数据
|
||||
SchedulersGroup schedulersGroup = new SchedulersGroup();
|
||||
BeanUtils.copyProperties(dto, schedulersGroup);
|
||||
save(schedulersGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务调度分组
|
||||
*
|
||||
* @param dto 任务调度分组更新
|
||||
*/
|
||||
@Override
|
||||
public void updateSchedulersGroup(@Valid SchedulersGroupUpdateDto dto) {
|
||||
// 更新内容
|
||||
SchedulersGroup schedulersGroup = new SchedulersGroup();
|
||||
BeanUtils.copyProperties(dto, schedulersGroup);
|
||||
updateById(schedulersGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除|批量删除任务调度分组
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
@Override
|
||||
public void deleteSchedulersGroup(List<Long> ids) {
|
||||
baseMapper.deleteBatchIdsWithPhysics(ids);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<?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.bunny.services.mapper.SchedulersGroupMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.bunny.dao.entity.schedulers.SchedulersGroup">
|
||||
<id column="id" property="id"/>
|
||||
<id column="create_time" property="createTime"/>
|
||||
<id column="update_time" property="updateTime"/>
|
||||
<id column="create_user" property="createUser"/>
|
||||
<id column="update_user" property="updateUser"/>
|
||||
<id column="is_deleted" property="isDeleted"/>
|
||||
<id column="group_name" property="groupName"/>
|
||||
<id column="description" property="description"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, create_time, update_time, create_user, update_user, is_deleted, group_name, description
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询任务调度分组内容 -->
|
||||
<select id="selectListByPage" resultType="cn.bunny.dao.entity.schedulers.SchedulersGroup">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from sys_schedulers_group
|
||||
<where>
|
||||
<if test="dto.groupName != null and dto.groupName != ''">
|
||||
and group_name like CONCAT('%',#{dto.groupName},'%')
|
||||
</if>
|
||||
<if test="dto.description != null and dto.description != ''">
|
||||
and description like CONCAT('%',#{dto.description},'%')
|
||||
</if>
|
||||
</where>
|
||||
order by update_time desc
|
||||
</select>
|
||||
|
||||
<!-- 物理删除任务调度分组 -->
|
||||
<delete id="deleteBatchIdsWithPhysics">
|
||||
delete
|
||||
from sys_schedulers_group
|
||||
where id in
|
||||
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue