package com.crm.custom.controller;

import com.crm.custom.service.GoldenRewardQuestionService;
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.GoldenRewardQuestionListDto;
import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionAddEntity;
import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionDeleteEntitys;
import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionSearchEntity;
import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionUpdateEntity;
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("/reward/question")
public class GoldenRewardQuestionController {

    @Autowired
    private GoldenRewardQuestionService goldenRewardQuestionService;

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

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

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

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

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

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

}
