|
- using Dapper;
- using Learun.DataBase.Repository;
- using Learun.Util;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Text;
-
- namespace Learun.Application.TwoDevelopment.EducationalAdministration
- {
- /// <summary>
- /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
- /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
- /// 创 建:超级管理员
- /// 日 期:2022-11-08 11:05
- /// 描 述:学生赛事奖励
- /// </summary>
- public class StudentCompetitionService : RepositoryFactory
- {
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表数据
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<StudentCompetitionEntity> GetPageList(Pagination pagination, string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT ");
- strSql.Append(@"
- t.*
- ");
- strSql.Append(" FROM StudentCompetition t ");
- strSql.Append(" WHERE 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
-
- if (!queryParam["AcademicYearNo"].IsEmpty())
- {
- dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
- strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo ");
- }
- if (!queryParam["Semester"].IsEmpty())
- {
- dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
- strSql.Append(" AND t.Semester = @Semester ");
- }
- if (!queryParam["StuNo"].IsEmpty())
- {
- dp.Add("StuNo", "%" + queryParam["StuNo"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.StuNo Like @StuNo ");
- }
- if (!queryParam["StuName"].IsEmpty())
- {
- dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.StuName Like @StuName ");
- }
- if (!queryParam["DeptNo"].IsEmpty())
- {
- dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
- strSql.Append(" AND t.DeptNo = @DeptNo ");
- }
- if (!queryParam["MajorNo"].IsEmpty())
- {
- dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
- strSql.Append(" AND t.MajorNo = @MajorNo ");
- }
- if (!queryParam["ClassNo"].IsEmpty())
- {
- dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
- strSql.Append(" AND t.ClassNo = @ClassNo ");
- }
- if (!queryParam["SCName"].IsEmpty())
- {
- dp.Add("SCName", "%" + queryParam["SCName"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.SCName Like @SCName ");
- }
- if (!queryParam["SCLevel"].IsEmpty())
- {
- dp.Add("SCLevel",queryParam["SCLevel"].ToString(), DbType.String);
- strSql.Append(" AND t.SCLevel = @SCLevel ");
- }
- if (!queryParam["SCTime"].IsEmpty())
- {
- dp.Add("SCTime", queryParam["SCTime"].ToDate(), DbType.DateTime);
- strSql.Append(" AND t.SCTime = @SCTime ");
- }
- if (!queryParam["SCType"].IsEmpty())
- {
- dp.Add("SCType", "%" + queryParam["SCType"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.SCType Like @SCType ");
- }
- if (!queryParam["Unit"].IsEmpty())
- {
- dp.Add("Unit", "%" + queryParam["Unit"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.Unit Like @Unit ");
- }
- return this.BaseRepository("CollegeMIS").FindList<StudentCompetitionEntity>(strSql.ToString(), dp, pagination);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取StudentCompetition表实体数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- public StudentCompetitionEntity GetStudentCompetitionEntity(string keyValue)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindEntity<StudentCompetitionEntity>(keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取主表实体数据
- /// </summary>
- /// <param name="processId">流程实例ID</param>
- /// <returns></returns>
- public StudentCompetitionEntity GetEntityByProcessId(string processId)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindEntity<StudentCompetitionEntity>(t => t.processId == processId);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取页面显示列表数据
- /// </summary>
- /// <returns></returns>
- public IEnumerable<StudentCompetitionEntity> GetList(string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT t.* ");
- strSql.Append(" FROM StudentCompetition t ");
- strSql.Append(" WHERE 1=1 and t.Status=2 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- if (!queryParam["StuNo"].IsEmpty())
- {
- dp.Add("StuNo", queryParam["StuNo"].ToString(), DbType.String);
- strSql.Append(" AND t.StuNo = @StuNo ");
- }
- if (!queryParam["StuName"].IsEmpty())
- {
- dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.StuName Like @StuName ");
- }
- if (!queryParam["AcademicYearNo"].IsEmpty())
- {
- dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
- strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo ");
- }
- if (!queryParam["Semester"].IsEmpty())
- {
- dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
- strSql.Append(" AND t.Semester = @Semester ");
- }
-
- return this.BaseRepository("CollegeMIS").FindList<StudentCompetitionEntity>(strSql.ToString(), dp);
-
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- public void DeleteEntity(string keyValue)
- {
- try
- {
- this.BaseRepository("CollegeMIS").Delete<StudentCompetitionEntity>(t => t.Id == keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="entity">实体</param>
- /// <returns></returns>
- public void SaveEntity(string keyValue, StudentCompetitionEntity entity)
- {
- try
- {
- if (!string.IsNullOrEmpty(keyValue))
- {
- entity.Modify(keyValue);
- this.BaseRepository("CollegeMIS").Update(entity);
- }
- else
- {
- entity.Create();
- this.BaseRepository("CollegeMIS").Insert(entity);
- }
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- public void ChangeStatusByProcessId(string processId, int status)
- {
- try
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql($"update StudentCompetition set Status='{status}' where processId='{processId}'");
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- public void ChangeStatusById(string keyValue, int status, string processId)
- {
- try
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql($"update StudentCompetition set Status='{status}',processId='{processId}' where Id='{keyValue}'");
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- #endregion
-
- }
- }
|