package com.crm.manager.controller;

import com.crm.manager.service.golden.GoldenCommonQuestionFeignService;
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 GoldenCommonQuestionFeignService goldenCommonQuestionService;

    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated GoldenCommonQuestionAddEntity entity) throws Exception {

        return goldenCommonQuestionService.add(entity);
    }

    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody @Validated GoldenCommonQuestionDeleteEntitys entitys) throws Exception {
        return goldenCommonQuestionService.delete(entitys);
    }

    @PostMapping("/update")
    public BaseResultDto update(@RequestBody @Validated GoldenCommonQuestionUpdateEntity entity) throws Exception {

        return goldenCommonQuestionService.update(entity);
    }

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

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

}
