package com.sunxung.factoring.web.businessConsulting;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sunxung.factoring.component.exception.ServiceException;
import com.sunxung.factoring.entity.BaseSearch;
import com.sunxung.factoring.entity.GridPage;
import com.sunxung.factoring.entity.ResponseJson;
import com.sunxung.factoring.entity.businessConsulting.model.dto.BusinessConsultingDTO;
import com.sunxung.factoring.service.businessConsulting.BusinessConsultingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author liutao
 * @date  2024-03-30
 */
@RestController
@RequestMapping(path = "businessconsulting")
public class BusinessConsultingController {

    @Autowired
    private BusinessConsultingService businessConsultingService;



//    @PostMapping(path = "businessconsulting")
//    @PermissionAndCheck(name="添加用户咨询表",code="BusinessConsultingController:add")
//    @Limit(key = "query",permitsPerSeconds = 1,timeout = 1,msg = "触发接口限流，请重试")
//    public ResponseData add(@Validated @RequestBody AddBusinessConsultingRequest addBusinessConsultingRequest) {
//
//        businessConsultingService.addBusinessConsulting(addBusinessConsultingRequest);
//        return ResponseData.success();
//
//    }

//    @PutMapping(path = "businessconsulting")
//    @PermissionAndCheck(name="更新用户咨询表",code="BusinessConsultingController:update")
//    public ResponseData edit(@Validated @RequestBody EditBusinessConsultingRequest editBusinessConsultingRequest) {
//        businessConsultingService.editBusinessConsulting(editBusinessConsultingRequest);
//        return ResponseData.success();
//    }
//
    @GetMapping(path = "businessconsulting/{id}")
    public ResponseJson getById(@PathVariable("id") Long id){
        BusinessConsultingDTO businessConsultingDTO = businessConsultingService.getBusinessConsultingDtoById(id);
        return new ResponseJson(businessConsultingDTO);

    }

    @PostMapping(path = "businessconsulting/findAll")
    public GridPage findAll(@RequestBody BaseSearch baseSearch){
        return businessConsultingService.findAll(baseSearch);

    }
//
//
//    @DeleteMapping(path = "businessconsulting/{id}")
//    @PermissionAndCheck(name = "删除用户咨询表", code="BusinessConsultingController:delete")
//    public ResponseData deleteById(@PathVariable("id") Long id){
//        if(id==null){
//            throw new ServiceException(400, ExceptionEnum.SYSTEM_DATE_ERROR);
//        }
//        businessConsultingService.deleteBusinessConsulting(id);
//        return ResponseData.success();
//    }
}