package com.crm.manager.controller;

import com.crm.manager.service.SysAgentLoginTypeService;
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.system.logintype.SysAgentLoginTypeListDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.system.agent.logintype.SysAgentLoginTypeAddEntity;
import com.crm.rely.backend.core.entity.system.agent.logintype.SysAgentLoginTypeDeleteEntitys;
import com.crm.rely.backend.core.entity.system.agent.logintype.SysAgentLoginTypeUpdateEntity;
import com.crm.rely.backend.core.entity.system.logintype.SysLoginTypeSearchEntity;
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("/agent/login/type")
public class SysAgentLoginTypeController {

    @Autowired
    private SysAgentLoginTypeService sysAgentLoginTypeService;

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

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

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

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

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

        return sysAgentLoginTypeService.searchPageList(entity);
    }

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

}
