package com.xingxi.master.ipInfo.service.impl;

import com.xingxi.common.core.text.Convert;
import com.xingxi.common.enums.EDelFlag;
import com.xingxi.common.utils.DateUtils;
import com.xingxi.common.utils.ShiroUtils;
import com.xingxi.master.ipInfo.domain.IpInfo;
import com.xingxi.master.ipInfo.mapper.IpInfoMapper;
import com.xingxi.master.ipInfo.service.IIpInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 文创品牌Service业务层处理
 *
 * @author xingxi
 * @date 2025-03-06
 */
@Service
public class IpInfoServiceImpl implements IIpInfoService {
    @Resource
    private IpInfoMapper ipInfoMapper;

    /**
     * 查询文创品牌
     *
     * @param ipId 文创品牌主键
     * @return 文创品牌
     */
    @Override
    public IpInfo selectIpInfoByIpId(Long ipId) {
        return ipInfoMapper.selectIpInfoByIpId(ipId);
    }

    /**
     * 查询文创品牌列表
     *
     * @param ipInfo 文创品牌
     * @return 文创品牌
     */
    @Override
    public List<IpInfo> selectIpInfoList(IpInfo ipInfo) {
        ipInfo.setDelFlag(EDelFlag.NO.getVal());
        return ipInfoMapper.selectIpInfoList(ipInfo);
    }

    /**
     * 新增文创品牌
     *
     * @param ipInfo 文创品牌
     * @return 结果
     */
    @Override
    public int insertIpInfo(IpInfo ipInfo) {
        ipInfo.setDelFlag(EDelFlag.NO.getVal());
        ipInfo.setCreateUser(ShiroUtils.getLoginName());
        ipInfo.setCreateTime(DateUtils.getNowDate());
        return ipInfoMapper.insertIpInfo(ipInfo);
    }

    /**
     * 新增文创品牌
     *
     * @param ipInfoList 文创品牌
     * @return 结果
     */
    @Override
    public int batchInsertIpInfo(List<IpInfo> ipInfoList) {
        return ipInfoMapper.batchInsertIpInfo(ipInfoList);
    }

    /**
     * 修改文创品牌
     *
     * @param ipInfo 文创品牌
     * @return 结果
     */
    @Override
    public int updateIpInfo(IpInfo ipInfo) {
        ipInfo.setUpdateUser(ShiroUtils.getLoginName());
        ipInfo.setUpdateTime(DateUtils.getNowDate());
        return ipInfoMapper.updateIpInfo(ipInfo);
    }

    /**
     * 批量删除文创品牌
     *
     * @param ipIds 需要删除的文创品牌主键
     * @return 结果
     */
    @Override
    public int deleteIpInfoByIpIds(String ipIds) {
        return ipInfoMapper.deleteIpInfoByIpIds(Convert.toStrArray(ipIds));
    }

    /**
     * 删除文创品牌信息
     *
     * @param ipId 文创品牌主键
     * @return 结果
     */
    @Override
    public int deleteIpInfoByIpId(Long ipId) {
        return ipInfoMapper.deleteIpInfoByIpId(ipId);
    }

    /**
     * 逻辑删除文创品牌
     *
     * @param ipId 文创品牌主键
     * @return 结果
     */
    @Override
    public int logicDeleteIpInfoByIpId(Long ipId) {
        return ipInfoMapper.logicDeleteIpInfoByIpId(ipId);
    }

    /**
     * 逻辑批量删除文创品牌
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    @Override
    public int logicDeleteIpInfoByIpIds(String ids) {
        return ipInfoMapper.logicDeleteIpInfoByIpIds(Convert.toStrArray(ids));
    }

    /**
     * 逻辑批量删除文创品牌
     *
     * @param ipInfo 文创品牌
     * @return 结果
     */
    @Override
    public int logicDeleteIpInfoByCondition(IpInfo ipInfo) {
        return ipInfoMapper.logicDeleteIpInfoByCondition(ipInfo);
    }
}
