| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.pojo.Standards; |
| | | import com.yuanchu.limslaboratory.service.StandardsService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | |
| | | 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.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | | * @since 2023-07-11 |
| | | */ |
| | | @Api(tags = "标准库操作") |
| | | @Api(tags = "标准库-->⭐⭐⭐") |
| | | @RestController |
| | | @RequestMapping("/standards") |
| | | public class StandardsController { |
| | |
| | | return Result.fail("添加【"+ standards.getName() +"】失败!"); |
| | | } |
| | | |
| | | @ApiOperation("标准库-->点击全部:查询所有标准数据") |
| | | @ApiOperation("标准库-->侧边栏查询所有标准数据") |
| | | @GetMapping("/list") |
| | | public Result<?> listStandardsInformation(){ |
| | | List<Map<String, Object>> list = standardsService.listStandardsInformation(); |
| | | return Result.success(list); |
| | | } |
| | | |
| | | @ApiOperation("标准库-->点击全部:分页查询所有标准数据") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageNo", value = "起始页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "每一页数量", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(value = "标准号/标准名称", name = "IdOrNameOfStandards", dataTypeClass = String.class) |
| | | }) |
| | | @GetMapping("/list") |
| | | public Result<?> listStandardsInformation(String IdOrNameOfStandards){ |
| | | List<Map<String, Object>> list = standardsService.listStandardsInformation(IdOrNameOfStandards); |
| | | return Result.success(list); |
| | | @GetMapping("/list_page") |
| | | public Result<?> listPageStandardsInformation(Integer pageNo, Integer pageSize, String IdOrNameOfStandards){ |
| | | IPage<Map<String, Object>> listPage = standardsService.listPageStandardsInformation(new Page<Object>(pageNo, pageSize), IdOrNameOfStandards); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("row", listPage.getRecords()); |
| | | map.put("total", listPage.getTotal()); |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @ApiOperation("标准库-->根据Id修改参数") |
| | | @PutMapping("/update") |
| | | public Result<?> updateStandardsInformation(@RequestHeader("X-Token") String token, @RequestBody Standards standards) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | standards.setUserId((Integer) unmarshal.get("id")); |
| | | Integer isUpdateSuccess = standardsService.updateStandardsInformation(standards); |
| | | if (isUpdateSuccess == 1){ |
| | | return Result.success("更新成功!"); |
| | | } |
| | | return Result.fail("更新失败!"); |
| | | } |
| | | |
| | | @ApiOperation("标准库-->根据ID删除数据") |
| | | @DeleteMapping("/delete") |
| | | public Result<?> deleteStandardsInformation(String standardsId) { |
| | | Integer isDeleteSuccess = standardsService.deleteStandardsInformation(standardsId); |
| | | if (isDeleteSuccess == 1){ |
| | | return Result.success("删除成功!"); |
| | | } |
| | | return Result.fail("删除失败!"); |
| | | } |
| | | } |