sys_price_conf_mapper.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # # -*- coding: utf-8 -*-
  2. # # @Author : YY
  3. # # @FileName: sys_stuff_info_conf_mapper.py
  4. # # @Time : 2025-12-22 04:49:51
  5. #
  6. # from typing import List
  7. # from datetime import datetime
  8. #
  9. # from flask import g
  10. # from sqlalchemy import select, update, delete
  11. #
  12. # from ruoyi_admin.ext import db
  13. # from ruoyi_common.domain.entity import SysPriceConf
  14. # from ruoyi_system.domain.po import SysPriceConfPo
  15. #
  16. #
  17. # class SysPriceConfMapper:
  18. # """价目配置表Mapper"""
  19. #
  20. # @staticmethod
  21. # def select_sys_stuff_info_conf_list(sys: SysPriceConf) -> List[SysPriceConf]:
  22. # """
  23. # 查询价目配置表列表
  24. #
  25. # Args:
  26. # sys (sys_stuff_info_conf): 价目配置表对象
  27. #
  28. # Returns:
  29. # List[sys_stuff_info_conf]: 价目配置表列表
  30. # """
  31. # try:
  32. # # 构建查询条件
  33. # stmt = select(SysPriceConfPo)
  34. #
  35. #
  36. # if sys.conf_id is not None:
  37. # stmt = stmt.where(SysPriceConfPo.conf_id == sys.conf_id)
  38. #
  39. #
  40. #
  41. # if sys.module_index is not None:
  42. # stmt = stmt.where(SysPriceConfPo.module_index == sys.module_index)
  43. #
  44. #
  45. #
  46. # if sys.category is not None:
  47. # stmt = stmt.where(SysPriceConfPo.category == sys.category)
  48. #
  49. #
  50. #
  51. # if sys.attributes is not None:
  52. # stmt = stmt.where(SysPriceConfPo.attributes == sys.attributes)
  53. #
  54. #
  55. # if "criterian_meta" in g and g.criterian_meta.page:
  56. # g.criterian_meta.page.stmt = stmt
  57. #
  58. # result = db.session.execute(stmt).scalars().all()
  59. # return [SysPriceConf.model_validate(item) for item in result] if result else []
  60. # except Exception as e:
  61. # print(f"查询价目配置表列表出错: {e}")
  62. # return []
  63. #
  64. #
  65. # @staticmethod
  66. # def select_sys_stuff_info_conf_by_id(conf_id: int) -> SysPriceConf:
  67. # """
  68. # 根据ID查询价目配置表
  69. #
  70. # Args:
  71. # conf_id (int): conf_id
  72. #
  73. # Returns:
  74. # sys_stuff_info_conf: 价目配置表对象
  75. # """
  76. # try:
  77. # result = db.session.get(SysPriceConfPo, conf_id)
  78. # return SysPriceConf.model_validate(result) if result else None
  79. # except Exception as e:
  80. # print(f"根据ID查询价目配置表出错: {e}")
  81. # return None
  82. #
  83. #
  84. # @staticmethod
  85. # def insert_sys_stuff_info_conf(sys: SysPriceConf) -> int:
  86. # """
  87. # 新增价目配置表
  88. #
  89. # Args:
  90. # sys (sys_stuff_info_conf): 价目配置表对象
  91. #
  92. # Returns:
  93. # int: 插入的记录数
  94. # """
  95. # try:
  96. # now = datetime.now()
  97. # new_po = SysPriceConfPo()
  98. # new_po.conf_id = sys.conf_id
  99. # new_po.module_index = sys.module_index
  100. # new_po.category = sys.category
  101. # new_po.attributes = sys.attributes
  102. # db.session.add(new_po)
  103. # db.session.commit()
  104. # sys.conf_id = new_po.conf_id
  105. # return 1
  106. # except Exception as e:
  107. # db.session.rollback()
  108. # print(f"新增价目配置表出错: {e}")
  109. # return 0
  110. #
  111. #
  112. # @staticmethod
  113. # def update_sys_stuff_info_conf(sys: SysPriceConf) -> int:
  114. # """
  115. # 修改价目配置表
  116. #
  117. # Args:
  118. # sys (sys_stuff_info_conf): 价目配置表对象
  119. #
  120. # Returns:
  121. # int: 更新的记录数
  122. # """
  123. # try:
  124. #
  125. # existing = db.session.get(SysPriceConfPo, sys.conf_id)
  126. # if not existing:
  127. # return 0
  128. # now = datetime.now()
  129. # # 主键不参与更新
  130. # existing.module_index = sys.module_index
  131. # existing.category = sys.category
  132. # existing.attributes = sys.attributes
  133. # db.session.commit()
  134. # return 1
  135. #
  136. # except Exception as e:
  137. # db.session.rollback()
  138. # print(f"修改价目配置表出错: {e}")
  139. # return 0
  140. #
  141. # @staticmethod
  142. # def delete_sys_stuff_info_conf_by_ids(ids: List[int]) -> int:
  143. # """
  144. # 批量删除价目配置表
  145. #
  146. # Args:
  147. # ids (List[int]): ID列表
  148. #
  149. # Returns:
  150. # int: 删除的记录数
  151. # """
  152. # try:
  153. # stmt = delete(SysPriceConfPo).where(SysPriceConfPo.conf_id.in_(ids))
  154. # result = db.session.execute(stmt)
  155. # db.session.commit()
  156. # return result.rowcount
  157. # except Exception as e:
  158. # db.session.rollback()
  159. # print(f"批量删除价目配置表出错: {e}")
  160. # return 0
  161. #