package com.sifang.modules.taskdispatch.dao;

import com.jfinal.plugin.activerecord.Db;
import com.sifang.modules.sys.common.persistence.BaseDao;
import com.sifang.modules.sys.common.persistence.Parameter;
import com.sifang.modules.sys.common.utils.DateUtils;
import com.sifang.modules.taskdispatch.entity.CrmPriorReviewSetting;
import com.sifang.modules.taskdispatch.entity.CrmPriorReviewSettingMember;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CrmPriorReviewSettingMemberDao extends BaseDao<CrmPriorReviewSettingMember> {

    public void deleteMemberByReviewSettingId(String reviewSettingId) {
        StringBuffer sb = new StringBuffer();
        sb.append("DELETE FROM crm_prior_review_setting_member WHERE review_setting_id = ? ");
        Db.update(sb.toString(), reviewSettingId);
    }

    public List<CrmPriorReviewSettingMember> findReviewSettingMemberById(String id) {
        return find(" from CrmPriorReviewSettingMember where review_setting_id =:p1", new Parameter(id));
    }

    public List<CrmPriorReviewSettingMember> findReviewSettingMemberByGroupName(String id, String groupName) {
        return find(" from CrmPriorReviewSettingMember where review_setting_id =:p1 and group_name =:p2", new Parameter(id,groupName));
    }

    public List<CrmPriorReviewSettingMember> findReviewSettingMemberByUserId(String userId) {
        return find(" from CrmPriorReviewSettingMember where user_id =:p1 ", new Parameter(userId));
    }

}
