package com.crm.manager.controller;

import com.crm.login.rely.backend.controller.BaseLoginController;
import com.crm.manager.service.activity.WebActivityCountryFeignService;
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.web.activity.country.WebActivityCountryListDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.web.activity.country.WebActivityCountryAddEntity;
import com.crm.rely.backend.core.entity.web.activity.country.WebActivityCountryDeleteEntity;
import com.crm.rely.backend.core.entity.web.activity.country.WebActivityCountrySearchEntity;
import com.crm.rely.backend.core.entity.web.activity.country.WebActivityCountryUpdateEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/web/activity/country")
public class WebActivityCountryController extends BaseLoginController {

    @Autowired
    private WebActivityCountryFeignService webActivityCountryService;

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

        return webActivityCountryService.add(entity);
    }

    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody @Validated WebActivityCountryDeleteEntity entity) throws Exception {

        return webActivityCountryService.delete(entity);
    }

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

        return webActivityCountryService.update(entity);
    }

    @PostMapping("/search/list")
    public BaseResultDto list(@RequestBody @Validated WebActivityCountrySearchEntity entity) throws Exception {

        ResultWithPagerDto<WebActivityCountryListDto> result = webActivityCountryService.list(entity);
        return result;
    }

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

}
