package com.moka.gdtauto.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moka.gdtauto.entity.AssetDramaSyncConf;
import com.moka.gdtauto.mapper.AssetDramaSyncConfMapper;
import com.moka.gdtauto.service.AssetDramaSyncConfService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * 短剧资产同步配置Service实现
 *
 * @author moka
 * @since 2026-03-04
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class AssetDramaSyncConfServiceImpl extends ServiceImpl<AssetDramaSyncConfMapper, AssetDramaSyncConf>
        implements AssetDramaSyncConfService {

    @Override
    public Page<AssetDramaSyncConf> listPage(Long page, Long size, String jobNumber, Long accountId) {
        LambdaQueryWrapper<AssetDramaSyncConf> wrapper = new LambdaQueryWrapper<>();
        if (StringUtils.hasText(jobNumber)) {
            wrapper.like(AssetDramaSyncConf::getJobNumber, jobNumber);
        }
        if (accountId != null) {
            wrapper.eq(AssetDramaSyncConf::getAccountId, accountId);
        }
        wrapper.orderByDesc(AssetDramaSyncConf::getCreateTime);
        return this.page(new Page<>(page, size), wrapper);
    }

    @Override
    public boolean addConf(AssetDramaSyncConf conf) {
        return this.save(conf);
    }

    @Override
    public boolean updateConf(AssetDramaSyncConf conf) {
        return this.updateById(conf);
    }

    @Override
    public boolean deleteConf(Long id) {
        return this.removeById(id);
    }
}
