package com.vetti.hotake.service.impl;

import cn.hutool.core.util.StrUtil;
import com.vetti.common.core.service.BaseServiceImpl;
import com.vetti.common.enums.FillTypeEnum;
import com.vetti.common.enums.HotakeCompliancesStatusEnum;
import com.vetti.hotake.domain.HotakeComplianceInfo;
import com.vetti.hotake.mapper.HotakeComplianceInfoMapper;
import com.vetti.hotake.service.IHotakeComplianceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户合规性信息Service业务层处理
 * 
 * @author wangxiangshun
 * @date 2026-01-18
 */
@SuppressWarnings("all")
@Service
public class HotakeComplianceInfoServiceImpl extends BaseServiceImpl implements IHotakeComplianceInfoService
{
    @Autowired
    private HotakeComplianceInfoMapper hotakeComplianceInfoMapper;

    /**
     * 查询用户合规性信息
     * 
     * @param id 用户合规性信息主键
     * @return 用户合规性信息
     */
    @Transactional(readOnly = true)
    @Override
    public HotakeComplianceInfo selectHotakeComplianceInfoById(Long id)
    {
        return hotakeComplianceInfoMapper.selectHotakeComplianceInfoById(id);
    }

    /**
     * 查询用户合规性信息列表
     * 
     * @param hotakeComplianceInfo 用户合规性信息
     * @return 用户合规性信息
     */
    @Transactional(readOnly = true)
    @Override
    public List<HotakeComplianceInfo> selectHotakeComplianceInfoList(HotakeComplianceInfo hotakeComplianceInfo)
    {
        return hotakeComplianceInfoMapper.selectHotakeComplianceInfoList(hotakeComplianceInfo);
    }

    /**
     * 新增用户合规性信息
     * 
     * @param hotakeComplianceInfo 用户合规性信息
     * @return 结果
     */
    @Transactional(rollbackFor=Exception.class)
    @Override
    public int insertHotakeComplianceInfo(HotakeComplianceInfo hotakeComplianceInfo)
    {
        if(StrUtil.isEmpty(hotakeComplianceInfo.getStatus())){
            hotakeComplianceInfo.setStatus(HotakeCompliancesStatusEnum.PENDING.getCode());
        }
        fill(FillTypeEnum.INSERT.getCode(), hotakeComplianceInfo);
        return hotakeComplianceInfoMapper.insertHotakeComplianceInfo(hotakeComplianceInfo);
    }

    /**
     * 修改用户合规性信息
     * 
     * @param hotakeComplianceInfo 用户合规性信息
     * @return 结果
     */
    @Transactional(rollbackFor=Exception.class)
    @Override
    public int updateHotakeComplianceInfo(HotakeComplianceInfo hotakeComplianceInfo)
    {
        fill(FillTypeEnum.UPDATE.getCode(), hotakeComplianceInfo);
        return hotakeComplianceInfoMapper.updateHotakeComplianceInfo(hotakeComplianceInfo);
    }

    /**
     * 批量删除用户合规性信息
     * 
     * @param ids 需要删除的用户合规性信息主键
     * @return 结果
     */
    @Transactional(rollbackFor=Exception.class)
    @Override
    public int deleteHotakeComplianceInfoByIds(Long[] ids)
    {
        return hotakeComplianceInfoMapper.deleteHotakeComplianceInfoByIds(ids);
    }

    /**
     * 删除用户合规性信息信息
     * 
     * @param id 用户合规性信息主键
     * @return 结果
     */
    @Transactional(rollbackFor=Exception.class)
    @Override
    public int deleteHotakeComplianceInfoById(Long id)
    {
        return hotakeComplianceInfoMapper.deleteHotakeComplianceInfoById(id);
    }
    /**
     * 批量新增用户合规性信息
     *
     * @param hotakeComplianceInfoList 用户合规性信息列表
     * @return 结果
     */
    @Transactional(rollbackFor=Exception.class)
    @Override
    public int batchInsertHotakeComplianceInfo(List<HotakeComplianceInfo> hotakeComplianceInfoList){
        return hotakeComplianceInfoMapper.batchInsertHotakeComplianceInfo(hotakeComplianceInfoList);
    }
}
