package com.crm.custom.controller;

import com.crm.custom.service.GoldenCommonQuestionService;
import com.crm.rely.backend.core.constant.FeignClientAnnotation;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.model.dto.golden.question.GoldenCommonQuestionListDto;
import com.crm.rely.backend.model.entity.golden.question.GoldenCommonQuestionAddEntity;
import com.crm.rely.backend.model.entity.golden.question.GoldenCommonQuestionDeleteEntitys;
import com.crm.rely.backend.model.entity.golden.question.GoldenCommonQuestionSearchEntity;
import com.crm.rely.backend.model.entity.golden.question.GoldenCommonQuestionUpdateEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;

@RestController
@RequestMapping("/common/question")
public class GoldenCommonQuestionController {

    @Autowired
    private GoldenCommonQuestionService goldenCommonQuestionService;


    @PostMapping("/search/list")
    public ResultWithPagerDto<GoldenCommonQuestionListDto> customPageList(@RequestBody GoldenCommonQuestionSearchEntity entity) throws Exception {
        return goldenCommonQuestionService.searchPageList(entity);
    }

    @PostMapping("/manager/add")
    @FeignClientAnnotation
    public BaseResultDto add(@RequestBody @Validated GoldenCommonQuestionAddEntity entity) throws Exception {
        goldenCommonQuestionService.add(entity);
        return BaseResultDto.success();
    }

    @PostMapping("/manager/delete")
    @FeignClientAnnotation
    public BaseResultDto delete(@RequestBody @Validated GoldenCommonQuestionDeleteEntitys entitys) throws Exception {

        goldenCommonQuestionService.delete(entitys);
        return BaseResultDto.success();
    }

    @PostMapping("/manager/update")
    @FeignClientAnnotation
    public BaseResultDto update(@RequestBody @Validated GoldenCommonQuestionUpdateEntity entity) throws Exception {
        goldenCommonQuestionService.update(entity);
        return BaseResultDto.success();
    }

    @PostMapping("/manager/search/list")
    @FeignClientAnnotation
    public ResultWithPagerDto<GoldenCommonQuestionListDto> pageList(@RequestBody GoldenCommonQuestionSearchEntity entity) throws Exception {
        return goldenCommonQuestionService.searchPageList(entity);
    }

    @PostMapping("/manager/search/single")
    @FeignClientAnnotation
    public BaseResultDto searchSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception {
        return BaseResultDto.success(goldenCommonQuestionService.searchSingle(entity));
    }

}
