package com.docus.server.controller;

import com.docus.infrastructure.web.api.CommonResult;
import com.docus.infrastructure.web.request.SearchDTO;
import com.docus.infrastructure.web.response.PageResult;
import com.docus.server.api.recovery.RcvSysUserApi;
import com.docus.server.common.IgnoreValidate;
import com.docus.server.dto.recovery.rcvsysuser.AddRcvSysUserDTO;
import com.docus.server.dto.recovery.rcvsysuser.DeleteRcvSysUserDTO;
import com.docus.server.dto.recovery.rcvsysuser.EditRcvSysUserDTO;
import com.docus.server.dto.recovery.rcvsysuser.LoginRcvSysUserDTO;
import com.docus.server.service.IRcvSysUserService;
import com.docus.server.vo.recovery.rcvsysuser.RcvSysUserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * 系统登录用户表 控制器类
 *
 * @author AutoGenerator
 * @since 2023-09-13
 */
@Api(value = "系统登录用户表", tags = "系统登录用户表")
@RestController
public class RcvSysUserController implements RcvSysUserApi {
    @Resource
    private IRcvSysUserService iRcvSysUserService;


    @Override
    @ApiOperation("登录")
    @IgnoreValidate
    public CommonResult<String> login(LoginRcvSysUserDTO userDTO) {
        String token = iRcvSysUserService.doLogin(userDTO.getUserName(), userDTO.getUserPwd());
        return CommonResult.success(token, "登录成功");
    }

    @ApiOperation("退出登录")
    @Override
    @IgnoreValidate
    public boolean logout() {
        iRcvSysUserService.logout();
        return true;
    }

    /**
     * 按主键查询
     *
     * @param id 主键Id
     * @return 实体
     */
    @ApiOperation("按主键查询")
    @Override
    public RcvSysUserVO findById(Serializable id) {
        return iRcvSysUserService.findById(id);
    }

    /**
     * 按主键集合查询
     *
     * @param ids 主键Ids
     * @return 实体列表
     */
    @ApiOperation("按主键集合查询")
    @Override
    public List<RcvSysUserVO> findByIds(List<Serializable> ids) {
        return iRcvSysUserService.findByIds(ids);
    }


    /**
     * 按属性查询多实体
     *
     * @param propertyName  属性名
     * @param propertyValue 属性值
     * @return 实体列表
     */
    @ApiOperation("按属性查询多实体")
    @Override
    public List<RcvSysUserVO> findBy(String propertyName, Object propertyValue) {
        return iRcvSysUserService.findBy(propertyName, propertyValue);
    }

    /**
     * 按属性值集合查询
     *
     * @param propertyName  属性名
     * @param propertyValue 属性值
     * @return 实体列表
     */
    @ApiOperation("按属性值集合查询")
    @Override
    public List<RcvSysUserVO> findBy(String propertyName, Collection<Serializable> propertyValue) {
        return iRcvSysUserService.findBy(propertyName, propertyValue);
    }

    /**
     * 按属性查询单实体
     *
     * @param propertyName  属性名
     * @param propertyValue 属性值
     * @return 实体列表
     */
    @ApiOperation("按属性查询单实体")
    @Override
    public RcvSysUserVO findOneBy(String propertyName, Object propertyValue) {
        return iRcvSysUserService.findOneBy(propertyName, propertyValue);
    }

    /**
     * 按属性值集合查询
     *
     * @param propertyName  属性名
     * @param propertyValue 属性值
     * @return 实体列表
     */
    @ApiOperation("按属性值集合查询")
    @Override
    public RcvSysUserVO findOneBy(String propertyName, Collection<Serializable> propertyValue) {
        return iRcvSysUserService.findOneBy(propertyName, propertyValue);
    }

    /**
     * 查询所有
     *
     * @return 实体
     */
    @ApiOperation("查询所有")
    @Override
    public List<RcvSysUserVO> findAll() {
        return iRcvSysUserService.findAll();
    }

    /**
     * 关键字搜索
     *
     * @param searchDTO 搜索参数
     * @return 分页列表
     */
    @ApiOperation("关键字搜索")
    @Override
    public PageResult<RcvSysUserVO> search(SearchDTO searchDTO) {
        return iRcvSysUserService.search(searchDTO);
    }

    /**
     * 新增
     *
     * @param addRcvSysUserDTO 编辑参数
     */
    @ApiOperation("新增")
    @Override
    public void add(AddRcvSysUserDTO addRcvSysUserDTO) {
        iRcvSysUserService.add(addRcvSysUserDTO);
    }

    /**
     * 批量新增
     *
     * @param addRcvSysUserDTO 编辑参数
     */
    @ApiOperation("批量新增")
    @Override
    public void addBatch(List<AddRcvSysUserDTO> addRcvSysUserDTO) {
        iRcvSysUserService.addBatch(addRcvSysUserDTO);
    }

    /**
     * 新增或编辑
     *
     * @param editRcvSysUserDTO 新增或编辑参数
     */
    @ApiOperation("新增或编辑")
    @Override
    public void addOrEdit(EditRcvSysUserDTO editRcvSysUserDTO) {
        iRcvSysUserService.addOrEdit(editRcvSysUserDTO);
    }

    /**
     * 批量新增或编辑
     *
     * @param editRcvSysUserDTOList 编辑参数
     */
    @ApiOperation("批量新增或编辑")
    @Override
    public void addOrEditBatch(List<EditRcvSysUserDTO> editRcvSysUserDTOList) {
        iRcvSysUserService.addOrEditBatch(editRcvSysUserDTOList);
    }

    /**
     * 编辑
     *
     * @param editRcvSysUserDTO 编辑参数
     */
    @ApiOperation("编辑")
    @Override
    public void edit(EditRcvSysUserDTO editRcvSysUserDTO) {
        iRcvSysUserService.edit(editRcvSysUserDTO);
    }

    /**
     * 批量编辑
     *
     * @param editRcvSysUserDTO 编辑参数
     */
    @ApiOperation("批量编辑")
    @Override
    public void editBatchById(List<EditRcvSysUserDTO> editRcvSysUserDTO) {
        iRcvSysUserService.editBatchById(editRcvSysUserDTO);
    }

    /**
     * 批量删除
     *
     * @param deleteRcvSysUserDTO 删除参数
     */
    @ApiOperation("批量删除")
    @Override
    public void delete(DeleteRcvSysUserDTO deleteRcvSysUserDTO) {
        iRcvSysUserService.delete(deleteRcvSysUserDTO);
    }

    /**
     * 按主键删除
     *
     * @param id 删除参数
     */
    @ApiOperation("按主键删除")
    @Override
    public void deleteById(Serializable id) {
        iRcvSysUserService.delete(id);
    }

    /**
     * 按属性删除
     *
     * @param propertyName  删除属性名
     * @param propertyValue 删除属性值
     */
    @ApiOperation("按属性删除")
    @Override
    public void deleteBy(String propertyName, Object propertyValue) {
        iRcvSysUserService.deleteBy(propertyName, propertyValue);
    }

    /**
     * 按属性值集合删除
     *
     * @param propertyName  删除属性名
     * @param propertyValue 删除属性值集合
     */
    @ApiOperation("按属性值集合删除")
    @Override
    public void deleteBy(String propertyName, Collection<Serializable> propertyValue) {
        iRcvSysUserService.deleteBy(propertyName, propertyValue);
    }

    /**
     * 按主键集合批量删除
     *
     * @param ids 删除参数
     */
    @ApiOperation("按主键集合批量删除")
    @Override
    public void deleteByIds(Collection<Serializable> ids) {
        iRcvSysUserService.deleteByIds(ids);
    }

    /**
     * 名称不重复
     *
     * @param id   主键
     * @param name 名称
     * @return 名称重复数量
     */
    @ApiOperation("名称不重复")
    @Override
    public int findByIdAndName(Serializable id, String name) {
        return iRcvSysUserService.findByIdAndName(id, name);
    }
}
