package com.dgtly.system.service.impl;

import java.util.List;
import com.dgtly.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dgtly.system.mapper.SysUserCustomerAuthorizationMapper;
import com.dgtly.system.domain.SysUserCustomerAuthorization;
import com.dgtly.system.service.ISysUserCustomerAuthorizationService;
import com.dgtly.common.core.text.Convert;

/**
 * 经销商用户授权Service业务层处理
 *
 * @author njs
 * @date 2024-05-24
 */
@Service
public class SysUserCustomerAuthorizationServiceImpl implements ISysUserCustomerAuthorizationService
{
    @Autowired
    private SysUserCustomerAuthorizationMapper sysUserCustomerAuthorizationMapper;

    /**
     * 查询经销商用户授权
     *
     * @param customerCode 经销商用户授权ID
     * @return 经销商用户授权
     */
    @Override
    public SysUserCustomerAuthorization selectSysUserCustomerAuthorizationById(String customerCode)
    {
        return sysUserCustomerAuthorizationMapper.selectSysUserCustomerAuthorizationById(customerCode);
    }

    /**
     * 查询经销商用户授权列表
     *
     * @param sysUserCustomerAuthorization 经销商用户授权
     * @return 经销商用户授权
     */
    @Override
    public List<SysUserCustomerAuthorization> selectSysUserCustomerAuthorizationList(SysUserCustomerAuthorization sysUserCustomerAuthorization)
    {
        return sysUserCustomerAuthorizationMapper.selectSysUserCustomerAuthorizationList(sysUserCustomerAuthorization);
    }

    /**
     * 新增经销商用户授权
     *
     * @param sysUserCustomerAuthorization 经销商用户授权
     * @return 结果
     */
    @Override
    public int insertSysUserCustomerAuthorization(SysUserCustomerAuthorization sysUserCustomerAuthorization)
    {
        sysUserCustomerAuthorization.setCreateTime(DateUtils.getNowDate());
        return sysUserCustomerAuthorizationMapper.insertSysUserCustomerAuthorization(sysUserCustomerAuthorization);
    }

    /**
     * 修改经销商用户授权
     *
     * @param sysUserCustomerAuthorization 经销商用户授权
     * @return 结果
     */
    @Override
    public int updateSysUserCustomerAuthorization(SysUserCustomerAuthorization sysUserCustomerAuthorization)
    {
        sysUserCustomerAuthorization.setUpdateTime(DateUtils.getNowDate());
        return sysUserCustomerAuthorizationMapper.updateSysUserCustomerAuthorization(sysUserCustomerAuthorization);
    }

    /**
     * 删除经销商用户授权对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSysUserCustomerAuthorizationByIds(String ids)
    {
        return sysUserCustomerAuthorizationMapper.deleteSysUserCustomerAuthorizationByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除经销商用户授权信息
     *
     * @param customerCode 经销商用户授权ID
     * @return 结果
     */
    @Override
    public int deleteSysUserCustomerAuthorizationById(String customerCode)
    {
        return sysUserCustomerAuthorizationMapper.deleteSysUserCustomerAuthorizationById(customerCode);
    }

    /**
     * @param customerCode
     * @param userId
     * @description: 查询根据经销商用户查询授权
     * @param: [customerCode, userId]
     * @return: com.dgtly.system.domain.SysUserCustomerAuthorization
     * @author: njs
     * @date: 2024/5/24 14:15
     */
    @Override
    public SysUserCustomerAuthorization selectAuthorizationByUserIdAndCustomerCode(String customerCode, String userId) {
        return sysUserCustomerAuthorizationMapper.selectAuthorizationByUserIdAndCustomerCode(customerCode, userId);
    }

    /**
     * @param sysUserCustomerAuthorization
     * @description: 根据经销商编号和用户id修改授权标记
     * @param: [sysUserCustomerAuthorization]
     * @return: int
     * @author: njs
     * @date: 2024/5/24 13:58
     */
    @Override
    public int updateAuthorizationByCustomerCodeAndUserId(SysUserCustomerAuthorization sysUserCustomerAuthorization) {
        return sysUserCustomerAuthorizationMapper.updateAuthorizationByCustomerCodeAndUserId(sysUserCustomerAuthorization);
    }
}
