| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.cloud.admin; |
| | | |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.config.annotation.CloudRequiredPermission; |
| | | import com.doumee.core.annotation.excel.ExcelExporter; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.service.business.third.model.ApiResponse; |
| | | import com.doumee.service.business.third.model.PageData; |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.business.model.Category; |
| | | import com.doumee.service.business.CategoryService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/11/30 15:33 |
| | | */ |
| | | @Api(tags = "å类信æ¯è¡¨") |
| | | @RestController |
| | | @RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX+"/business/category") |
| | | public class CategoryCloudController extends BaseController { |
| | | |
| | | @Autowired |
| | | private CategoryService categoryService; |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("æ°å»º") |
| | | @PostMapping("/create") |
| | | @CloudRequiredPermission("business:category:create") |
| | | public ApiResponse create(@RequestBody Category category,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | category.setLoginUserInfo(this.getLoginUser(token)); |
| | | return ApiResponse.success(categoryService.create(category)); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDå é¤") |
| | | @GetMapping("/delete/{id}") |
| | | @CloudRequiredPermission("business:category:delete") |
| | | public ApiResponse deleteById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | categoryService.deleteById(id); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("æ¹éå é¤") |
| | | @GetMapping("/delete/batch") |
| | | @CloudRequiredPermission("business:category:delete") |
| | | public ApiResponse deleteByIdInBatch(@RequestParam String ids,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | String [] idArray = ids.split(","); |
| | | List<Integer> idList = new ArrayList<>(); |
| | | for (String id : idArray){ |
| | | idList.add(Integer.valueOf(id)); |
| | | } |
| | | categoryService.deleteByIdInBatch(idList); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDä¿®æ¹") |
| | | @PostMapping("/updateById") |
| | | @CloudRequiredPermission("business:category:update") |
| | | public ApiResponse updateById(@RequestBody Category category,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | categoryService.updateById(category); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("å页æ¥è¯¢") |
| | | @PostMapping("/page") |
| | | @CloudRequiredPermission("business:category:query") |
| | | public ApiResponse<PageData<Category>> findPage (@RequestBody PageWrap<Category> pageWrap,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | return ApiResponse.success(categoryService.findPage(pageWrap)); |
| | | } |
| | | |
| | | @ApiOperation("å表æ¥è¯¢") |
| | | @PostMapping("/list") |
| | | @CloudRequiredPermission("business:category:query") |
| | | public ApiResponse<List<Category>> findList (@RequestBody Category category,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | return ApiResponse.success(categoryService.queryList(category)); |
| | | } |
| | | |
| | | @ApiOperation("导åºExcel") |
| | | @PostMapping("/exportExcel") |
| | | @CloudRequiredPermission("business:category:exportExcel") |
| | | public void exportExcel (@RequestBody PageWrap<Category> pageWrap, HttpServletResponse response,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | ExcelExporter.build(Category.class).export(categoryService.findPage(pageWrap).getRecords(), "å类信æ¯è¡¨", response); |
| | | } |
| | | @ApiOperation("导åºäºçº§åç±»æ°æ®Excel") |
| | | @PostMapping("/exportChildExcel") |
| | | @CloudRequiredPermission("business:category:exportExcel") |
| | | public void exportChildExcel (@RequestBody PageWrap<Category> pageWrap, HttpServletResponse response,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | // pageWrap.getModel().setType(Constants.ONE); |
| | | ExcelExporter.build(Category.class).export(categoryService.findChileList(pageWrap.getModel()), "车è¾å类信æ¯è¡¨", response); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDæ¥è¯¢") |
| | | @GetMapping("/{id}") |
| | | @CloudRequiredPermission("business:category:query") |
| | | public ApiResponse findById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | return ApiResponse.success(categoryService.findById(id)); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDæ¥è¯¢") |
| | | @GetMapping("/findListByStatus") |
| | | @CloudRequiredPermission("business:category:query") |
| | | public ApiResponse<List<Category>> findListByStatus(@RequestParam("type") Integer type){ |
| | | Category category = new Category(); |
| | | category.setIsdeleted(Constants.ZERO); |
| | | category.setStatus(Constants.ZERO); |
| | | category.setType(type); |
| | | return ApiResponse.success(categoryService.findList(category)); |
| | | } |
| | | |
| | | |
| | | } |