|
- using Nancy;
- using Learun.Util;
- using System.Collections.Generic;
- using Learun.Application.TwoDevelopment.PersonnelManagement;
- using System;
-
- namespace Learun.Application.WebApi
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2020-01-04 11:47
- /// 描 述:社团管理
- /// </summary>
- public class CommunityInfoApi : BaseApi
- {
- private CommunityInfoIBLL communityInfoIBLL = new CommunityInfoBLL();
- private CommunityMemberIBLL communityMemberIBLL = new CommunityMemberBLL();
-
- /// <summary>
- /// 注册接口
- /// <summary>
- public CommunityInfoApi()
- : base("/Learun/adms/PersonnelManagement/CommunityInfo")
- {
- Get["/pagelist"] = GetPageList;
- Get["/list"] = GetList;
- Get["/form"] = GetForm;
- Post["/delete"] = DeleteForm;
- Post["/save"] = SaveForm;
- Post["/join"] = JoinForm;
- Get["/communityMemberpagelist"] = GetCommunityMemberPageList;
- }
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表分页数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetPageList(dynamic _)
- {
- ReqPageParam parameter = this.GetReqData<ReqPageParam>();
- var data = communityInfoIBLL.GetPageList(parameter.pagination, parameter.queryJson);
- var jsonData = new
- {
- rows = data,
- total = parameter.pagination.total,
- page = parameter.pagination.page,
- records = parameter.pagination.records
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetList(dynamic _)
- {
- string queryJson = this.GetReqData();
- var data = communityInfoIBLL.GetList(queryJson);
- return Success(data);
- }
- /// <summary>
- /// 获取表单数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- var CommunityInfoData = communityInfoIBLL.GetCommunityInfoEntity(keyValue);
- var jsonData = new
- {
- CommunityInfo = CommunityInfoData,
- };
- return Success(jsonData);
- }
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response DeleteForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- communityInfoIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response SaveForm(dynamic _)
- {
- ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
- CommunityInfoEntity entity = parameter.strEntity.ToObject<CommunityInfoEntity>();
- communityInfoIBLL.SaveEntity(this.userInfo, parameter.keyValue, entity);
- return Success("保存成功!");
- }
- /// <summary>
- /// 申请加入社团
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response JoinForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- if (this.userInfo.Description != "学生")
- {
- return Fail("当前账号不是学生账号!");
- }
- CommunityMemberEntity entity = new CommunityMemberEntity()
- {
- CommunityId = keyValue,
- StuNo = this.userInfo.account,
- StuName = this.userInfo.realName,
- JoinTime = DateTime.Now.Date,
- CreateTime = DateTime.Now,
- CreateUserId = this.userInfo.userId,
- CreateUserName = this.userInfo.realName
- };
- communityMemberIBLL.SaveEntity("", entity);
- return Success("保存成功!");
- }
- /// <summary>
- /// 我的社团
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetCommunityMemberPageList(dynamic _)
- {
- ReqPageParam parameter = this.GetReqData<ReqPageParam>();
- var data = communityMemberIBLL.GetPageList(parameter.pagination, parameter.queryJson, this.userInfo.account);
- var jsonData = new
- {
- rows = data,
- total = parameter.pagination.total,
- page = parameter.pagination.page,
- records = parameter.pagination.records
- };
- return Success(jsonData);
- }
- #endregion
-
- #region 私有类
-
- /// <summary>
- /// 表单实体类
- /// <summary>
- private class ReqFormEntity
- {
- public string keyValue { get; set; }
- public string strEntity { get; set; }
- }
- #endregion
-
- }
- }
|