| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.BeanUtils; |
| | | import com.ruoyi.system.domain.TbBasicDataCategory; |
| | | import com.ruoyi.system.dto.BasicDataCategoryDTO; |
| | | import com.ruoyi.system.dto.ShowHideDTO; |
| | | import com.ruoyi.system.dto.update.BasicDataCategoryUpdateDTO; |
| | | import com.ruoyi.system.query.BasicDataCategoryQuery; |
| | | import com.ruoyi.system.service.TbBasicDataCategoryService; |
| | | import com.ruoyi.system.vo.BasicDataCategoryVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author mitao |
| | | * @since 2024-03-13 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/tb-basic-data-category") |
| | | @RequiredArgsConstructor |
| | | @Api(tags = {"基础数据分类相关接口"}) |
| | | @RequestMapping("/basic-data-category") |
| | | public class TbBasicDataCategoryController { |
| | | |
| | | private final TbBasicDataCategoryService tbBasicDataCategoryService; |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param dto 基础数据分类传输对象 |
| | | * @return R<Void> |
| | | */ |
| | | @PostMapping("/add") |
| | | @ApiOperation("添加") |
| | | public R<Void> add(@RequestBody @Validated BasicDataCategoryDTO dto) { |
| | | tbBasicDataCategoryService.add(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param dto 基础数据分类更新传输对象 |
| | | * @return R<Void> |
| | | */ |
| | | @PostMapping("/edit") |
| | | @ApiOperation("编辑") |
| | | public R<Void> add(@RequestBody @Validated BasicDataCategoryUpdateDTO dto) { |
| | | tbBasicDataCategoryService.update(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | * @param id id |
| | | * @return R<Void> |
| | | */ |
| | | @DeleteMapping("/delete") |
| | | @ApiOperation("删除") |
| | | public R<Void> delete(@RequestParam(value = "id") Integer id){ |
| | | tbBasicDataCategoryService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 根据id获取详情 |
| | | * @param id id |
| | | * @return R<BasicDataCategoryVO> |
| | | */ |
| | | @GetMapping("/get-details") |
| | | @ApiOperation("根据id获取详情") |
| | | public R<BasicDataCategoryVO> getDetails(@RequestParam(value = "id") Integer id){ |
| | | TbBasicDataCategory basicDataCategory = tbBasicDataCategoryService.getById(id); |
| | | BasicDataCategoryVO vo = BeanUtils.copyBean(basicDataCategory, BasicDataCategoryVO.class); |
| | | return R.ok(vo); |
| | | } |
| | | |
| | | /** |
| | | * 隐藏显示操作 |
| | | * @param dto 显示隐藏操作数据传输对象 |
| | | * @return R<Void> |
| | | */ |
| | | @PostMapping("/show-hide") |
| | | @ApiOperation("隐藏显示操作") |
| | | public R<Void> showHide(@RequestBody ShowHideDTO dto) { |
| | | TbBasicDataCategory basicDataCategory = tbBasicDataCategoryService.getById(dto.getId()); |
| | | if (Objects.isNull(basicDataCategory)) { |
| | | throw new RuntimeException("非法参数"); |
| | | } |
| | | tbBasicDataCategoryService.lambdaUpdate().set( TbBasicDataCategory::getStatus, dto.getStatus()).eq(TbBasicDataCategory::getId, dto.getId()).update(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 分页条件查询 |
| | | * @param query 基础数据分类条件查询对象 |
| | | * @return R<PageDTO<BasicDataCategoryVO>> |
| | | */ |
| | | @PostMapping("/page") |
| | | @ApiOperation("分页条件查询") |
| | | public R<PageDTO<BasicDataCategoryVO>> page(@RequestBody BasicDataCategoryQuery query) { |
| | | return R.ok(tbBasicDataCategoryService.queryPage(query)); |
| | | } |
| | | |
| | | } |
| | | |