using Dapper;
using Learun.DataBase.Repository;
using Learun.Util;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
namespace Learun.Application.OA
{
///
/// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
/// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
/// 创 建:超级管理员
/// 日 期:2021-05-20 15:14
/// 描 述:失物招领
///
public class LostArticleInfoService : RepositoryFactory
{
#region 获取数据
///
/// 获取页面显示列表数据
///
/// 查询参数
/// 查询参数
///
public IEnumerable GetPageList(Pagination pagination, string queryJson)
{
try
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(@"t.*
");
strSql.Append(" FROM LostArticleInfo t ");
strSql.Append(" WHERE 1=1 ");
var queryParam = queryJson.ToJObject();
// 虚拟参数
var dp = new DynamicParameters(new { });
if (queryParam.HasValues)
{
if (!queryParam["F_FullHead"].IsEmpty())
{
dp.Add("F_FullHead", "%" + queryParam["F_FullHead"].ToString() + "%", DbType.String);
strSql.Append(" AND t.F_FullHead like @F_FullHead ");
}
}
return this.BaseRepository().FindList(strSql.ToString(), dp, pagination);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 获取LostArticleInfo表实体数据
///
/// 主键
///
public LostArticleInfoEntity GetLostArticleInfoEntity(string keyValue)
{
try
{
return this.BaseRepository().FindEntity(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
#endregion
#region 提交数据
///
/// 删除实体数据
///
/// 主键
public void DeleteEntity(string keyValue)
{
try
{
this.BaseRepository().Delete(t => t.F_LId == keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 保存实体数据(新增、修改)
///
/// 主键
/// 实体
public void SaveEntity(string keyValue, LostArticleInfoEntity entity)
{
try
{
if (!string.IsNullOrEmpty(keyValue))
{
entity.Modify(keyValue);
this.BaseRepository().Update(entity);
}
else
{
entity.Create();
this.BaseRepository().Insert(entity);
}
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 发布
///
/// 主键
public void PublishForm(string keyValue)
{
try
{
//草稿0、待认领1、已认领2
string sql = $"update LostArticleInfo set F_State=1 where F_LId='{keyValue}'";
this.BaseRepository().ExecuteBySql(sql);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 认领
///
/// 主键
public void ClaimForm(string keyValue, LostArticleInfoEntity entity)
{
try
{
//草稿0、待认领1、已认领2
UserInfo userInfo = LoginUserInfo.Get();
string sql = $@"update LostArticleInfo set F_State=2,F_User='{entity.F_User}',F_UserTime='{entity.F_UserTime}',F_ClaimImage='{entity.F_ClaimImage}',
F_ManageUserId='{userInfo.userId}',F_ManageUserName='{userInfo.realName}' where F_LId='{keyValue}'";
this.BaseRepository().ExecuteBySql(sql);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 撤下
///
/// 主键
public void CancleForm(string keyValue)
{
try
{
//草稿0、待认领1、已认领2
string sql = $"update LostArticleInfo set F_State=0 where F_LId='{keyValue}'";
this.BaseRepository().ExecuteBySql(sql);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
#endregion
}
}