package com.crm.manager.controller;

import com.crm.manager.service.CustomGroupInterestFreeService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
import com.crm.rely.backend.core.dto.custom.free.CustomGroupInterestFreeListDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.custom.group.free.CustomGroupInterestFreeAddEntity;
import com.crm.rely.backend.core.entity.custom.group.free.CustomGroupInterestFreeDeleteEntitys;
import com.crm.rely.backend.core.entity.custom.group.free.CustomGroupInterestFreeSearchEntity;
import com.crm.rely.backend.core.entity.custom.group.free.CustomGroupInterestFreeUpdateEntity;
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("/custom/group/free")
public class CustomGroupInterestFreeController {

    @Autowired
    private CustomGroupInterestFreeService CustomGroupInterestFreeService;

    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated CustomGroupInterestFreeAddEntity entity) throws Exception {
        CustomGroupInterestFreeService.add(entity);
        return BaseResultDto.success();
    }

    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody @Validated CustomGroupInterestFreeDeleteEntitys entitys) throws Exception {

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

    @PostMapping("/update")
    public BaseResultDto update(@RequestBody @Validated CustomGroupInterestFreeUpdateEntity entity) throws Exception {
        CustomGroupInterestFreeService.update(entity);
        return BaseResultDto.success();
    }

    @PostMapping("/search/list")
    public ResultWithPagerDto<CustomGroupInterestFreeListDto> pageList(@RequestBody CustomGroupInterestFreeSearchEntity entity) throws Exception {

        return CustomGroupInterestFreeService.searchPageList(entity);
    }

    @PostMapping("/search/single")
    public BaseResultDto searchSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception {
        CustomGroupInterestFreeListDto result = CustomGroupInterestFreeService.searchSingle(entity);
        return BaseResultDto.success(result);
    }

}
