团餐订单
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.
 
 

83 lines
2.8 KiB

  1. using BPA.KitChen.GroupMealOrder.Core.Entity;
  2. using BPA.KitChen.GroupMealOrder.Core.Enum;
  3. using BPA.KitChen.GroupMealOrder.SqlSugar;
  4. using MySqlConnector;
  5. using System.Collections.Generic;
  6. using System.ComponentModel.DataAnnotations;
  7. namespace BPA.KitChen.GroupMealOrder.Application.BaseDto
  8. {
  9. /// <summary>
  10. /// Dto参数验证
  11. /// </summary>
  12. public class DtoValidator
  13. {
  14. /// <summary>
  15. /// 验证会员
  16. /// </summary>
  17. /// <param name="id"></param>
  18. /// <returns></returns>
  19. public static ValidationResult Member(string id)
  20. {
  21. var data = SqlSugarDb.Db.Queryable<BPA_MemberInfo>().First(x => x.Id == id&&x.IsDeleted==0);
  22. return data == null ? new ValidationResult("会员不存在") : ValidationResult.Success;
  23. }
  24. /// <summary>
  25. /// 验证会员标签的合法性
  26. /// </summary>
  27. /// <param name="id"></param>
  28. /// <returns></returns>
  29. public static ValidationResult MemberTag(string id)
  30. {
  31. var data = SqlSugarDb.Db.Queryable<BPA_MemberTag>().First(x=>x.Id==id);
  32. return data == null ? new ValidationResult("会员标签不存在") : ValidationResult.Success;
  33. }
  34. /// <summary>
  35. /// 验证会员标签的合法性
  36. /// </summary>
  37. /// <param name="id"></param>
  38. /// <returns></returns>
  39. public static ValidationResult MemberTagList(List<string> ids)
  40. {
  41. var data = SqlSugarDb.Db.Queryable<BPA_MemberTag>().Where(x => ids.Contains(x.Id) && x.IsDeleted == 0&&x.Status== CommonStatus.ENABLE).ToList();
  42. return data.Count<=0 ? new ValidationResult("会员标签不存在") : ValidationResult.Success;
  43. }
  44. /// <summary>
  45. /// 会员平台
  46. /// </summary>
  47. /// <param name="type"></param>
  48. /// <returns></returns>
  49. public static ValidationResult MemberPlatformType(int type)
  50. {
  51. return !System.Enum.IsDefined(typeof(PlatformType), type) ? new ValidationResult("平台类型不存在") : ValidationResult.Success;
  52. }
  53. /// <summary>
  54. /// 会员平台
  55. /// </summary>
  56. /// <param name="type"></param>
  57. /// <returns></returns>
  58. public static ValidationResult Status(int type)
  59. {
  60. return !System.Enum.IsDefined(typeof(CommonStatus), type) ? new ValidationResult("状态错误") : ValidationResult.Success;
  61. }
  62. /// <summary>
  63. /// 优惠券使用
  64. /// </summary>
  65. /// <param name="type"></param>
  66. /// <returns></returns>
  67. public static ValidationResult CouponUseType(int type)
  68. {
  69. return !System.Enum.IsDefined(typeof(CouponUseType), type) ? new ValidationResult("状态错误") : ValidationResult.Success;
  70. }
  71. }
  72. }