79 lines
2.9 KiB
C#
79 lines
2.9 KiB
C#
using CYQ.Data.Cache;
|
|
using Newtonsoft.Json;
|
|
using Song.ServiceInterfaces;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Dynamic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Taurus.Core;
|
|
using Taurus.Mvc;
|
|
using Taurus.Mvc.Attr;
|
|
using WeiSha.Common;
|
|
|
|
namespace PeiXun.Controllers.BasicInfo
|
|
{
|
|
|
|
|
|
public class SubjectAPIController : Controller
|
|
{
|
|
|
|
[Token]
|
|
[HttpGet]
|
|
public void SubjectList()
|
|
{
|
|
string search = Query<string>("search");
|
|
int sbjid = Query<int>("sbjid");
|
|
|
|
string token = Query<string>("token").TrimStart("xyl:".ToCharArray());
|
|
DistributedCache cache = DistributedCache.Instance;
|
|
Song.Entities.Accounts emp = cache.Get<Song.Entities.Accounts>(token);
|
|
int org_ID = emp.Org_ID;
|
|
|
|
//当前专业
|
|
Song.Entities.Subject subject = Business.Do<ISubject>().SubjectSingle(sbjid);
|
|
if (subject != null)
|
|
{
|
|
subject.Sbj_Logo = string.IsNullOrWhiteSpace(subject.Sbj_Logo) ? subject.Sbj_Logo : Upload.Get["Subject"].Virtual + subject.Sbj_Logo;
|
|
subject.Sbj_LogoSmall = string.IsNullOrWhiteSpace(subject.Sbj_LogoSmall) ? subject.Sbj_LogoSmall : Upload.Get["Subject"].Virtual + subject.Sbj_LogoSmall;
|
|
//是否有子级,如果没有,则直接跳到课程选择页
|
|
//if (isChildren(new object[] { subject.Sbj_ID }).ToString() != "0")
|
|
//{
|
|
// this.Response.Redirect("Courses.ashx?sbjid=" + subject.Sbj_ID);
|
|
//}
|
|
}
|
|
//当前专业下的子专业,如果是顶级,则显示所有顶级专业
|
|
Song.Entities.Subject[] subjects;
|
|
if (string.IsNullOrWhiteSpace(search))
|
|
{
|
|
subjects = Business.Do<ISubject>().SubjectCount(org_ID, null, true, sbjid, 0);
|
|
}
|
|
else
|
|
{
|
|
subjects = Business.Do<ISubject>().SubjectCount(org_ID, search, true, -1, 0);
|
|
}
|
|
|
|
foreach (Song.Entities.Subject s in subjects)
|
|
{
|
|
s.Sbj_Logo = string.IsNullOrWhiteSpace(s.Sbj_Logo) ? s.Sbj_Logo : Upload.Get["Subject"].Virtual + s.Sbj_Logo;
|
|
s.Sbj_LogoSmall = string.IsNullOrWhiteSpace(s.Sbj_LogoSmall) ? s.Sbj_LogoSmall : Upload.Get["Subject"].Virtual + s.Sbj_LogoSmall;
|
|
}
|
|
//this.Document.SetValue("subjects", subjects);
|
|
////是否拥有子级
|
|
//this.Document.RegisterGlobalFunction(this.isChildren);
|
|
bool isChilid = Business.Do<ISubject>().SubjectIsChildren(org_ID, sbjid, true);
|
|
|
|
|
|
dynamic obj = new ExpandoObject();
|
|
obj.code = 1;
|
|
obj.msg = "success";
|
|
obj.isChildren = isChilid;
|
|
obj.data = subjects;
|
|
|
|
Write(JsonConvert.SerializeObject(obj));
|
|
}
|
|
|
|
}
|
|
}
|