package com.copy.trade.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.copy.trade.dao.FollowConfigMapper;
import com.copy.trade.entity.form.FollowConfigForm;
import com.copy.trade.entity.po.Follow;
import com.copy.trade.entity.po.FollowConfig;
import com.copy.trade.enums.FollowStatusEnum;
import com.copy.trade.service.IFollowConfigService;
import com.copy.trade.util.WebAssert;

/**
 * <p>
 * 标签表 服务实现类
 * </p>
 *
 * @author wz
 * @since 2022-11-12
 */
@Service
public class FollowConfigServiceImpl extends ServiceImpl<FollowConfigMapper, FollowConfig>
		implements IFollowConfigService {

	@Override
	public FollowConfig getConfig(String configNameEn) {
		QueryWrapper<FollowConfig> followConfigQueryWrapper = new QueryWrapper<>();
		followConfigQueryWrapper.eq("config_name_en", configNameEn);
		return getOne(followConfigQueryWrapper);
	}

	@Override
	public Boolean editById(FollowConfigForm followConfigForm) {
		FollowConfig followConfig = getById(followConfigForm.getId());
		WebAssert.isNotNull(followConfig,"不存在的配置信息");
		followConfig.setConfigContent(followConfigForm.getConfigContent());
		return updateById(followConfig);
	}
	
    @Override
    public List<FollowConfig> getListForAdmin() {
        QueryWrapper<FollowConfig> followConfigQueryWrapper = new QueryWrapper<>();
        followConfigQueryWrapper.eq("is_admin_edit",true);
        return list(followConfigQueryWrapper);
    }

}
