package com.crm.manager.controller;

import com.crm.manager.service.SysGoogleGroupEmailService;
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.google.SysGoogleGroupEmailListDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.system.google.SysGoogleGroupEmailAddEntity;
import com.crm.rely.backend.core.entity.system.google.SysGoogleGroupEmailDeleteEntitys;
import com.crm.rely.backend.core.entity.system.google.SysGoogleGroupEmailSearchEntity;
import com.crm.rely.backend.core.entity.system.google.SysGoogleGroupEmailUpdateEntity;
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("/google/group")
public class SysGoogleGroupEmailController {

    @Autowired
    private SysGoogleGroupEmailService sysGoogleGroupEmailService;

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

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

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

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

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

        return sysGoogleGroupEmailService.searchPageList(entity);
    }

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

    @PostMapping("/user/list")
    public BaseResultDto getAllList(@RequestBody SysGoogleGroupEmailSearchEntity entity) throws Exception {
        return sysGoogleGroupEmailService.getAllList(entity);
    }

}
