init
This commit is contained in:
parent
bb0d61bf69
commit
beda2d25eb
|
@ -0,0 +1,81 @@
|
|||
package cn.workde.module.drone.coding.controller;
|
||||
|
||||
|
||||
|
||||
import cn.workde.core.constant.GrapeConst;
|
||||
import cn.workde.core.data.dto.Result;
|
||||
import cn.workde.module.drone.coding.entity.Batches;
|
||||
import cn.workde.module.drone.coding.service.BatchesService;
|
||||
import cn.workde.module.drone.coding.vo.BatchesVo;
|
||||
import cn.workde.module.upms.controller._BaseController;
|
||||
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.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 无人机批次表(Batches)表控制层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-09-05 14:46:51
|
||||
*/
|
||||
@Tag(name = "批次管理")
|
||||
@RestController
|
||||
@RequestMapping(value = GrapeConst.API + "/batches")
|
||||
public class BatchesController extends _BaseController {
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Resource
|
||||
private BatchesService batchesService;
|
||||
|
||||
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "增加")
|
||||
public Result add(@RequestBody BatchesVo vo) {
|
||||
return batchesService.addBatches(vo);
|
||||
}
|
||||
|
||||
@PutMapping("/edit/{batchId}")
|
||||
@Operation(summary = "编辑")
|
||||
@Parameters({
|
||||
@Parameter(name = "batchId", description = "批次ID", required = true)
|
||||
})
|
||||
public Result edit(@RequestBody BatchesVo vo, @PathVariable String batchId) {
|
||||
return batchesService.editBatches(batchId, vo);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{batchId}")
|
||||
@Operation(summary = "删除")
|
||||
@Parameters({
|
||||
@Parameter(name = "batchId", description = "批次ID", required = true)
|
||||
})
|
||||
public Result delete(@PathVariable String batchId) {
|
||||
return batchesService.deleteBatches(batchId);
|
||||
}
|
||||
|
||||
@GetMapping("/detail")
|
||||
@Operation(summary = "详情")
|
||||
@Parameters({
|
||||
@Parameter(name = "batchId", description = "批次ID", required = true)
|
||||
})
|
||||
public Result<Batches> detail(String batchId) {
|
||||
return batchesService.getBatchesDetail(batchId);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "分页查询")
|
||||
@Parameters({
|
||||
@Parameter(name = "current", description = "当前页", required = true),
|
||||
@Parameter(name = "size", description = "每页数量", required = true)
|
||||
})
|
||||
public Result<Page<Batches>> page(@ParameterObject BatchesVo vo) {
|
||||
return batchesService.getBatchesPageList(getPage(), vo);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
package cn.workde.module.drone.coding.controller;
|
||||
|
||||
|
||||
|
||||
import cn.workde.core.constant.GrapeConst;
|
||||
import cn.workde.core.data.dto.Result;
|
||||
import cn.workde.module.drone.coding.entity.Mfc;
|
||||
import cn.workde.module.drone.coding.service.MfcService;
|
||||
import cn.workde.module.drone.coding.vo.MfcVo;
|
||||
import cn.workde.module.upms.controller._BaseController;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import cn.workde.module.drone.coding.entity.Mfc;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 无人机MFC表(Mfc)表控制层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-09-05 16:50:19
|
||||
*/
|
||||
@Tag(name = "MFC管理")
|
||||
@RestController
|
||||
@RequestMapping(value = GrapeConst.API + "/mfc")
|
||||
public class MfcController extends _BaseController {
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Resource
|
||||
private MfcService mfcService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "增加")
|
||||
public Result add(@RequestBody @Validated MfcVo vo) {
|
||||
return mfcService.addMfc(vo);
|
||||
}
|
||||
|
||||
@PutMapping("/edit/{mfcId}")
|
||||
@Operation(summary = "编辑")
|
||||
@Parameters({
|
||||
@Parameter(name = "mfcId", description = "MFC ID", required = true)
|
||||
})
|
||||
public Result edit(@RequestBody @Validated MfcVo vo, @PathVariable String mfcId) {
|
||||
return mfcService.editMfc(mfcId, vo);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{mfcId}")
|
||||
@Operation(summary = "删除")
|
||||
@Parameters({
|
||||
@Parameter(name = "mfcId", description = "MFC ID", required = true)
|
||||
})
|
||||
public Result delete(@PathVariable String mfcId) {
|
||||
return mfcService.deleteMfc(mfcId);
|
||||
}
|
||||
|
||||
@GetMapping("/detail")
|
||||
@Operation(summary = "详情")
|
||||
@Parameters({
|
||||
@Parameter(name = "mfcId", description = "MFC ID", required = true)
|
||||
})
|
||||
public Result<Mfc> detail(String mfcId) {
|
||||
return mfcService.getMfcDetail(mfcId);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "分页查询")
|
||||
@Parameters({
|
||||
@Parameter(name = "current", description = "当前页", required = true),
|
||||
@Parameter(name = "size", description = "每页数量", required = true)
|
||||
})
|
||||
public Result<Page<Mfc>> page(@ParameterObject MfcVo vo) {
|
||||
return mfcService.getMfcPageList(getPage(), vo);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package cn.workde.module.drone.coding.entity;
|
||||
|
||||
import cn.workde.core.base.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 无人机批次表(Batches)表实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-09-05 14:46:54
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName(value = "dss_drone_coding_batches")
|
||||
public class Batches extends BaseEntity {
|
||||
|
||||
@Schema(description = "批次编号")
|
||||
private String batchesCode;
|
||||
|
||||
@Schema(description = "批次名称")
|
||||
private String batchesName;
|
||||
|
||||
@Schema(description = "批次描述")
|
||||
private String batchesDescription;
|
||||
|
||||
@Schema(description = "所属MFC ID")
|
||||
private String mfcId;
|
||||
|
||||
@Schema(description = "规则ID")
|
||||
private String ruleId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package cn.workde.module.drone.coding.entity;
|
||||
|
||||
import cn.workde.core.base.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 无人机MFC表(Mfc)表实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-09-05 16:50:21
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName(value = "dss_drone_coding_batches")
|
||||
public class Mfc extends BaseEntity {
|
||||
|
||||
@Schema(description = "MFC编号")
|
||||
private String mfcCode;
|
||||
|
||||
@Schema(description = "制造商名称")
|
||||
private String mfcName;
|
||||
|
||||
@Schema(description = "制造商描述")
|
||||
private String mfcDescription;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package cn.workde.module.drone.coding.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.workde.module.drone.coding.entity.Batches;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 无人机批次表(Batches)表数据库访问层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-09-05 14:46:52
|
||||
*/
|
||||
@Mapper
|
||||
public interface BatchesMapper extends MPJBaseMapper<Batches> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package cn.workde.module.drone.coding.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.workde.module.drone.coding.entity.Mfc;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 无人机MFC表(Mfc)表数据库访问层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-09-05 16:50:19
|
||||
*/
|
||||
@Mapper
|
||||
public interface MfcMapper extends MPJBaseMapper<Mfc> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package cn.workde.module.drone.coding.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.workde.core.base.BaseService;
|
||||
import cn.workde.core.data.dto.Result;
|
||||
import cn.workde.module.drone.coding.entity.Batches;
|
||||
import cn.workde.module.drone.coding.mapper.BatchesMapper;
|
||||
import cn.workde.module.drone.coding.vo.BatchesVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 无人机批次表(Batches)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-09-05 14:47:00
|
||||
*/
|
||||
@Service("batchesService")
|
||||
public class BatchesService extends BaseService<BatchesMapper, Batches> {
|
||||
|
||||
public Result addBatches(BatchesVo vo) {
|
||||
Long count = this.getBaseMapper().selectCount(new QueryWrapper<Batches>()
|
||||
.lambda()
|
||||
.eq(Batches::getBatchesCode, vo.getBatchesCode())
|
||||
);
|
||||
if (count > 0) {
|
||||
return Result.fail("批次编号已存在");
|
||||
}
|
||||
Batches obj = BeanUtil.copyProperties(vo, Batches.class);
|
||||
return this.saveOrUpdate(obj) ? Result.success("操作成功") : Result.fail("操作失败");
|
||||
}
|
||||
|
||||
public Result editBatches(String id, BatchesVo vo) {
|
||||
Long count = this.getBaseMapper().selectCount(new QueryWrapper<Batches>()
|
||||
.lambda()
|
||||
.eq(Batches::getBatchesCode, vo.getBatchesCode())
|
||||
.ne(Batches::getId, id)
|
||||
);
|
||||
if (count > 0) {
|
||||
return Result.fail("批次编号已存在");
|
||||
}
|
||||
Batches obj = this.getById(id);
|
||||
if (ObjUtil.isNull(obj)) {
|
||||
return Result.fail("数据不存在");
|
||||
}
|
||||
BeanUtil.copyProperties(vo, obj);
|
||||
return this.saveOrUpdate(obj) ? Result.success("操作成功") : Result.fail("操作失败");
|
||||
}
|
||||
|
||||
public Result deleteBatches(String id) {
|
||||
if (ObjUtil.isNull(this.getById(id))) {
|
||||
return Result.fail("数据不存在");
|
||||
}
|
||||
return this.removeById(id) ? Result.success("操作成功") : Result.fail("操作失败");
|
||||
}
|
||||
|
||||
public Result<Batches> getBatchesDetail(String id) {
|
||||
Batches obj = this.getById(id);
|
||||
if (ObjUtil.isNull(obj)) {
|
||||
return Result.fail("数据不存在");
|
||||
}
|
||||
return Result.data(obj);
|
||||
}
|
||||
|
||||
public Result<Page<Batches>> getBatchesPageList(Page page, BatchesVo vo) {
|
||||
Page paged = this.page(page, new QueryWrapper<Batches>()
|
||||
.lambda()
|
||||
.like(StrUtil.isNotBlank(vo.getBatchesCode()), Batches::getBatchesCode, vo.getBatchesCode())
|
||||
.like(StrUtil.isNotBlank(vo.getBatchesName()), Batches::getBatchesName, vo.getBatchesName())
|
||||
.like(StrUtil.isNotBlank(vo.getBatchesDescription()), Batches::getBatchesDescription, vo.getBatchesDescription())
|
||||
);
|
||||
return Result.data(paged);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
package cn.workde.module.drone.coding.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.workde.core.base.BaseService;
|
||||
import cn.workde.core.data.dto.Result;
|
||||
import cn.workde.module.drone.coding.entity.Mfc;
|
||||
import cn.workde.module.drone.coding.mapper.MfcMapper;
|
||||
import cn.workde.module.drone.coding.vo.MfcVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 无人机MFC表(Mfc)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-09-05 16:50:21
|
||||
*/
|
||||
@Service("mfcService")
|
||||
public class MfcService extends BaseService<MfcMapper, Mfc> {
|
||||
public Result addMfc(MfcVo vo) {
|
||||
// 校验MFC编号 编号长度必须为4位
|
||||
if (StrUtil.isBlank(vo.getMfcCode()) || vo.getMfcCode().length() != 4) {
|
||||
return Result.fail("MFC编号长度必须为4位");
|
||||
}
|
||||
//校验 MFC编号 是否符合要求 4位字符由除大写字母“O”和“I”的数字(0~9)、大写字母(A~Z)及其组合组成
|
||||
String regex = "^[A-HJ-NP-Z0-9]{4}$";
|
||||
if (!vo.getMfcCode().matches(regex)) {
|
||||
return Result.fail("MFC编号不符合要求 4位字符由除大写字母“O”和“I”的数字(0~9)、大写字母(A~Z)及其组合组成");
|
||||
}
|
||||
// 校验MFC编号是否已存在
|
||||
Long count = this.getBaseMapper().selectCount(new QueryWrapper<Mfc>()
|
||||
.lambda()
|
||||
.eq(Mfc::getMfcCode, vo.getMfcCode())
|
||||
);
|
||||
if (count > 0) {
|
||||
return Result.fail("MFC编号已存在");
|
||||
}
|
||||
Mfc obj = BeanUtil.copyProperties(vo, Mfc.class);
|
||||
return this.saveOrUpdate(obj) ? Result.success("操作成功") : Result.fail("操作失败");
|
||||
}
|
||||
|
||||
public Result editMfc(String id, MfcVo vo) {
|
||||
// 校验MFC编号 编号长度必须为4位
|
||||
if (StrUtil.isBlank(vo.getMfcCode()) || vo.getMfcCode().length() != 4) {
|
||||
return Result.fail("MFC编号长度必须为4位");
|
||||
}
|
||||
//校验 MFC编号 是否符合要求 4位字符由除大写字母“O”和“I”的数字(0~9)、大写字母(A~Z)及其组合组成
|
||||
String regex = "^[A-HJ-NP-Z0-9]{4}$";
|
||||
if (!vo.getMfcCode().matches(regex)) {
|
||||
return Result.fail("MFC编号不符合要求 4位字符由除大写字母“O”和“I”的数字(0~9)、大写字母(A~Z)及其组合组成");
|
||||
}
|
||||
// 校验MFC编号是否已存在
|
||||
Long count = this.getBaseMapper().selectCount(new QueryWrapper<Mfc>()
|
||||
.lambda()
|
||||
.eq(Mfc::getMfcCode, vo.getMfcCode())
|
||||
.ne(Mfc::getId, id)
|
||||
);
|
||||
if (count > 0) {
|
||||
return Result.fail("MFC编号已存在");
|
||||
}
|
||||
Mfc obj = this.getById(id);
|
||||
if (ObjUtil.isNull(obj)) {
|
||||
return Result.fail("数据不存在");
|
||||
}
|
||||
BeanUtil.copyProperties(vo, obj);
|
||||
return this.saveOrUpdate(obj) ? Result.success("操作成功") : Result.fail("操作失败");
|
||||
}
|
||||
|
||||
public Result deleteMfc(String id) {
|
||||
if (ObjUtil.isNull(this.getById(id))) {
|
||||
return Result.fail("数据不存在");
|
||||
}
|
||||
return this.removeById(id) ? Result.success("操作成功") : Result.fail("操作失败");
|
||||
}
|
||||
|
||||
public Result<Mfc> getMfcDetail(String id) {
|
||||
Mfc obj = this.getById(id);
|
||||
if (ObjUtil.isNull(obj)) {
|
||||
return Result.fail("数据不存在");
|
||||
}
|
||||
return Result.data(obj);
|
||||
}
|
||||
|
||||
public Result<Page<Mfc>> getMfcPageList(Page page, MfcVo vo) {
|
||||
Page paged = this.page(page, new QueryWrapper<Mfc>()
|
||||
.lambda()
|
||||
.like(StrUtil.isNotBlank(vo.getMfcCode()), Mfc::getMfcCode, vo.getMfcCode())
|
||||
.like(StrUtil.isNotBlank(vo.getMfcName()), Mfc::getMfcName, vo.getMfcName())
|
||||
.like(StrUtil.isNotBlank(vo.getMfcDescription()), Mfc::getMfcDescription, vo.getMfcDescription())
|
||||
);
|
||||
return Result.data(paged);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package cn.workde.module.drone.coding.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BatchesVo {
|
||||
|
||||
@Schema(description = "批次编号")
|
||||
@NotBlank(message = "批次编号不能为空")
|
||||
private String batchesCode;
|
||||
|
||||
@Schema(description = "批次名称")
|
||||
@NotBlank(message = "批次名称不能为空")
|
||||
private String batchesName;
|
||||
|
||||
@Schema(description = "批次描述")
|
||||
@NotBlank(message = "批次描述不能为空")
|
||||
private String batchesDescription;
|
||||
|
||||
@Schema(description = "所属MFC ID")
|
||||
@NotBlank(message = "请选择所属MFC")
|
||||
private String mfcId;
|
||||
|
||||
@Schema(description = "规则ID")
|
||||
@NotBlank(message = "请选择规则")
|
||||
private String ruleId;
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package cn.workde.module.drone.coding.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MfcVo {
|
||||
|
||||
@Schema(description = "MFC编号")
|
||||
@NotBlank(message = "MFC编号不能为空")
|
||||
private String mfcCode;
|
||||
|
||||
@Schema(description = "制造商名称")
|
||||
@NotBlank(message = "制造商名称不能为空")
|
||||
private String mfcName;
|
||||
|
||||
@Schema(description = "制造商描述")
|
||||
@NotBlank(message = "制造商描述不能为空")
|
||||
private String mfcDescription;
|
||||
|
||||
|
||||
}
|
|
@ -1,12 +1,38 @@
|
|||
package cn.workde.module.upms.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.workde.core.util.HttpServletUtil;
|
||||
import cn.workde.module.upms.entity.GrapeAdmin;
|
||||
import cn.workde.module.upms.interceptor.UpmsInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class _BaseController {
|
||||
|
||||
@Autowired
|
||||
protected HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
protected HttpServletResponse response;
|
||||
|
||||
protected Integer getPageNum() {
|
||||
String pageNum = request.getParameter("current");
|
||||
return StrUtil.isBlank(pageNum) ? 1 : Convert.toInt(pageNum);
|
||||
}
|
||||
|
||||
protected Integer getPageSize() {
|
||||
String limit = request.getParameter("size");
|
||||
return StrUtil.isBlank(limit) ? 20 : Convert.toInt(limit);
|
||||
}
|
||||
|
||||
protected Page getPage() {
|
||||
return new Page<>(getPageNum(), getPageSize());
|
||||
}
|
||||
|
||||
public GrapeAdmin getLoginAdmin() {
|
||||
return (GrapeAdmin) HttpServletUtil.getRequest().getAttribute(UpmsInterceptor.ADMIN_LOGGER);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue