| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.yuanchu.limslaboratory.pojo.Classify; |
| | | import com.yuanchu.limslaboratory.pojo.dto.UpdateClassifyDto; |
| | | import com.yuanchu.limslaboratory.service.ClassifyService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | | * @since 2023-07-20 |
| | | */ |
| | | @Api(tags = "实验室-->设备台账-->1、分类模块") |
| | | @RestController |
| | | @RequestMapping("/classify") |
| | | public class ClassifyController { |
| | | |
| | | @Autowired |
| | | private ClassifyService classifyService; |
| | | |
| | | @ApiOperation("添加分类:如果选择了name即添加的为子节点数据;如果没有选择即添加的为父节点数据;后台处理") |
| | | @PostMapping("/add") |
| | | public Result<?> addClassifyInformation(@RequestBody Classify classify) { |
| | | if (ObjectUtils.isEmpty(classify.getSonName())){ |
| | | return Result.fail("请填写分类名称!"); |
| | | } |
| | | Integer isAddClassifySuccess = classifyService.addClassifyInformation(classify); |
| | | if (isAddClassifySuccess == 1) { |
| | | if (ObjectUtils.isEmpty(classify.getSonName())){ |
| | | return Result.success("添加父级【"+ classify.getFatherName() +"】分类成功!"); |
| | | } |
| | | return Result.success("添加分类【"+ classify.getSonName() +"】成功!"); |
| | | } else if (isAddClassifySuccess == 2){ |
| | | return Result.fail("抱歉重复添加父级【"+ classify.getFatherName() +"】分类,添加失败!"); |
| | | } else if (isAddClassifySuccess == 3) { |
| | | return Result.fail("抱歉重复添加子级【"+ classify.getSonName() +"】,添加失败!"); |
| | | } |
| | | return Result.fail("添加分类【"+ classify.getSonName() +"】失败!"); |
| | | } |
| | | |
| | | @ApiOperation("分类侧边栏列表:如果sonName为空,则带着father_name的Id进行点击操作") |
| | | @GetMapping("/list") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(value = "分类名称", name = "classifyName", dataTypeClass = String.class) |
| | | }) |
| | | public Result<?> getListClassifyInformation(String classifyName) { |
| | | return Result.success(classifyService.getListClassifyInformation(classifyName)); |
| | | } |
| | | |
| | | @ApiOperation("删除分类") |
| | | @DeleteMapping("/delete") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(value = "分类Id", name = "classifyId", dataTypeClass = String.class) |
| | | }) |
| | | public Result<?> deleteClassifyInformation(String classifyId) { |
| | | Boolean isDeleteSuccess = classifyService.deleteClassifyInformation(classifyId); |
| | | if (isDeleteSuccess){ |
| | | return Result.success("删除分类成功!"); |
| | | } |
| | | return Result.fail("删除分类失败!"); |
| | | } |
| | | |
| | | @ApiOperation("更新分类") |
| | | @PutMapping("/update") |
| | | public Result<?> updateClassifyInformation(@RequestBody UpdateClassifyDto updateClassifyDto) throws Exception { |
| | | Classify classify = JackSonUtil.unmarshal(JackSonUtil.marshal(updateClassifyDto), Classify.class); |
| | | Boolean isUpdateClassifySuccess = classifyService.updateClassifyInformation(classify); |
| | | if (isUpdateClassifySuccess){ |
| | | return Result.success("更新分类成功!"); |
| | | } |
| | | return Result.fail("更新分类失败!"); |
| | | } |
| | | } |