package com.goldenwater.hzz.service;

import com.github.pagehelper.PageHelper;
import com.goldenwater.hzz.domain.ArticleDTO;
import com.goldenwater.hzz.domain.FileWsnDTO;
import com.goldenwater.hzz.domain.RuleExecDTO;
import com.goldenwater.hzz.mapper.RuleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class RuleService {
    @Autowired
    private RuleMapper mapper;

    public List<RuleExecDTO> getRuleMessage(String adCode, String ruleType) {
        return mapper.getRuleMessage(adCode, ruleType);
    }

    public List<FileWsnDTO> getWsnList(String types, String fn, String ft, String st, String et, int pn, int ps) {
        PageHelper.startPage(pn, ps);
        return mapper.getWsnList(types, fn, ft, st, et);
    }

    public int insertWsn(FileWsnDTO dto) {
        if (dto.getGuid() == null) dto.setGuid(UUID.randomUUID().toString().replace("-", ""));
        return mapper.insertWsn(dto);
    }

    public int updateWsn(FileWsnDTO dto) {
        return mapper.updateWsn(dto);
    }

    public int deleteWsn(String guid) {
        return mapper.deleteWsn(guid);
    }

    public List<ArticleDTO> getArticleList(String t, String ty, String st, String et, int pn, int ps) {
        PageHelper.startPage(pn, ps);
        return mapper.getArticleList(t, ty, st, et);
    }

    public int addArticle(ArticleDTO dto) {
        if (dto.getGuid() == null) dto.setGuid(UUID.randomUUID().toString().replace("-", ""));
        return mapper.addArticle(dto);
    }

    public int updateArticle(ArticleDTO dto) {
        return mapper.updateArticle(dto);
    }

    public int deleteArticle(String g) {
        return mapper.deleteArticle(g);
    }

    public List<ArticleDTO> getArticleTop5(String type) {
        return mapper.getArticleTop5(type);
    }
}
