package com.usky.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.usky.common.mybatis.core.AbstractCrudService;
import com.usky.common.security.utils.SecurityUtils;
import com.usky.system.domain.SysMobileTenantConfig;
import com.usky.system.mapper.SysMobileRoleMenuMapper;
import com.usky.system.mapper.SysMobileTenantConfigMapper;
import com.usky.system.service.SysMobileTenantConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 移动端_租户配置表 服务实现类
 * </p>
 *
 * @author JCB
 * @since 2022-08-09
 */
@Service
public class SysMobileTenantConfigServiceImpl extends AbstractCrudService<SysMobileTenantConfigMapper, SysMobileTenantConfig> implements SysMobileTenantConfigService {


    @Override
    public List<SysMobileTenantConfig> getAppTenantConfig(String url){
        List<SysMobileTenantConfig> list = baseMapper.getAppTenantConfig(url);
        return list;
    }

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

    @Override
    public void addMobileTenantConfig(SysMobileTenantConfig sysMobileTenantConfig){
        sysMobileTenantConfig.setCreateBy(SecurityUtils.getUsername());
        sysMobileTenantConfig.setCreateTime(LocalDateTime.now());
        this.save(sysMobileTenantConfig);
    }

    @Override
    public void updateMobileTenantConfig(SysMobileTenantConfig sysMobileTenantConfig){
        sysMobileTenantConfig.setCreateBy(SecurityUtils.getUsername());
        sysMobileTenantConfig.setCreateTime(LocalDateTime.now());
        this.updateById(sysMobileTenantConfig);
    }

}
