纽威
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.3 KiB

3 years ago
  1. using NFine.Code;
  2. using NFine.Domain.Entity.SystemManage;
  3. using NFine.Domain.IRepository.SystemManage;
  4. using NFine.Repository.SystemManage;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. namespace NFine.Application.SystemManage
  9. {
  10. public class ModuleButtonApp
  11. {
  12. private IModuleButtonRepository service = new ModuleButtonRepository();
  13. public List<ModuleButtonEntity> GetList(string moduleId = "")
  14. {
  15. var expression = ExtLinq.True<ModuleButtonEntity>();
  16. if (!string.IsNullOrEmpty(moduleId))
  17. {
  18. expression = expression.And(t => t.F_ModuleId == moduleId);
  19. }
  20. return service.IQueryable(expression).OrderBy(t => t.F_SortCode).ToList();
  21. }
  22. public ModuleButtonEntity GetForm(string keyValue)
  23. {
  24. return service.FindEntity(keyValue);
  25. }
  26. public void DeleteForm(string keyValue)
  27. {
  28. if (service.IQueryable().Count(t => t.F_ParentId.Equals(keyValue)) > 0)
  29. {
  30. throw new Exception("删除失败!操作的对象包含了下级数据。");
  31. }
  32. else
  33. {
  34. service.Delete(t => t.F_Id == keyValue);
  35. }
  36. }
  37. public void SubmitForm(ModuleButtonEntity moduleButtonEntity, string keyValue)
  38. {
  39. if (!string.IsNullOrEmpty(keyValue))
  40. {
  41. moduleButtonEntity.Modify(keyValue);
  42. service.Update(moduleButtonEntity);
  43. }
  44. else
  45. {
  46. moduleButtonEntity.Create();
  47. service.Insert(moduleButtonEntity);
  48. }
  49. }
  50. public void SubmitCloneButton(string moduleId, string Ids)
  51. {
  52. string[] ArrayId = Ids.Split(',');
  53. var data = this.GetList();
  54. List<ModuleButtonEntity> entitys = new List<ModuleButtonEntity>();
  55. foreach (string item in ArrayId)
  56. {
  57. ModuleButtonEntity moduleButtonEntity = data.Find(t => t.F_Id == item);
  58. moduleButtonEntity.F_Id = Common.GuId();
  59. moduleButtonEntity.F_ModuleId = moduleId;
  60. entitys.Add(moduleButtonEntity);
  61. }
  62. service.SubmitCloneButton(entitys);
  63. }
  64. }
  65. }