package com.crm.manager.controller;

import com.crm.manager.service.CustomLoginDeleteExcludeService;
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.login.CustomLoginDeleteExcludeListDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.custom.login.delete.CustomLoginDeleteExcludeAddEntity;
import com.crm.rely.backend.core.entity.custom.login.delete.CustomLoginDeleteExcludeDeleteEntitys;
import com.crm.rely.backend.core.entity.custom.login.delete.CustomLoginDeleteExcludeSearchEntity;
import com.crm.rely.backend.core.entity.custom.login.delete.CustomLoginDeleteExcludeUpdateEntity;
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/login/delete/exclude")
public class CustomLoginDeleteExcludeController {

    @Autowired
    private CustomLoginDeleteExcludeService customLoginDeleteExcludeService;

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

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

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

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

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

        return customLoginDeleteExcludeService.searchPageList(entity);
    }

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

}
