This commit is contained in:
lijiaqi 2024-09-06 13:59:40 +08:00
parent 45e456491c
commit ccea6c874c
2 changed files with 119 additions and 3 deletions

View File

@ -2,12 +2,22 @@ package cn.workde.module.drone.coding.controller;
import cn.workde.core.constant.GrapeConst; import cn.workde.core.constant.GrapeConst;
import cn.workde.core.data.dto.Result;
import cn.workde.module.drone.coding.entity.AttributeClassification;
import cn.workde.module.drone.coding.service.AttributeClassificationService; import cn.workde.module.drone.coding.service.AttributeClassificationService;
import cn.workde.module.drone.coding.vo.AttributeClassificationVo;
import cn.workde.module.upms.controller._BaseController; 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 io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping; import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.RestController; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
@ -26,6 +36,59 @@ public class AttributeClassificationController extends _BaseController {
@Resource @Resource
private AttributeClassificationService attributeClassificationService; private AttributeClassificationService attributeClassificationService;
@PostMapping("/add")
@Operation(summary = "增加")
public Result addAttributeClassification(@RequestBody @Validated AttributeClassificationVo vo)
{
return attributeClassificationService.addAttributeClassification(vo);
}
@PutMapping("/edit/{attributeClassificationId}")
@Operation(summary = "修改")
@Parameters({
@Parameter(name = "attributeClassificationId", description = "属性分类ID", required = true)
})
public Result editAttributeClassification(@RequestBody @Validated AttributeClassificationVo vo,@PathVariable String attributeClassificationId)
{
return attributeClassificationService.editAttributeClassification(attributeClassificationId, vo);
}
@DeleteMapping("/delete/{attributeClassificationId}")
@Operation(summary = "删除")
@Parameters({
@Parameter(name = "attributeClassificationId", description = "属性分类ID", required = true)
})
public Result deleteAttributeClassification(@PathVariable String attributeClassificationId)
{
return attributeClassificationService.deleteAttributeClassification(attributeClassificationId);
}
@GetMapping("/detail")
@Operation(summary = "详情")
@Parameters({
@Parameter(name = "attributeClassificationId", description = "属性分类ID", required = true)
})
public Result<AttributeClassification> getAttributeClassificationDetail(String attributeClassificationId)
{
return attributeClassificationService.getAttributeClassificationDetail(attributeClassificationId);
}
@GetMapping("/page")
@Operation(summary = "分页查询")
@Parameters({
@Parameter(name = "current", description = "当前页", required = true),
@Parameter(name = "size", description = "每页数量", required = true)
})
public Result<Page<AttributeClassification>> getAttributeClassificationPageList(@ParameterObject AttributeClassificationVo vo)
{
return attributeClassificationService.getAttributeClassificationPageList(getPage(), vo);
}
@GetMapping("/list")
@Operation(summary = "列表查询")
public Result<List<AttributeClassification>> list()
{
return attributeClassificationService.getAttributeClassificationList();
}
} }

View File

@ -1,13 +1,19 @@
package cn.workde.module.drone.coding.service; 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.hutool.core.util.StrUtil;
import cn.workde.core.base.BaseService; import cn.workde.core.base.BaseService;
import cn.workde.module.drone.coding.mapper.AttributeClassificationMapper; import cn.workde.core.data.dto.Result;
import cn.workde.module.drone.coding.entity.AttributeClassification; import cn.workde.module.drone.coding.entity.AttributeClassification;
import cn.workde.module.drone.coding.mapper.AttributeClassificationMapper;
import cn.workde.module.drone.coding.vo.AttributeClassificationVo; import cn.workde.module.drone.coding.vo.AttributeClassificationVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* 无人机属性分类(AttributeClassification)表服务实现类 * 无人机属性分类(AttributeClassification)表服务实现类
* *
@ -31,5 +37,52 @@ public class AttributeClassificationService extends BaseService<AttributeClassif
return message; return message;
} }
public Result addAttributeClassification(AttributeClassificationVo vo) {
String message = check("", vo);
if (StrUtil.isNotBlank(message)) {
return Result.fail(message);
}
AttributeClassification obj = BeanUtil.copyProperties(vo, AttributeClassification.class);
return this.saveOrUpdate(obj) ? Result.success("操作成功") : Result.fail("操作失败");
}
public Result editAttributeClassification(String id, AttributeClassificationVo vo) {
String message = check(id, vo);
if (StrUtil.isNotBlank(message)) {
return Result.fail(message);
}
AttributeClassification obj = getById(id);
if (ObjUtil.isNull(obj)) {
return Result.fail("数据不存在");
}
BeanUtil.copyProperties(vo, obj);
return this.saveOrUpdate(obj) ? Result.success("操作成功") : Result.fail("操作失败");
}
public Result deleteAttributeClassification(String id) {
if (ObjUtil.isNull(this.getById(id))) {
return Result.fail("数据不存在");
}
return this.removeById(id) ? Result.success("操作成功") : Result.fail("操作失败");
}
public Result<AttributeClassification> getAttributeClassificationDetail(String id) {
AttributeClassification obj = this.getById(id);
if (ObjUtil.isNull(obj)) {
return Result.fail("数据不存在");
}
return Result.data(obj);
}
public Result<Page<AttributeClassification>> getAttributeClassificationPageList(Page page, AttributeClassificationVo vo) {
return Result.data(this.page(page, new QueryWrapper<AttributeClassification>()
.lambda()
.like(StrUtil.isNotBlank(vo.getAttributeClassificationName()), AttributeClassification::getAttributeClassificationName, vo.getAttributeClassificationName())
));
}
public Result<List<AttributeClassification>> getAttributeClassificationList() {
return Result.data(this.list());
}
} }