123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- using Lottomat.Data.Repository;
- using Lottomat.Util;
- using Lottomat.Util.WebControl;
- using Lottomat.Util.Extension;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data.Common;
- using Lottomat.Application.Code;
- using Lottomat.Data;
- using Lottomat.Application.Entity.BaseManage;
- using Lottomat.Application.IService.BaseManage;
- using Lottomat.Application.Service.AuthorizeManage;
- using Lottomat.Application.IService.AuthorizeManage;
- using Newtonsoft.Json.Linq;
- namespace Lottomat.Application.Service.BaseManage
- {
- /// <summary>
- /// 版 本
- /// Copyright (c) 2016-2017
- /// 创建人:赵轶
- /// 日 期:2015.11.4 14:31
- /// 描 述:角色管理
- /// </summary>
- public class RoleService : RepositoryFactory<RoleEntity>, IRoleService
- {
- private IAuthorizeService<RoleEntity> iauthorizeservice = new AuthorizeService<RoleEntity>();
- #region 获取数据
- /// <summary>
- /// 角色列表
- /// </summary>
- /// <returns></returns>
- public IEnumerable<RoleEntity> GetList()
- {
- var expression = LinqExtensions.True<RoleEntity>();
- expression = expression.And(t => t.Category == 1).And(t => t.EnabledMark == (int)EnabledMarkEnum.Enabled).And(t => t.DeleteMark == (int)DeleteMarkEnum.NotDelete);
- return this.BaseRepository().IQueryable(expression).OrderByDescending(t => t.CreateDate).ToList();
- }
- /// <summary>
- /// 角色列表
- /// </summary>
- /// <param name="pagination">分页</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<RoleEntity> GetPageList(Pagination pagination, string queryJson)
- {
- var expression = LinqExtensions.True<RoleEntity>();
- JObject queryParam = queryJson.ToJObject();
- if (queryParam != null)
- {
- //查询条件
- if (!queryParam["condition"].IsEmpty() && !queryParam["keyword"].IsEmpty())
- {
- string condition = queryParam["condition"].ToString();
- string keyword = queryParam["keyword"].ToString();
- switch (condition)
- {
- case "EnCode": //角色编号
- expression = expression.And(t => t.EnCode.Contains(keyword));
- break;
- case "FullName": //角色名称
- expression = expression.And(t => t.FullName.Contains(keyword));
- break;
- default:
- break;
- }
- }
- }
-
- expression = expression.And(t => t.Category == 1);
- return this.BaseRepository().FindList(expression, pagination);
- }
- /// <summary>
- /// 角色列表all
- /// </summary>
- /// <returns></returns>
- public IEnumerable<RoleEntity> GetAllList()
- {
- var strSql = new StringBuilder();
- strSql.Append(@"SELECT r.RoleId ,
- o.FullName AS OrganizeId ,
- r.Category ,
- r.EnCode ,
- r.FullName ,
- r.SortCode ,
- r.EnabledMark ,
- r.Description ,
- r.CreateDate
- FROM Base_Role r
- LEFT JOIN Base_Organize o ON o.OrganizeId = r.OrganizeId
- WHERE o.FullName is not null and r.Category = 1 and r.EnabledMark =1
- ORDER BY o.FullName, r.SortCode");
- return this.BaseRepository().FindList(strSql.ToString());
- }
- /// <summary>
- /// 角色实体
- /// </summary>
- /// <param name="keyValue">主键值</param>
- /// <returns></returns>
- public RoleEntity GetEntity(string keyValue)
- {
- return this.BaseRepository().FindEntity(keyValue);
- }
- #endregion
- #region 验证数据
- /// <summary>
- /// 角色编号不能重复
- /// </summary>
- /// <param name="enCode">编号</param>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- public bool ExistEnCode(string enCode, string keyValue)
- {
- var expression = LinqExtensions.True<RoleEntity>();
- expression = expression.And(t => t.EnCode == enCode).And(t => t.Category == 1);
- if (!string.IsNullOrEmpty(keyValue))
- {
- expression = expression.And(t => t.RoleId != keyValue);
- }
- return this.BaseRepository().IQueryable(expression).Count() == 0 ? true : false;
- }
- /// <summary>
- /// 角色名称不能重复
- /// </summary>
- /// <param name="fullName">名称</param>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- public bool ExistFullName(string fullName, string keyValue)
- {
- var expression = LinqExtensions.True<RoleEntity>();
- expression = expression.And(t => t.FullName == fullName).And(t => t.Category == 1);
- if (!string.IsNullOrEmpty(keyValue))
- {
- expression = expression.And(t => t.RoleId != keyValue);
- }
- return this.BaseRepository().IQueryable(expression).Count() == 0 ? true : false;
- }
- #endregion
- #region 提交数据
- /// <summary>
- /// 删除角色
- /// </summary>
- /// <param name="keyValue">主键</param>
- public void RemoveForm(string keyValue)
- {
- this.BaseRepository().Delete(keyValue);
- }
- /// <summary>
- /// 保存角色表单(新增、修改)
- /// </summary>
- /// <param name="keyValue">主键值</param>
- /// <param name="roleEntity">角色实体</param>
- /// <returns></returns>
- public void SaveForm(string keyValue, RoleEntity roleEntity)
- {
- if (!string.IsNullOrEmpty(keyValue))
- {
- roleEntity.Modify(keyValue);
- this.BaseRepository().Update(roleEntity);
- }
- else
- {
- roleEntity.Create();
- roleEntity.Category = 1;
- this.BaseRepository().Insert(roleEntity);
- }
- }
- #endregion
- }
- }
|