This commit is contained in:
lijiaqi 2024-09-06 11:26:34 +08:00
parent f08c36a65c
commit 45e456491c
14 changed files with 354 additions and 21 deletions

View File

@ -0,0 +1,31 @@
package cn.workde.module.drone.coding.controller;
import cn.workde.core.constant.GrapeConst;
import cn.workde.module.drone.coding.service.AttributeClassificationService;
import cn.workde.module.upms.controller._BaseController;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 无人机属性分类(AttributeClassification)表控制层
*
* @author makejava
* @since 2024-09-06 10:49:53
*/
@Tag(name = "无人机属性分类")
@RestController
@RequestMapping(value = GrapeConst.API + "/attributeClassification")
public class AttributeClassificationController extends _BaseController {
/**
* 服务对象
*/
@Resource
private AttributeClassificationService attributeClassificationService;
}

View File

@ -0,0 +1,32 @@
package cn.workde.module.drone.coding.controller;
import cn.workde.core.constant.GrapeConst;
import cn.workde.module.drone.coding.service.AttributeService;
import cn.workde.module.upms.controller._BaseController;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
/**
* 无人机属性(Attribute)表控制层
*
* @author makejava
* @since 2024-09-06 10:49:52
*/
@Tag(name = "无人机属性")
@RestController
@RequestMapping(value = GrapeConst.API + "/attribute")
public class AttributeController extends _BaseController {
/**
* 服务对象
*/
@Resource
private AttributeService attributeService;
}

View File

@ -0,0 +1,32 @@
package cn.workde.module.drone.coding.controller;
import cn.workde.core.constant.GrapeConst;
import cn.workde.module.drone.coding.service.AttributeValueService;
import cn.workde.module.upms.controller._BaseController;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
/**
* 无人机属性数值(AttributeValue)表控制层
*
* @author makejava
* @since 2024-09-06 10:49:54
*/
@Tag(name = "无人机属性数值")
@RestController
@RequestMapping(value = GrapeConst.API + "/attributeValue")
public class AttributeValueController extends _BaseController {
/**
* 服务对象
*/
@Resource
private AttributeValueService attributeValueService;
}

View File

@ -0,0 +1,38 @@
package cn.workde.module.drone.coding.entity;
import java.util.Date;
import cn.workde.core.base.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* 无人机属性(Attribute)表实体类
*
* @author makejava
* @since 2024-09-06 10:49:53
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName(value = "dss_drone_coding_attribute")
public class Attribute extends BaseEntity {
@Schema(description = "属性分类id")
private String attributeClassificationId;
@Schema(description = "属性名称")
private String attributeName;
@Schema(description = "属性描述")
private String attributeDescription;
@Schema(description = "属性备注")
private String attributeRemarks;
}

View File

@ -0,0 +1,29 @@
package cn.workde.module.drone.coding.entity;
import java.util.Date;
import cn.workde.core.base.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* 无人机属性分类(AttributeClassification)表实体类
*
* @author makejava
* @since 2024-09-06 10:49:53
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName(value = "dss_drone_coding_attribute_classification")
public class AttributeClassification extends BaseEntity {
@Schema(description = "属性分类名称")
private String attributeClassificationName;
}

View File

@ -0,0 +1,38 @@
package cn.workde.module.drone.coding.entity;
import java.util.Date;
import cn.workde.core.base.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* 无人机属性数值(AttributeValue)表实体类
*
* @author makejava
* @since 2024-09-06 10:49:54
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName(value = "dss_drone_coding_attribute_value")
public class AttributeValue extends BaseEntity {
@Schema(description = "批次ID")
private String batchesId;
@Schema(description = "属性分类ID")
private String attributeClassificationId;
@Schema(description = "属性ID")
private String attributeId;
@Schema(description = "属性数值")
private String attributeValue;
}

View File

@ -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.AttributeClassification;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 无人机属性分类(AttributeClassification)表数据库访问层
*
* @author makejava
* @since 2024-09-06 10:49:53
*/
@Mapper
public interface AttributeClassificationMapper extends MPJBaseMapper<AttributeClassification> {
}

View File

@ -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.Attribute;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 无人机属性(Attribute)表数据库访问层
*
* @author makejava
* @since 2024-09-06 10:49:53
*/
@Mapper
public interface AttributeMapper extends MPJBaseMapper<Attribute> {
}

View File

@ -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.AttributeValue;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 无人机属性数值(AttributeValue)表数据库访问层
*
* @author makejava
* @since 2024-09-06 10:49:54
*/
@Mapper
public interface AttributeValueMapper extends MPJBaseMapper<AttributeValue> {
}

View File

@ -0,0 +1,35 @@
package cn.workde.module.drone.coding.service;
import cn.hutool.core.util.StrUtil;
import cn.workde.core.base.BaseService;
import cn.workde.module.drone.coding.mapper.AttributeClassificationMapper;
import cn.workde.module.drone.coding.entity.AttributeClassification;
import cn.workde.module.drone.coding.vo.AttributeClassificationVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
/**
* 无人机属性分类(AttributeClassification)表服务实现类
*
* @author makejava
* @since 2024-09-06 10:49:54
*/
@Service("attributeClassificationService")
public class AttributeClassificationService extends BaseService<AttributeClassificationMapper, AttributeClassification> {
private String check(String id, AttributeClassificationVo vo){
String message = "";
String attributeClassificationName = vo.getAttributeClassificationName();
long count = this.count(new QueryWrapper<AttributeClassification>()
.lambda()
.eq(AttributeClassification::getAttributeClassificationName, attributeClassificationName)
.ne(StrUtil.isNotBlank(id), AttributeClassification::getId, id)
);
if(count > 0){
message = "属性分类名称已存在";
}
return message;
}
}

View File

@ -0,0 +1,18 @@
package cn.workde.module.drone.coding.service;
import cn.workde.core.base.BaseService;
import cn.workde.module.drone.coding.mapper.AttributeMapper;
import cn.workde.module.drone.coding.entity.Attribute;
import org.springframework.stereotype.Service;
/**
* 无人机属性(Attribute)表服务实现类
*
* @author makejava
* @since 2024-09-06 10:49:53
*/
@Service("attributeService")
public class AttributeService extends BaseService<AttributeMapper, Attribute> {
}

View File

@ -0,0 +1,18 @@
package cn.workde.module.drone.coding.service;
import cn.workde.core.base.BaseService;
import cn.workde.module.drone.coding.mapper.AttributeValueMapper;
import cn.workde.module.drone.coding.entity.AttributeValue;
import org.springframework.stereotype.Service;
/**
* 无人机属性数值(AttributeValue)表服务实现类
*
* @author makejava
* @since 2024-09-06 10:49:54
*/
@Service("attributeValueService")
public class AttributeValueService extends BaseService<AttributeValueMapper, AttributeValue> {
}

View File

@ -22,15 +22,17 @@ import java.util.List;
*/
@Service("mfcService")
public class MfcService extends BaseService<MfcMapper, Mfc> {
public Result addMfc(MfcVo vo) {
private String check(String id, MfcVo vo) {
String message = "";
// 校验MFC编号 编号长度必须为4位
if (StrUtil.isBlank(vo.getMfcCode()) || vo.getMfcCode().length() != 4) {
return Result.fail("MFC编号长度必须为4位");
message += " MFC编号长度必须为4位 ";
}
//校验 MFC编号 是否符合要求 4位字符由除大写字母OI的数字(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)及其组合组成");
message += " MFC编号不符合要求 4位字符由除大写字母“O”和“I”的数字(0~9)、大写字母(A~Z)及其组合组成 ";
}
// 校验MFC编号是否已存在
Long count = this.getBaseMapper().selectCount(new QueryWrapper<Mfc>()
@ -38,30 +40,23 @@ public class MfcService extends BaseService<MfcMapper, Mfc> {
.eq(Mfc::getMfcCode, vo.getMfcCode())
);
if (count > 0) {
return Result.fail("MFC编号已存在");
message += " MFC编号已存在 ";
}
return message;
}
public Result addMfc(MfcVo vo) {
String message = check(null, vo);
if (StrUtil.isNotBlank(message)) {
return Result.fail(message);
}
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位字符由除大写字母OI的数字(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编号已存在");
String message = check(id, vo);
if (StrUtil.isNotBlank(message)) {
return Result.fail(message);
}
Mfc obj = this.getById(id);
if (ObjUtil.isNull(obj)) {

View File

@ -0,0 +1,13 @@
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 AttributeClassificationVo {
@Schema(description = "属性分类名称")
@NotBlank(message = "属性分类名称不能为空")
private String attributeClassificationName;
}