|
- using Dapper;
- using Learun.DataBase.Repository;
- using Learun.Util;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Text;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
-
- namespace Learun.Application.TwoDevelopment.LogisticsManagement
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2020-05-19 11:37
- /// 描 述:心理预约管理
- /// </summary>
- public class APAppointmentPsychologistService : RepositoryFactory
- {
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<APAppointmentPsychologistEntity> GetPageList(Pagination pagination, string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT ");
- strSql.Append(@"
- t.PID,
- t.PStuNo,
- t.PDeptNo,
- t.PMajorNo,
- t.PClassNo,
- t.PTime,
- t.PEmpNo,
- t.PAgreee,
- t.Remark
- ");
- strSql.Append(" FROM APAppointmentPsychologist t ");
- strSql.Append(" WHERE 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
- {
- dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
- dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
- strSql.Append(" AND ( t.PTime >= @startTime AND t.PTime <= @endTime ) ");
- }
- if (!queryParam["PDeptNo"].IsEmpty())
- {
- dp.Add("PDeptNo", queryParam["PDeptNo"].ToString(), DbType.String);
- strSql.Append(" AND t.PDeptNo = @PDeptNo ");
- }
- if (!queryParam["PMajorNo"].IsEmpty())
- {
- dp.Add("PMajorNo", queryParam["PMajorNo"].ToString(), DbType.String);
- strSql.Append(" AND t.PMajorNo = @PMajorNo ");
- }
- if (!queryParam["PClassNo"].IsEmpty())
- {
- dp.Add("PClassNo", queryParam["PClassNo"].ToString(), DbType.String);
- strSql.Append(" AND t.PClassNo = @PClassNo ");
- }
- if (!queryParam["PEmpNo"].IsEmpty())
- {
- dp.Add("PEmpNo", queryParam["PEmpNo"].ToString(), DbType.String);
- strSql.Append(" AND t.PEmpNo = @PEmpNo ");
- }
- if (!queryParam["PTime"].IsEmpty())
- {
- dp.Add("PTime", queryParam["PTime"].ToString(), DbType.String);
- strSql.Append(" AND t.PTime = @PTime ");
- }
- if (!queryParam["PStuNo"].IsEmpty())
- {
- dp.Add("PStuNo", queryParam["PStuNo"].ToString(), DbType.String);
- strSql.Append(" AND t.PStuNo = @PStuNo ");
- }
- return this.BaseRepository("CollegeMIS").FindList<APAppointmentPsychologistEntity>(strSql.ToString(), dp, pagination);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取APAppointmentPsychologist表实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public APAppointmentPsychologistEntity GetAPAppointmentPsychologistEntity(string keyValue)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindEntity<APAppointmentPsychologistEntity>(keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void DeleteEntity(string keyValue)
- {
- try
- {
- this.BaseRepository("CollegeMIS").Delete<APAppointmentPsychologistEntity>(t => t.PID == keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- /// <summary>
- /// 通过预约
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void SuccessAppointment(string keyValue)
- {
- try
- {
- var sql = $"UPDATE dbo.APAppointmentPsychologist SET PAgreee='true' WHERE PID='{keyValue}'";
- this.BaseRepository("CollegeMIS").ExecuteBySql(sql);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void SaveEntity(string keyValue, APAppointmentPsychologistEntity entity)
- {
- try
- {
- if (!string.IsNullOrEmpty(keyValue))
- {
- entity.Modify(keyValue);
- this.BaseRepository("CollegeMIS").Update(entity);
- }
- else
- {
- //获取当前学生的名字、系、专业、班级
- var loginUser = LoginUserInfo.Get();
- var userEntity = this.BaseRepository("CollegeMIS")
- .FindEntity<StuInfoBasicEntity>(a => a.StuNo == loginUser.account);
- entity.PStuNo = userEntity?.StuNo;
- entity.PDeptNo = userEntity?.DeptNo;
- entity.PMajorNo = userEntity?.MajorNo;
- entity.PClassNo = userEntity?.ClassNo;
-
- entity.Create();
- this.BaseRepository("CollegeMIS").Insert(entity);
- }
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- #endregion
-
- }
- }
|