package com.usky.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.usky.common.security.utils.SecurityUtils;
import com.usky.system.domain.SysMobileBanner;
import com.usky.system.domain.SysMobileTenantConfig;
import com.usky.system.mapper.SysMobileBannerMapper;
import com.usky.system.service.SysMobileBannerService;
import com.usky.common.mybatis.core.AbstractCrudService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 移动端_banner图配置表 服务实现类
 * </p>
 *
 * @author han
 * @since 2023-03-30
 */
@Service
public class SysMobileBannerServiceImpl extends AbstractCrudService<SysMobileBannerMapper, SysMobileBanner> implements SysMobileBannerService {
    @Override
    public void addMobileBanner(SysMobileBanner sysMobileBanner){
        sysMobileBanner.setCreateBy(SecurityUtils.getUsername());
        sysMobileBanner.setCreateTime(LocalDateTime.now());
        this.save(sysMobileBanner);
    }

    @Override
    public void updateMobileBanner(SysMobileBanner sysMobileBanner){
        sysMobileBanner.setUpdateBy(SecurityUtils.getUsername());
        sysMobileBanner.setUpdateTime(LocalDateTime.now());
        this.updateById(sysMobileBanner);
    }

    @Override
    public List<SysMobileBanner> getMobileBanner(Integer tenantId) {
        LambdaQueryWrapper<SysMobileBanner> query = Wrappers.lambdaQuery();
        query.eq(SysMobileBanner::getTenantId, tenantId);
        List<SysMobileBanner> list = this.list(query);
        return list;
    }
}
