基础服务api
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

40 行
1.3 KiB

  1. using BPA.SAAS.Manage.Application.Org.Dtos.Role;
  2. using BPA.SAAS.Manage.Application.Org.Interface;
  3. using BPA.SAAS.Manage.Comm.Const;
  4. using BPA.SAAS.Manage.Core.Org;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace BPA.SAAS.Manage.Application.Org.Services
  11. {
  12. public class RoleService: IRoleService, ITransient
  13. {
  14. private readonly ISqlSugarClient _db;
  15. public RoleService(ISqlSugarClient db)
  16. {
  17. _db=db;
  18. }
  19. public async Task<bool> Add(RoleDtoInput input)
  20. {
  21. if (input.Code != "sys_manager_role")
  22. {
  23. var resEntitites = _db.Queryable<BPA_Roles>().Where(a => a.Code == input.Code).ToList();
  24. if (resEntitites.Count() > 0)
  25. {
  26. throw Oops.Oh("已存在相同编码的角色");
  27. }
  28. }
  29. var role = input.Adapt<BPA_Roles>();
  30. role.Id = Guid.NewGuid().ToString();
  31. role.CreateAt=DateTime.Now;
  32. role.CreateBy = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
  33. // role.DataScopeType = DataScopeType.ALL;
  34. return await _db.Insertable(role).ExecuteCommandAsync() > 0;
  35. }
  36. }
  37. }