|
- using BPA.SAAS.Manage.Application.Org.Dtos.Role;
- using BPA.SAAS.Manage.Application.Org.Interface;
- using BPA.SAAS.Manage.Comm.Const;
- using BPA.SAAS.Manage.Core.Org;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPA.SAAS.Manage.Application.Org.Services
- {
- public class RoleService: IRoleService, ITransient
- {
- private readonly ISqlSugarClient _db;
- public RoleService(ISqlSugarClient db)
- {
- _db=db;
- }
- public async Task<bool> Add(RoleDtoInput input)
- {
-
- if (input.Code != "sys_manager_role")
- {
- var resEntitites = _db.Queryable<BPA_Roles>().Where(a => a.Code == input.Code).ToList();
- if (resEntitites.Count() > 0)
- {
- throw Oops.Oh("已存在相同编码的角色");
- }
- }
- var role = input.Adapt<BPA_Roles>();
- role.Id = Guid.NewGuid().ToString();
- role.CreateAt=DateTime.Now;
- role.CreateBy = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
- // role.DataScopeType = DataScopeType.ALL;
- return await _db.Insertable(role).ExecuteCommandAsync() > 0;
- }
- }
- }
|