package cn.com.ctop.common.module.service.impl;

import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
import cn.com.ctop.common.module.entity.RuleDataTargetKuaishou;
import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
import cn.com.ctop.common.module.entity.RuleDateUnitKuaishou;
import cn.com.ctop.common.module.mapper.RuleDataAccountKuaishouMapper;
import cn.com.ctop.common.module.mapper.RuleDataTargetKuaishouMapper;
import cn.com.ctop.common.module.mapper.RuleDatePlanKuaishouMapper;
import cn.com.ctop.common.module.mapper.RuleDateUnitKuaishouMapper;
import cn.com.ctop.common.module.service.IRuleDataAccountKuaishouService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxl.job.core.enums.NoEn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 快手预警数据账户维度
 *
 * @author jeecg-boot
 * @version V1.0
 * @date 2020-12-03
 */
@Service
public class RuleDataAccountKuaishouServiceImpl extends ServiceImpl<RuleDataAccountKuaishouMapper, RuleDataAccountKuaishou> implements IRuleDataAccountKuaishouService {

    @Autowired
    private RuleDataAccountKuaishouMapper ruleDataAccountKuaishouMapper;
    @Autowired
    private RuleDataTargetKuaishouMapper ruleDataTargetKuaishouMapper;
    @Autowired
    private RuleDateUnitKuaishouMapper ruleDateUnitKuaishouMapper;
    @Autowired
    private RuleDatePlanKuaishouMapper ruleDatePlanKuaishouMapper;

    @Override
    public JSONObject getKuaiShouRuleDataByAccountId(Long accountId) {
        JSONObject obj = new JSONObject();
        Map<String, Object> map = new HashMap<>();
        map.put("account_id", accountId);
        map.put("status", NoEn.NO1.valueInt());
        List<RuleDataAccountKuaishou> accountList = ruleDataAccountKuaishouMapper.selectByMap(map);
        obj.put("account", accountList);
        List<RuleDateUnitKuaishou> unitKuaishous = ruleDateUnitKuaishouMapper.selectByMap(map);
        obj.put("unit", unitKuaishous);
        List<RuleDataTargetKuaishou> targetKuaishous = ruleDataTargetKuaishouMapper.selectByMap(map);
        obj.put("target", targetKuaishous);
        List<RuleDatePlanKuaishou> planKuaishous = ruleDatePlanKuaishouMapper.selectByMap(map);
        obj.put("plan", planKuaishous);
        return obj;
    }
}
