| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mdm.controller.admin.category; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.category.vo.MdmItemCategoryPageReqVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.category.vo.MdmItemCategoryRespVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.category.vo.MdmItemCategorySaveReqVO; |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.category.MdmItemCategoryDO; |
| | | import cn.iocoder.yudao.module.mdm.service.category.MdmItemCategoryService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | @Tag(name = "管çåå° - MDM ç©æåç±»") |
| | | @RestController |
| | | @RequestMapping("/mdm/category") |
| | | @Validated |
| | | public class MdmItemCategoryController { |
| | | |
| | | @Resource |
| | | private MdmItemCategoryService itemCategoryService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "åå»ºç©æåç±»") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item-category:create')") |
| | | public CommonResult<Long> createItemCategory(@Valid @RequestBody MdmItemCategorySaveReqVO createReqVO) { |
| | | return success(itemCategoryService.createItemCategory(createReqVO)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "æ´æ°ç©æåç±»") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item-category:update')") |
| | | public CommonResult<Boolean> updateItemCategory(@Valid @RequestBody MdmItemCategorySaveReqVO updateReqVO) { |
| | | itemCategoryService.updateItemCategory(updateReqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/update-status") |
| | | @Operation(summary = "æ´æ°ç©æåç±»ç¶æ") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true, example = "1") |
| | | @Parameter(name = "status", description = "ç¶æ", required = true, example = "0") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item-category:update')") |
| | | public CommonResult<Boolean> updateItemCategoryStatus(@RequestParam("id") Long id, @RequestParam("status") Integer status) { |
| | | itemCategoryService.updateItemCategoryStatus(id, status); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "å é¤ç©æåç±»") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item-category:delete')") |
| | | public CommonResult<Boolean> deleteItemCategory(@RequestParam("id") Long id) { |
| | | itemCategoryService.deleteItemCategory(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾ç©æåç±»") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item-category:query')") |
| | | public CommonResult<MdmItemCategoryRespVO> getItemCategory(@RequestParam("id") Long id) { |
| | | MdmItemCategoryDO itemCategory = itemCategoryService.getItemCategory(id); |
| | | return success(BeanUtils.toBean(itemCategory, MdmItemCategoryRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "è·å¾ç©æåç±»å页") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item-category:query')") |
| | | public CommonResult<PageResult<MdmItemCategoryRespVO>> getItemCategoryPage(@Valid MdmItemCategoryPageReqVO pageReqVO) { |
| | | PageResult<MdmItemCategoryDO> pageResult = itemCategoryService.getItemCategoryPage(pageReqVO); |
| | | return success(BeanUtils.toBean(pageResult, MdmItemCategoryRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | @Operation(summary = "è·å¾ç©æåç±»å表") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item-category:query')") |
| | | public CommonResult<List<MdmItemCategoryRespVO>> getItemCategoryList() { |
| | | List<MdmItemCategoryDO> list = itemCategoryService.getItemCategoryList(null); |
| | | return success(BeanUtils.toBean(list, MdmItemCategoryRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/list-all-simple") |
| | | @Operation(summary = "è·å¾å¯ç¨çåç±»å表") |
| | | public CommonResult<List<MdmItemCategoryRespVO>> getSimpleItemList() { |
| | | List<MdmItemCategoryDO> list = itemCategoryService.getSimpleItemList(); |
| | | return success(BeanUtils.toBean(list, MdmItemCategoryRespVO.class)); |
| | | } |
| | | |
| | | } |