using Edu.Common.Enum;
using Edu.Model.Entity.OKR;
using Edu.Model.ViewModel.OKR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;
namespace Edu.Repository.OKR
{
///
/// OKR对齐仓储层
///
public class RB_OKR_ObjectiveRelationRepository : BaseRepository
{
///
/// 获取列表
///
///
///
public List GetList(RB_OKR_ObjectiveRelation demodel)
{
string where = $@" 1=1 ";
if (demodel.ObjectiveId > 0)
{
where += $@" and {nameof(RB_OKR_ObjectiveRelation.ObjectiveId)} ={demodel.ObjectiveId}";
}
if (demodel.ParentId > 0)
{
where += $@" and {nameof(RB_OKR_ObjectiveRelation.ParentId)} ={demodel.ParentId}";
}
string sql = $@" select * from RB_OKR_ObjectiveRelation where {where} order by Id desc";
return Get(sql).ToList();
}
///
/// 获取上对齐数量
///
///
///
public List GetParentAlignNum(string ObjectiveIds)
{
string sql = $@" select ObjectiveId,COUNT(0) AS ParentId from RB_OKR_ObjectiveRelation WHERE ObjectiveId in({ObjectiveIds}) GROUP BY ObjectiveId";
return Get(sql).ToList();
}
///
/// 获取下对齐数量
///
///
///
public List GetChildAlignNum(string ObjectiveIds)
{
string sql = $@" select ParentId,COUNT(0) AS ObjectiveId from RB_OKR_ObjectiveRelation WHERE ParentId in({ObjectiveIds}) GROUP BY ParentId";
return Get(sql).ToList();
}
///
/// 获取目标的上对齐 所有的目标
///
///
///
public string GetObjectiveParentIds(int objectiveId)
{
string sql = $" SELECT func_okr_getobjectiveparentids({objectiveId});";
var obj = ExecuteScalar(sql);
return obj == null ? "" : obj.ToString();
}
///
/// 获取目标的下对齐 所有的目标
///
///
///
public string GetObjectiveChildIds(int objectiveId)
{
string sql = $" SELECT func_okr_getobjectivechildids({objectiveId});";
var obj = ExecuteScalar(sql);
return obj == null ? "" : obj.ToString();
}
}
}