123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package cn.cslg.pas.controller;
- import cn.cslg.pas.common.core.base.Constants;
- import cn.cslg.pas.common.dto.business.*;
- import cn.cslg.pas.common.model.cronModel.Records;
- import cn.cslg.pas.common.utils.Response;
- import cn.cslg.pas.exception.ConditionException;
- import cn.cslg.pas.exception.UnLoginException;
- import cn.cslg.pas.exception.XiaoShiException;
- import cn.cslg.pas.service.business.CustomOptionService;
- import io.swagger.v3.oas.annotations.Operation;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.List;
- /**
- * 自定义选项Controller层
- * @Author xiexiang
- * @Date 2023/11/13
- */
- @Slf4j
- @RequestMapping(Constants.API_XiaoSHI + "/customOption")
- @RestController
- public class CustomOptionController {
- @Autowired
- private CustomOptionService customOptionService;
- @Operation(summary = "查询自定义选项")
- @PostMapping("/queryCustomOption")
- public Response queryCustomOption(@RequestBody GetCustomOptionDTO getCustomOptionDTO) throws Exception {
- Records records = customOptionService.getCustomOption(getCustomOptionDTO);
- return Response.success(records);
- }
- @Operation(summary = "新增自定义选项")
- @PostMapping("/addCustomOption")
- public Response addCustomOption(@RequestBody CustomOptionDTO customOptionDTO) throws Exception {
- if(customOptionDTO != null){
- Integer id = null;
- try {
- id = customOptionService.addCustomOption(customOptionDTO);
- } catch (Exception e){
- if(e instanceof XiaoShiException) {
- return Response.error(e.getMessage());
- } else if (e instanceof UnLoginException) {
- return Response.unLogin(e.getMessage());
- }
- }
- return Response.success(id);
- } else {
- return Response.error("网络异常");
- }
- }
- @Operation(summary = "更新自定义选项")
- @PostMapping("/updateCustomOption")
- public Response updateCustomOption(@RequestBody UpdateCustomOptionDTO updateCustomOptionDTO) throws Exception {
- if (updateCustomOptionDTO != null) {
- Integer id = customOptionService.updateCustomOption(updateCustomOptionDTO);
- return Response.success(id);
- } else {
- return Response.error("网络异常");
- }
- }
- @Operation(summary = "删除自定义选项")
- @PostMapping("/deleteCustomOption")
- public Response deleteCustomOption(@RequestBody List<CustomOptionDeleteDTO> customOptionDeleteDTOS) throws Exception {
- customOptionService.deleteCustomOption(customOptionDeleteDTOS);
- return Response.success("删除成功");
- }
- }
|