ry_sys_base.py 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384
  1. # -*- coding: utf-8 -*-
  2. from sqlalchemy import String, Column, Integer,DateTime,Text,BigInteger,Boolean,PrimaryKeyConstraint,Index,UniqueConstraint,CHAR,LargeBinary,TIMESTAMP
  3. from sqlalchemy.dialects.mysql import TINYINT
  4. from sqlalchemy.sql import func
  5. from database import Base
  6. from datetime import datetime
  7. '''社会化关系表'''
  8. class SysSocial(Base):
  9. __tablename__ = 'sys_social'
  10. id = Column(BigInteger, primary_key=True,autoincrement=True, comment='主键')
  11. user_id = Column(BigInteger, nullable=False, comment='用户ID')
  12. tenant_id = Column(String(20), default=None, comment='租户id')
  13. auth_id = Column(String(255), nullable=False, comment='平台+平台唯一id')
  14. source = Column(String(255), nullable=False, comment='用户来源')
  15. open_id = Column(String(255), default=None, comment='平台编号唯一id')
  16. user_name = Column(String(30), nullable=False, comment='登录账号')
  17. nick_name = Column(String(30), default='', comment='用户昵称')
  18. email = Column(String(255), default='', comment='用户邮箱')
  19. avatar = Column(String(500), default='', comment='头像地址')
  20. access_token = Column(String(255), nullable=False, comment='用户的授权令牌')
  21. expire_in = Column(Integer, default=None, comment='用户的授权令牌的有效期')
  22. refresh_token = Column(String(255), default=None, comment='刷新令牌')
  23. access_code = Column(String(255), default=None, comment='平台的授权信息')
  24. union_id = Column(String(255), default=None, comment='用户的 unionid')
  25. scope = Column(String(255), default=None, comment='授予的权限')
  26. token_type = Column(String(255), default=None, comment='个别平台的授权信息')
  27. id_token = Column(String(2000), default=None, comment='id token')
  28. mac_algorithm = Column(String(255), default=None, comment='小米平台用户的附带属性')
  29. mac_key = Column(String(255), default=None, comment='小米平台用户的附带属性')
  30. code = Column(String(255), default=None, comment='用户的授权code')
  31. oauth_token = Column(String(255), default=None, comment='Twitter平台用户的附带属性')
  32. oauth_token_secret = Column(String(255), default=None, comment='Twitter平台用户的附带属性')
  33. create_dept = Column(BigInteger, default=None, comment='创建部门')
  34. create_by = Column(BigInteger, default=None, comment='创建者')
  35. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  36. update_by = Column(BigInteger, default=None, comment='更新者')
  37. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  38. del_flag = Column(String(1), default='0', comment='删除标志(0代表存在 2代表删除)')
  39. class Config:
  40. orm_mode = True
  41. '''租户表'''
  42. class SysTenant(Base):
  43. __tablename__ = 'sys_tenant'
  44. id = Column(BigInteger, primary_key=True,autoincrement=True, comment='id')
  45. tenant_id = Column(String(20), nullable=False, comment='租户编号')
  46. contact_user_name = Column(String(20), comment='联系人')
  47. contact_phone = Column(String(20), comment='联系电话')
  48. company_name = Column(String(50), comment='企业名称')
  49. license_number = Column(String(30), comment='统一社会信用代码')
  50. address = Column(String(200), comment='地址')
  51. intro = Column(String(200), comment='企业简介')
  52. domain = Column(String(200), comment='域名')
  53. remark = Column(String(200), comment='备注')
  54. package_id = Column(BigInteger, comment='租户套餐编号')
  55. expire_time = Column(DateTime, comment='过期时间')
  56. account_count = Column(Integer, default=-1, comment='用户数量(-1不限制)')
  57. status = Column(String(1), default='0', comment='租户状态(0正常 1停用)')
  58. del_flag = Column(String(1), default='0', comment='删除标志(0代表存在 2代表删除)')
  59. create_dept = Column(BigInteger, default=None, comment='创建部门')
  60. create_by = Column(BigInteger, default=None, comment='创建者')
  61. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  62. update_by = Column(BigInteger, default=None, comment='更新者')
  63. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  64. class Config:
  65. orm_mode = True
  66. '''租户套餐表'''
  67. class SysTenantPackage(Base):
  68. __tablename__ = 'sys_tenant_package'
  69. package_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='租户套餐id')
  70. package_name = Column(String(20), comment='套餐名称')
  71. menu_ids = Column(String(3000), comment='关联菜单id')
  72. remark = Column(String(200), comment='备注')
  73. menu_check_strictly = Column(Integer, default=1, comment='菜单树选择项是否关联显示')
  74. status = Column(String(1), default='0', comment='状态(0正常 1停用)')
  75. del_flag = Column(String(1), default='0', comment='删除标志(0代表存在 2代表删除)')
  76. create_dept = Column(BigInteger, default=None, comment='创建部门')
  77. create_by = Column(BigInteger, default=None, comment='创建者')
  78. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  79. update_by = Column(BigInteger, default=None, comment='更新者')
  80. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  81. class Config:
  82. orm_mode = True
  83. '''部门表'''
  84. class SysDept(Base):
  85. __tablename__ = 'sys_dept'
  86. dept_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='部门id')
  87. tenant_id = Column(String(20), default='000000', comment='租户编号')
  88. parent_id = Column(BigInteger, default=0, comment='父部门id')
  89. parent_name = Column(String(30), default='', comment='父部门名称')
  90. ancestors = Column(String(500), default='', comment='祖级列表')
  91. dept_name = Column(String(30), default='', comment='部门名称')
  92. dept_category = Column(String(100), default='', comment='部门类别编码')
  93. order_num = Column(Integer, default=0, comment='显示顺序')
  94. leader = Column(BigInteger, default=None, comment='负责人')
  95. leader_name = Column(String(30), default='', comment='负责人姓名')
  96. phone = Column(String(100), default='', comment='联系电话')
  97. email = Column(String(100), default='', comment='邮箱')
  98. status = Column(String(1), default='0', comment='部门状态(0正常 1停用)')
  99. del_flag = Column(String(1), default='0', comment='删除标志(0代表存在 2代表删除)')
  100. create_dept = Column(BigInteger, default=None, comment='创建部门')
  101. create_by = Column(BigInteger, default=None, comment='创建者')
  102. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  103. update_by = Column(BigInteger, default=None, comment='更新者')
  104. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  105. sign = Column(String, server_default='', default='', comment='HMACSM3数值')
  106. class Config:
  107. orm_mode = True
  108. '''用户信息表'''
  109. class SysUser(Base):
  110. __tablename__ = 'sys_user'
  111. user_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='用户ID')
  112. tenant_id = Column(String(20), default='000000', comment='租户编号')
  113. dept_id = Column(BigInteger, default=None, comment='部门ID')
  114. dept_name = Column(String(30), default='', comment='部门名称')
  115. user_name = Column(String(30), nullable=False, comment='用户账号')
  116. nick_name = Column(String(30), nullable=False, comment='用户昵称')
  117. user_type = Column(String(10), default='sys_user', comment='用户类型(sys_user系统用户)')
  118. email = Column(String(50), default='', comment='用户邮箱')
  119. phonenumber = Column(String(11), default='', comment='手机号码')
  120. sex = Column(String(1), default='0', comment='用户性别(0男 1女 2未知)')
  121. avatar = Column(BigInteger, default='0', comment='头像地址')
  122. password = Column(String(100), default='', comment='密码')
  123. status = Column(String(1), default='0', comment='帐号状态(0正常 1停用)')
  124. del_flag = Column(String(1), default='0', comment='删除标志(0代表存在 2代表删除)')
  125. login = Column(Integer, default=0, comment='登录次数')
  126. login_ip = Column(String(128), default='', comment='最后登录IP')
  127. login_date = Column(DateTime, default=datetime.now, comment='最后登录时间')
  128. create_dept = Column(BigInteger, default=None, comment='创建部门')
  129. create_by = Column(BigInteger, default=None, comment='创建者')
  130. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  131. update_by = Column(BigInteger, default=None, comment='更新者')
  132. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  133. remark = Column(String(500), default=None, comment='备注')
  134. yzy_account = Column(String(50), default=None, comment='粤政易账号')
  135. sign = Column(String, server_default='', default='', comment='HMACSM3数值')
  136. class Config:
  137. orm_mode = True
  138. '''岗位信息表'''
  139. class SysPost(Base):
  140. __tablename__ = 'sys_post'
  141. post_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='岗位ID')
  142. tenant_id = Column(String(20), default='000000', comment='租户编号')
  143. dept_id = Column(BigInteger, nullable=False, comment='部门id')
  144. post_code = Column(String(64), nullable=False, comment='岗位编码')
  145. post_category = Column(String(100), default=None, comment='岗位类别编码')
  146. post_name = Column(String(50), nullable=False, comment='岗位名称')
  147. post_sort = Column(Integer, nullable=False, comment='显示顺序')
  148. status = Column(String(1), nullable=False, comment='状态(0正常 1停用)')
  149. create_dept = Column(BigInteger, default=None, comment='创建部门')
  150. create_by = Column(BigInteger, default=None, comment='创建者')
  151. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  152. update_by = Column(BigInteger, default=None, comment='更新者')
  153. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  154. remark = Column(String(500), default=None, comment='备注')
  155. sign = Column(String, server_default='', default='', comment='HMACSM3数值')
  156. class Config:
  157. orm_mode = True
  158. '''角色信息表'''
  159. class SysRole(Base):
  160. __tablename__ = 'sys_role'
  161. role_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='角色ID')
  162. tenant_id = Column(String(20), default='000000', comment='租户编号')
  163. role_name = Column(String(30), nullable=False, comment='角色名称')
  164. role_key = Column(String(100), nullable=False, comment='角色权限字符串')
  165. role_sort = Column(Integer, nullable=False, comment='显示顺序')
  166. data_scope = Column(String(1), default='1', comment='数据范围')
  167. menu_check_strictly = Column(Integer, default=1, comment='菜单树选择项是否关联显示')
  168. dept_check_strictly = Column(Integer, default=1, comment='部门树选择项是否关联显示')
  169. status = Column(String(1), nullable=False, comment='角色状态(0正常 1停用)')
  170. del_flag = Column(String(1), default='0', comment='删除标志(0代表存在 2代表删除)')
  171. create_dept = Column(BigInteger, default=None, comment='创建部门')
  172. create_by = Column(BigInteger, default=None, comment='创建者')
  173. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  174. update_by = Column(BigInteger, default=None, comment='更新者')
  175. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  176. remark = Column(String(500), default=None, comment='备注')
  177. sign = Column(String, server_default='', default='', comment='HMACSM3数值')
  178. class Config:
  179. orm_mode = True
  180. '''菜单权限表'''
  181. class SysMenu(Base):
  182. __tablename__ = 'sys_menu'
  183. menu_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='菜单ID')
  184. menu_name = Column(String(50), nullable=False, comment='菜单名称')
  185. parent_id = Column(BigInteger, default=0, comment='父菜单ID')
  186. order_num = Column(Integer, default=0, comment='显示顺序')
  187. path = Column(String(200), default='', comment='路由地址')
  188. component = Column(String(255), default=None, comment='组件路径')
  189. query_param = Column(String(255), default=None, comment='路由参数')
  190. is_frame = Column(Integer, default=1, comment='是否为外链(0是 1否)')
  191. is_cache = Column(Integer, default=0, comment='是否缓存(0缓存 1不缓存)')
  192. menu_type = Column(String(1), default='', comment='菜单类型(M目录 C菜单 F按钮)')
  193. visible = Column(String(1), default='0', comment='显示状态(0显示 1隐藏)')
  194. status = Column(String(1), default='0', comment='菜单状态(0正常 1停用)')
  195. perms = Column(String(100), default=None, comment='权限标识')
  196. icon = Column(String(100), default='#', comment='菜单图标')
  197. create_dept = Column(BigInteger, default=None, comment='创建部门')
  198. create_by = Column(BigInteger, default=None, comment='创建者')
  199. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  200. update_by = Column(BigInteger, default=None, comment='更新者')
  201. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  202. remark = Column(String(500), default='', comment='备注')
  203. del_flag = Column(String(1), default='0', comment='删除标志(0代表存在 2代表删除)')
  204. sign = Column(String, server_default='', default='', comment='HMACSM3数值')
  205. class Config:
  206. orm_mode = True
  207. '''用户和角色关联表'''
  208. class SysUserRole(Base):
  209. __tablename__ = 'sys_user_role'
  210. __table_args__ = (PrimaryKeyConstraint('role_id', 'user_id'),)
  211. user_id = Column(BigInteger, nullable=True, comment='用户ID')
  212. role_id = Column(BigInteger, nullable=True, comment='角色ID')
  213. sign = Column(String, server_default='', default='', comment='HMACSM3数值')
  214. class Config:
  215. orm_mode = True
  216. '''用户和视频关联表'''
  217. class SysUserVideo(Base):
  218. __tablename__ = 'sys_user_video'
  219. __table_args__ = (PrimaryKeyConstraint('video_code_int', 'user_id'),)
  220. user_id = Column(BigInteger, nullable=True, comment='用户ID')
  221. video_code_int = Column(String(255), nullable=True, comment='视频ID')
  222. class Config:
  223. orm_mode = True
  224. '''角色和菜单关联表'''
  225. class SysRoleMenu(Base):
  226. __tablename__ = 'sys_role_menu'
  227. __table_args__ = (PrimaryKeyConstraint('role_id', 'menu_id'),)
  228. role_id = Column(BigInteger, nullable=False, comment='角色ID')
  229. menu_id = Column(BigInteger, nullable=False, comment='菜单ID')
  230. sign = Column(String, server_default='', default='', comment='HMACSM3数值')
  231. class Config:
  232. orm_mode = True
  233. '''角色和部门关联表'''
  234. class SysRoleDept(Base):
  235. __tablename__ = 'sys_role_dept'
  236. __table_args__ = (PrimaryKeyConstraint('role_id', 'dept_id'),)
  237. role_id = Column(BigInteger, nullable=False, comment='角色ID')
  238. dept_id = Column(BigInteger, nullable=False, comment='部门ID')
  239. sign = Column(String, server_default='', default='', comment='HMACSM3数值')
  240. class Config:
  241. orm_mode = True
  242. '''用户与岗位关联表'''
  243. class SysUserPost(Base):
  244. __tablename__ = 'sys_user_post'
  245. __table_args__ = (PrimaryKeyConstraint('user_id', 'post_id'),)
  246. user_id = Column(BigInteger, nullable=False, comment='用户ID')
  247. post_id = Column(BigInteger, nullable=False, comment='岗位ID')
  248. sign = Column(String, server_default='', default='', comment='HMACSM3数值')
  249. class Config:
  250. orm_mode = True
  251. '''菜单权限表'''
  252. class SysMenuLayer(Base):
  253. __tablename__ = 'sys_menu_layer'
  254. menu_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='菜单ID')
  255. menu_name = Column(String(50), nullable=False, comment='菜单名称')
  256. parent_id = Column(BigInteger, default=0, comment='父菜单ID')
  257. order_num = Column(Integer, default=0, comment='显示顺序')
  258. path = Column(String(200), default='', comment='路由地址')
  259. component = Column(String(255), default=None, comment='组件路径')
  260. query_param = Column(String(255), default=None, comment='路由参数')
  261. is_frame = Column(Integer, default=1, comment='是否为外链(0是 1否)')
  262. is_cache = Column(Integer, default=0, comment='是否缓存(0缓存 1不缓存)')
  263. menu_type = Column(String(1), default='', comment='菜单类型(M目录 C菜单 F按钮)')
  264. layer_visible = Column(String(1), default='0', comment='显示状态(0显示 1隐藏)')
  265. status = Column(String(1), default='0', comment='菜单状态(0正常 1停用)')
  266. perms = Column(String(100), default=None, comment='权限标识')
  267. icon = Column(String(100), default='#', comment='菜单图标')
  268. create_dept = Column(BigInteger, default=None, comment='创建部门')
  269. create_by = Column(BigInteger, default=None, comment='创建者')
  270. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  271. update_by = Column(BigInteger, default=None, comment='更新者')
  272. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  273. remark = Column(String(500), default='', comment='备注')
  274. del_flag = Column(String(1), default='0', comment='删除标志(0代表存在 2代表删除)')
  275. layer_template = Column(String(100), default='', comment='图层模板')
  276. sign = Column(String, server_default='', default='', comment='HMACSM3数值')
  277. class Config:
  278. orm_mode = True
  279. '''操作日志记录'''
  280. class SysOperLog(Base):
  281. __tablename__ = 'sys_oper_log'
  282. __table_args__ = (
  283. Index('idx_sys_oper_log_bt', 'business_type'),
  284. Index('idx_sys_oper_log_s', 'status'),
  285. Index('idx_sys_oper_log_ot', 'oper_time'),
  286. )
  287. oper_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='日志主键')
  288. tenant_id = Column(String(20), default='000000', comment='租户编号')
  289. title = Column(String(50), default='', comment='模块标题')
  290. business_type = Column(Integer, default=0, comment='业务类型(0其它 1新增 2修改 3删除)')
  291. method = Column(String(100), default='', comment='方法名称')
  292. request_method = Column(String(10), default='', comment='请求方式')
  293. operator_type = Column(Integer, default=0, comment='操作类别(0其它 1后台用户 2手机端用户)')
  294. oper_name = Column(String(50), default='', comment='操作人员')
  295. dept_name = Column(String(50), default='', comment='部门名称')
  296. oper_url = Column(String(255), default='', comment='请求URL')
  297. oper_ip = Column(String(128), default='', comment='主机地址')
  298. oper_location = Column(String(255), default='', comment='操作地点')
  299. oper_param = Column(Text, default='', comment='请求参数')
  300. json_result = Column(Text, default='', comment='返回参数')
  301. status = Column(Integer, default=0, comment='操作状态(0正常 1异常)')
  302. error_msg = Column(String(2000), default='', comment='错误消息')
  303. oper_time = Column(DateTime, comment='操作时间')
  304. cost_time = Column(BigInteger, default=0, comment='消耗时间')
  305. class Config:
  306. orm_mode = True
  307. '''字典类型表'''
  308. class SysDictType(Base):
  309. __tablename__ = 'sys_dict_type'
  310. dict_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='字典主键')
  311. tenant_id = Column(String(20), default='000000', comment='租户编号')
  312. dict_name = Column(String(100), default='', comment='字典名称')
  313. dict_type = Column(String(100), default='', comment='字典类型')
  314. create_dept = Column(BigInteger, default=None, comment='创建部门')
  315. create_by = Column(BigInteger, default=None, comment='创建者')
  316. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  317. update_by = Column(BigInteger, default=None, comment='更新者')
  318. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  319. remark = Column(String(500), default=None, comment='备注')
  320. del_flag = Column(String(1), default='0', comment='删除标志(0代表存在 2代表删除)')
  321. # 定义唯一性约束条件
  322. __table_args__ = (UniqueConstraint('tenant_id', 'dict_type', name='uq_sys_dict_type_tenant_type'),)
  323. class Config:
  324. orm_mode = True
  325. '''字典数据表'''
  326. class SysDictData(Base):
  327. __tablename__ = 'sys_dict_data'
  328. dict_code = Column(BigInteger, primary_key=True,autoincrement=True, comment='字典编码')
  329. tenant_id = Column(String(20), default='000000', comment='租户编号')
  330. dict_sort = Column(Integer, default=0, comment='字典排序')
  331. dict_label = Column(String(100), default='', comment='字典标签')
  332. dict_value = Column(String(100), default='', comment='字典键值')
  333. dict_type = Column(String(100), default='', comment='字典类型')
  334. css_class = Column(String(100), default=None, comment='样式属性(其他样式扩展)')
  335. list_class = Column(String(100), default=None, comment='表格回显样式')
  336. is_default = Column(CHAR(1), default='N', comment='是否默认(Y是 N否)')
  337. create_dept = Column(BigInteger, default=None, comment='创建部门')
  338. create_by = Column(BigInteger, default=None, comment='创建者')
  339. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  340. update_by = Column(BigInteger, default=None, comment='更新者')
  341. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  342. remark = Column(String(500), default=None, comment='备注')
  343. del_flag = Column(String(1), default='0', comment='删除标志(0代表存在 2代表删除)')
  344. class Config:
  345. orm_mode = True
  346. '''参数配置表'''
  347. class SysConfig(Base):
  348. __tablename__ = 'sys_config'
  349. config_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='参数主键')
  350. tenant_id = Column(String(20), default='000000', comment='租户编号')
  351. config_name = Column(String(100), default='', comment='参数名称')
  352. config_key = Column(String(100), default='', comment='参数键名')
  353. config_value = Column(String(500), default='', comment='参数键值')
  354. config_type = Column(CHAR(1), default='N', comment='系统内置(Y是 N否)')
  355. create_dept = Column(BigInteger, default=None, comment='创建部门')
  356. create_by = Column(BigInteger, default=None, comment='创建者')
  357. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  358. update_by = Column(BigInteger, default=None, comment='更新者')
  359. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  360. remark = Column(String(500), default=None, comment='备注')
  361. class Config:
  362. orm_mode = True
  363. '''系统访问记录'''
  364. class SysLoginInfor(Base):
  365. __tablename__ = 'sys_logininfor'
  366. info_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='访问ID')
  367. tenant_id = Column(String(20), default='000000', comment='租户编号')
  368. user_name = Column(String(50), default='', comment='用户账号')
  369. client_key = Column(String(32), default='', comment='客户端')
  370. device_type = Column(String(32), default='', comment='设备类型')
  371. ipaddr = Column(String(128), default='', comment='登录IP地址')
  372. login_location = Column(String(255), default='', comment='登录地点')
  373. browser = Column(String(50), default='', comment='浏览器类型')
  374. os = Column(String(50), default='', comment='操作系统')
  375. status = Column(CHAR(1), default='0', comment='登录状态(0成功 1失败)')
  376. msg = Column(String(255), default='', comment='提示消息')
  377. login_time = Column(DateTime, comment='访问时间')
  378. # 定义表的索引(可选,根据需要添加到Base中)
  379. __table_args__ = (
  380. # 假设Base已经包含了索引的创建方式
  381. Index('idx_sys_logininfor_s', 'status'),
  382. Index('idx_sys_logininfor_lt', 'login_time'),
  383. )
  384. class Config:
  385. orm_mode = True
  386. '''通知公告表'''
  387. class SysNotice(Base):
  388. __tablename__ = 'sys_notice'
  389. notice_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='公告ID')
  390. tenant_id = Column(String(20), default='000000', comment='租户编号')
  391. notice_title = Column(String(50), nullable=False, comment='公告标题')
  392. notice_type = Column(CHAR(1), nullable=False, comment='公告类型(1通知 2公告)')
  393. notice_content = Column(LargeBinary, default=None, comment='公告内容')
  394. status = Column(CHAR(1), default='0', comment='公告状态(0正常 1关闭)')
  395. create_dept = Column(BigInteger, default=None, comment='创建部门')
  396. create_by = Column(BigInteger, default=None, comment='创建者')
  397. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  398. update_by = Column(BigInteger, default=None, comment='更新者')
  399. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  400. remark = Column(String(255), default=None, comment='备注')
  401. class Config:
  402. orm_mode = True
  403. '''代码生成业务表'''
  404. class GenTable(Base):
  405. __tablename__ = 'gen_table'
  406. table_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='编号')
  407. data_name = Column(String(200), default='', comment='数据源名称')
  408. table_name = Column(String(200), default='', comment='表名称')
  409. table_comment = Column(String(500), default='', comment='表描述')
  410. sub_table_name = Column(String(64), default=None, comment='关联子表的表名')
  411. sub_table_fk_name = Column(String(64), default=None, comment='子表关联的外键名')
  412. class_name = Column(String(100), default='', comment='实体类名称')
  413. tpl_category = Column(String(200), default='crud', comment='使用的模板(crud单表操作 tree树表操作)')
  414. package_name = Column(String(100), comment='生成包路径')
  415. module_name = Column(String(30), comment='生成模块名')
  416. business_name = Column(String(30), comment='生成业务名')
  417. function_name = Column(String(50), comment='生成功能名')
  418. function_author = Column(String(50), comment='生成功能作者')
  419. gen_type = Column(CHAR(1), default='0', comment='生成代码方式(0zip压缩包 1自定义路径)')
  420. gen_path = Column(String(200), default='/', comment='生成路径(不填默认项目路径)')
  421. options = Column(String(1000), comment='其它生成选项')
  422. create_dept = Column(BigInteger, default=None, comment='创建部门')
  423. create_by = Column(BigInteger, default=None, comment='创建者')
  424. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  425. update_by = Column(BigInteger, default=None, comment='更新者')
  426. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  427. remark = Column(String(500), default=None, comment='备注')
  428. class Config:
  429. orm_mode = True
  430. '''代码生成业务表字段'''
  431. class GenTableColumn(Base):
  432. __tablename__ = 'gen_table_column'
  433. column_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='编号')
  434. table_id = Column(BigInteger, comment='归属表编号')
  435. column_name = Column(String(200), comment='列名称')
  436. column_comment = Column(String(500), comment='列描述')
  437. column_type = Column(String(100), comment='列类型')
  438. java_type = Column(String(500), comment='JAVA类型')
  439. java_field = Column(String(200), comment='JAVA字段名')
  440. is_pk = Column(CHAR(1), comment='是否主键(1是)')
  441. is_increment = Column(CHAR(1), comment='是否自增(1是)')
  442. is_required = Column(CHAR(1), comment='是否必填(1是)')
  443. is_insert = Column(CHAR(1), comment='是否为插入字段(1是)')
  444. is_edit = Column(CHAR(1), comment='是否编辑字段(1是)')
  445. is_list = Column(CHAR(1), comment='是否列表字段(1是)')
  446. is_query = Column(CHAR(1), comment='是否查询字段(1是)')
  447. query_type = Column(String(200), default='EQ', comment='查询方式(等于、不等于、大于、小于、范围)')
  448. html_type = Column(String(200), comment='显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)')
  449. dict_type = Column(String(200), default='', comment='字典类型')
  450. sort = Column(Integer, comment='排序')
  451. create_dept = Column(BigInteger, default=None, comment='创建部门')
  452. create_by = Column(BigInteger, default=None, comment='创建者')
  453. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  454. update_by = Column(BigInteger, default=None, comment='更新者')
  455. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  456. class Config:
  457. orm_mode = True
  458. '''OSS对象存储表'''
  459. class SysOss(Base):
  460. __tablename__ = 'sys_oss'
  461. oss_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='对象存储主键')
  462. tenant_id = Column(String(20), default='000000', comment='租户编号')
  463. file_name = Column(String(255), default='', nullable=False, comment='文件名')
  464. original_name = Column(String(255), default='', nullable=False, comment='原名')
  465. file_suffix = Column(String(10), default='', nullable=False, comment='文件后缀名')
  466. url = Column(String(500), nullable=False, comment='URL地址')
  467. create_dept = Column(BigInteger, default=None, comment='创建部门')
  468. create_by = Column(BigInteger, default=None, comment='创建者')
  469. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  470. update_by = Column(BigInteger, default=None, comment='更新者')
  471. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  472. service = Column(String(20), default='minio', nullable=False, comment='服务商')
  473. class Config:
  474. orm_mode = True
  475. '''对象存储配置表'''
  476. class SysOssConfig(Base):
  477. __tablename__ = 'sys_oss_config'
  478. oss_config_id = Column(BigInteger, primary_key=True,autoincrement=True, comment='主键')
  479. tenant_id = Column(String(20), default='000000', comment='租户编号')
  480. config_key = Column(String(20), default='', nullable=False, comment='配置key')
  481. access_key = Column(String(255), default='', comment='accessKey')
  482. secret_key = Column(String(255), default='', comment='秘钥')
  483. bucket_name = Column(String(255), default='', comment='桶名称')
  484. prefix = Column(String(255), default='', comment='前缀')
  485. endpoint = Column(String(255), default='', comment='访问站点')
  486. domain = Column(String(255), default='', comment='自定义域名')
  487. is_https = Column(CHAR(1), default='N', comment='是否https(Y=是,N=否)')
  488. region = Column(String(255), default='', comment='域')
  489. access_policy = Column(CHAR(1), nullable=False, default='1', comment='桶权限类型(0=private 1=public 2=custom)')
  490. status = Column(CHAR(1), default='1', comment='是否默认(0=是,1=否)')
  491. ext1 = Column(String(255), default='', comment='扩展字段')
  492. create_dept = Column(BigInteger, default=None, comment='创建部门')
  493. create_by = Column(BigInteger, default=None, comment='创建者')
  494. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  495. update_by = Column(BigInteger, default=None, comment='更新者')
  496. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  497. remark = Column(String(500), default=None, comment='备注')
  498. class Config:
  499. orm_mode = True
  500. '''系统授权表'''
  501. class SysClient(Base):
  502. __tablename__ = 'sys_client'
  503. id = Column(BigInteger, primary_key=True,autoincrement=True, comment='id')
  504. client_id = Column(String(64), default=None, comment='客户端id')
  505. client_key = Column(String(32), default=None, comment='客户端key')
  506. client_secret = Column(String(255), default=None, comment='客户端秘钥')
  507. grant_type = Column(String(255), default=None, comment='授权类型')
  508. device_type = Column(String(32), default=None, comment='设备类型')
  509. active_timeout = Column(Integer, default=1800, comment='token活跃超时时间')
  510. timeout = Column(Integer, default=604800, comment='token固定超时')
  511. status = Column(CHAR(1), default='0', comment='状态(0正常 1停用)')
  512. del_flag = Column(CHAR(1), default='0', comment='删除标志(0代表存在 2代表删除)')
  513. create_dept = Column(BigInteger, default=None, comment='创建部门')
  514. create_by = Column(BigInteger, default=None, comment='创建者')
  515. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  516. update_by = Column(BigInteger, default=None, comment='更新者')
  517. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  518. class Config:
  519. orm_mode = True
  520. '''测试单表'''
  521. class TestDemo(Base):
  522. __tablename__ = 'test_demo'
  523. id = Column(BigInteger, primary_key=True,autoincrement=True, comment='主键')
  524. tenant_id = Column(String(20), default='000000', comment='租户编号')
  525. dept_id = Column(BigInteger, default=None, comment='部门id')
  526. user_id = Column(BigInteger, default=None, comment='用户id')
  527. order_num = Column(Integer, default=0, comment='排序号')
  528. test_key = Column(String(255), default=None, comment='key键')
  529. value = Column(String(255), default=None, comment='值')
  530. version = Column(Integer, default=0, comment='版本')
  531. create_dept = Column(BigInteger, default=None, comment='创建部门')
  532. create_by = Column(BigInteger, default=None, comment='创建者')
  533. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  534. update_by = Column(BigInteger, default=None, comment='更新者')
  535. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  536. del_flag = Column(Integer, default=0, comment='删除标志')
  537. class Config:
  538. orm_mode = True
  539. '''测试树表'''
  540. class TestTree(Base):
  541. __tablename__ = 'test_tree'
  542. id = Column(BigInteger, primary_key=True,autoincrement=True, comment='主键')
  543. tenant_id = Column(String(20), default='000000', comment='租户编号')
  544. parent_id = Column(BigInteger, default=0, comment='父id')
  545. dept_id = Column(BigInteger, default=None, comment='部门id')
  546. user_id = Column(BigInteger, default=None, comment='用户id')
  547. tree_name = Column(String(255), default=None, comment='树节点名称')
  548. version = Column(Integer, default=0, comment='版本')
  549. create_dept = Column(BigInteger, default=None, comment='创建部门')
  550. create_by = Column(BigInteger, default=None, comment='创建者')
  551. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  552. update_by = Column(BigInteger, default=None, comment='更新者')
  553. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  554. del_flag = Column(Integer, default=0, comment='删除标志')
  555. class Config:
  556. orm_mode = True
  557. '''flowable'''
  558. '''请假申请表'''
  559. class TestLeave(Base):
  560. __tablename__ = 'test_leave'
  561. id = Column(BigInteger, primary_key=True, comment='主键')
  562. leave_type = Column(String(255), nullable=False, comment='请假类型')
  563. start_date = Column(DateTime, nullable=False, comment='开始时间')
  564. end_date = Column(DateTime, nullable=False, comment='结束时间')
  565. leave_days = Column(Integer, nullable=False, comment='请假天数')
  566. remark = Column(String(255), comment='请假原因')
  567. status = Column(String(255), comment='状态')
  568. create_dept = Column(BigInteger, default=None, comment='创建部门')
  569. create_by = Column(BigInteger, default=None, comment='创建者')
  570. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  571. update_by = Column(BigInteger, default=None, comment='更新者')
  572. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  573. tenant_id = Column(String(20), comment='租户编号')
  574. class Config:
  575. orm_mode = True
  576. '''流程分类'''
  577. class WfCategory(Base):
  578. __tablename__ = 'wf_category'
  579. id = Column(BigInteger, primary_key=True, comment='主键')
  580. category_name = Column(String(255), comment='分类名称')
  581. category_code = Column(String(255), comment='分类编码')
  582. parent_id = Column(BigInteger, comment='父级id')
  583. sort_num = Column(Integer, comment='排序')
  584. tenant_id = Column(String(20), comment='租户编号')
  585. create_dept = Column(BigInteger, default=None, comment='创建部门')
  586. create_by = Column(BigInteger, default=None, comment='创建者')
  587. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  588. update_by = Column(BigInteger, default=None, comment='更新者')
  589. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  590. # 定义唯一性约束条件
  591. __table_args__ = (UniqueConstraint('category_code', name='uni_category_code'),)
  592. class Config:
  593. orm_mode = True
  594. '''节点审批记录'''
  595. class WfTaskBackNode(Base):
  596. __tablename__ = 'wf_task_back_node'
  597. id = Column(BigInteger, primary_key=True, comment='主键')
  598. node_id = Column(String(255), nullable=False, comment='节点id')
  599. node_name = Column(String(255), nullable=False, comment='节点名称')
  600. order_no = Column(Integer, nullable=False, comment='排序')
  601. instance_id = Column(String(255), comment='流程实例id')
  602. task_type = Column(String(255), nullable=False, comment='节点类型')
  603. assignee = Column(String(2000), nullable=False, comment='审批人')
  604. tenant_id = Column(String(20), comment='租户编号')
  605. create_dept = Column(BigInteger, default=None, comment='创建部门')
  606. create_by = Column(BigInteger, default=None, comment='创建者')
  607. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  608. update_by = Column(BigInteger, default=None, comment='更新者')
  609. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  610. class Config:
  611. orm_mode = True
  612. '''流程定义配置'''
  613. class WfDefinitionConfig(Base):
  614. __tablename__ = 'wf_definition_config'
  615. id = Column(BigInteger, primary_key=True, comment='主键')
  616. table_name = Column(String(255), nullable=False, comment='表名')
  617. definition_id = Column(String(255), nullable=False, comment='流程定义ID')
  618. process_key = Column(String(255), nullable=False, comment='流程KEY')
  619. version = Column(Integer, nullable=False, comment='流程版本')
  620. create_dept = Column(BigInteger, default=None, comment='创建部门')
  621. create_by = Column(BigInteger, default=None, comment='创建者')
  622. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  623. update_by = Column(BigInteger, default=None, comment='更新者')
  624. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  625. remark = Column(String(500), default='', comment='备注')
  626. tenant_id = Column(String(20), comment='租户编号')
  627. # 定义唯一性约束条件
  628. __table_args__ = (UniqueConstraint('definition_id', name='uni_definition_id'),)
  629. class Config:
  630. orm_mode = True
  631. '''表单管理'''
  632. class WfFormManage(Base):
  633. __tablename__ = 'wf_form_manage'
  634. id = Column(BigInteger, primary_key=True, comment='主键')
  635. form_name = Column(String(255), nullable=False, comment='表单名称')
  636. form_type = Column(String(255), nullable=False, comment='表单类型')
  637. router = Column(String(255), nullable=False, comment='路由地址/表单ID')
  638. remark = Column(String(500), comment='备注')
  639. tenant_id = Column(String(20), comment='租户编号')
  640. create_dept = Column(BigInteger, default=None, comment='创建部门')
  641. create_by = Column(BigInteger, default=None, comment='创建者')
  642. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  643. update_by = Column(BigInteger, default=None, comment='更新者')
  644. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  645. class Config:
  646. orm_mode = True
  647. '''节点配置'''
  648. class WfNodeConfig(Base):
  649. __tablename__ = 'wf_node_config'
  650. id = Column(BigInteger, primary_key=True, comment='主键')
  651. form_id = Column(BigInteger, comment='表单id')
  652. form_type = Column(String(255), comment='表单类型')
  653. node_name = Column(String(255), nullable=False, comment='节点名称')
  654. node_id = Column(String(255), nullable=False, comment='节点id')
  655. definition_id = Column(String(255), nullable=False, comment='流程定义id')
  656. apply_user_task = Column(CHAR(1), default='0', comment='是否为申请人节点(0是 1否)')
  657. create_dept = Column(BigInteger, default=None, comment='创建部门')
  658. create_by = Column(BigInteger, default=None, comment='创建者')
  659. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  660. update_by = Column(BigInteger, default=None, comment='更新者')
  661. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  662. tenant_id = Column(String(20), comment='租户编号')
  663. class Config:
  664. orm_mode = True
  665. '''snail_job'''
  666. '''命名空间'''
  667. class SjNamespace(Base):
  668. __tablename__ = 'sj_namespace'
  669. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  670. name = Column(String(64), nullable=False, comment='名称')
  671. unique_id = Column(String(64), nullable=False, comment='唯一id')
  672. description = Column(String(256), nullable=False, default='', comment='描述')
  673. deleted = Column(TINYINT(4), nullable=False, default=0, comment='逻辑删除 1、删除')
  674. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  675. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  676. # 定义索引
  677. __table_args__ = (
  678. Index('idx_name', 'name'),
  679. UniqueConstraint('unique_id', name='uk_unique_id'),
  680. )
  681. class Config:
  682. orm_mode = True
  683. '''组配置'''
  684. class SjGroupConfig(Base):
  685. __tablename__ = 'sj_group_config'
  686. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  687. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  688. group_name = Column(String(64), nullable=False, default='', comment='组名称')
  689. description = Column(String(256), nullable=False, default='', comment='组描述')
  690. token = Column(String(64), nullable=False, default='SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT', comment='token')
  691. group_status = Column(TINYINT(4), nullable=False, default=0, comment='组状态 0、未启用 1、启用')
  692. version = Column(Integer, nullable=False, comment='版本号')
  693. group_partition = Column(Integer, nullable=False, comment='分区')
  694. id_generator_mode = Column(TINYINT(4), nullable=False, default=1, comment='唯一id生成模式 默认号段模式')
  695. init_scene = Column(TINYINT(4), nullable=False, default=0, comment='是否初始化场景 0:否 1:是')
  696. bucket_index = Column(Integer, nullable=False, default=0, comment='bucket')
  697. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  698. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  699. # 定义唯一性约束条件
  700. __table_args__ = (UniqueConstraint('namespace_id', 'group_name', name='uk_namespace_id_group_name'),)
  701. class Config:
  702. orm_mode = True
  703. '''通知配置'''
  704. class SjNotifyConfig(Base):
  705. __tablename__ = 'sj_notify_config'
  706. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  707. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  708. group_name = Column(String(64), nullable=False, comment='组名称')
  709. business_id = Column(String(64), nullable=False, comment='业务id (job_id或workflow_id或scene_name)')
  710. system_task_type = Column(TINYINT(4), nullable=False, default=3, comment='任务类型')
  711. notify_status = Column(TINYINT(4), nullable=False, default=0, comment='通知状态')
  712. recipient_ids = Column(String(128), nullable=False, comment='接收人id列表')
  713. notify_threshold = Column(Integer, nullable=False, default=0, comment='通知阈值')
  714. notify_scene = Column(TINYINT(4), nullable=False, default=0, comment='通知场景')
  715. rate_limiter_status = Column(TINYINT(4), nullable=False, default=0, comment='限流状态')
  716. rate_limiter_threshold = Column(Integer, nullable=False, default=0, comment='每秒限流阈值')
  717. description = Column(String(256), nullable=False, default='', comment='描述')
  718. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  719. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  720. # 定义索引
  721. __table_args__ = (
  722. Index('idx_namespace_id_group_name_scene_name', 'namespace_id', 'group_name', 'business_id'),)
  723. class Config:
  724. orm_mode = True
  725. '''告警通知接收人'''
  726. class SjNotifyRecipient(Base):
  727. __tablename__ = 'sj_notify_recipient'
  728. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  729. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  730. recipient_name = Column(String(64), nullable=False, comment='接收人名称')
  731. notify_type = Column(TINYINT(4), nullable=False, default=0, comment='通知类型')
  732. notify_attribute = Column(String(512), nullable=False, comment='配置属性')
  733. description = Column(String(256), nullable=False, default='', comment='描述')
  734. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  735. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  736. # 定义索引
  737. __table_args__ = (
  738. Index('idx_namespace_id', 'namespace_id'),
  739. )
  740. class Config:
  741. orm_mode = True
  742. '''死信队列表'''
  743. class SjRetryDeadLetter(Base):
  744. __tablename__ = 'sj_retry_dead_letter_0'
  745. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  746. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  747. unique_id = Column(String(64), nullable=False, comment='同组下id唯一')
  748. group_name = Column(String(64), nullable=False, comment='组名称')
  749. scene_name = Column(String(64), nullable=False, comment='场景名称')
  750. idempotent_id = Column(String(64), nullable=False, comment='幂等id')
  751. biz_no = Column(String(64), nullable=False, default='', comment='业务编号')
  752. executor_name = Column(String(512), nullable=False, default='', comment='执行器名称')
  753. args_str = Column(Text, nullable=False, comment='执行方法参数')
  754. ext_attrs = Column(Text, nullable=False, comment='扩展字段')
  755. task_type = Column(TINYINT(4), nullable=False, default=1, comment='任务类型')
  756. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  757. # 定义索引和唯一性约束条件
  758. __table_args__ = (
  759. Index('idx_namespace_id_group_name_scene_name', 'namespace_id', 'group_name', 'scene_name'),
  760. Index('idx_idempotent_id', 'idempotent_id'),
  761. Index('idx_biz_no', 'biz_no'),
  762. Index('idx_create_dt', 'create_dt'),
  763. UniqueConstraint('namespace_id', 'group_name', 'unique_id', name='uk_namespace_id_group_name_unique_id'),
  764. )
  765. class Config:
  766. orm_mode = True
  767. '''任务表'''
  768. class SjRetryTask(Base):
  769. __tablename__ = 'sj_retry_task_0'
  770. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  771. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  772. unique_id = Column(String(64), nullable=False, comment='同组下id唯一')
  773. group_name = Column(String(64), nullable=False, comment='组名称')
  774. scene_name = Column(String(64), nullable=False, comment='场景名称')
  775. idempotent_id = Column(String(64), nullable=False, comment='幂等id')
  776. biz_no = Column(String(64), nullable=False, default='', comment='业务编号')
  777. executor_name = Column(String(512), nullable=False, default='', comment='执行器名称')
  778. args_str = Column(Text, nullable=False, comment='执行方法参数')
  779. ext_attrs = Column(Text, nullable=False, comment='扩展字段')
  780. next_trigger_at = Column(DateTime, nullable=False, comment='下次触发时间')
  781. retry_count = Column(Integer, nullable=False, default=0, comment='重试次数')
  782. retry_status = Column(TINYINT(4), nullable=False, default=0, comment='重试状态')
  783. task_type = Column(TINYINT(4), nullable=False, default=1, comment='任务类型')
  784. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  785. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  786. # 定义索引和唯一性约束条件
  787. __table_args__ = (
  788. Index('idx_namespace_id_group_name_scene_name', 'namespace_id', 'group_name', 'scene_name'),
  789. Index('idx_namespace_id_group_name_task_type', 'namespace_id', 'group_name', 'task_type'),
  790. Index('idx_namespace_id_group_name_retry_status', 'namespace_id', 'group_name', 'retry_status'),
  791. Index('idx_idempotent_id', 'idempotent_id'),
  792. Index('idx_biz_no', 'biz_no'),
  793. Index('idx_create_dt', 'create_dt'),
  794. UniqueConstraint('namespace_id', 'group_name', 'unique_id', name='uk_name_unique_id'),
  795. )
  796. class Config:
  797. orm_mode = True
  798. '''任务日志基础信息表'''
  799. class SjRetryTaskLog(Base):
  800. __tablename__ = 'sj_retry_task_log'
  801. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  802. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  803. unique_id = Column(String(64), nullable=False, comment='同组下id唯一')
  804. group_name = Column(String(64), nullable=False, comment='组名称')
  805. scene_name = Column(String(64), nullable=False, comment='场景名称')
  806. idempotent_id = Column(String(64), nullable=False, comment='幂等id')
  807. biz_no = Column(String(64), nullable=False, default='', comment='业务编号')
  808. executor_name = Column(String(512), nullable=False, default='', comment='执行器名称')
  809. args_str = Column(Text, nullable=False, comment='执行方法参数')
  810. ext_attrs = Column(Text, nullable=False, comment='扩展字段')
  811. retry_status = Column(TINYINT(4), nullable=False, default=0, comment='重试状态')
  812. task_type = Column(TINYINT(4), nullable=False, default=1, comment='任务类型')
  813. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  814. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  815. # 定义索引
  816. __table_args__ = (
  817. Index('idx_group_name_scene_name', 'namespace_id', 'group_name', 'scene_name'),
  818. Index('idx_retry_status', 'retry_status'),
  819. Index('idx_idempotent_id', 'idempotent_id'),
  820. Index('idx_unique_id', 'unique_id'),
  821. Index('idx_biz_no', 'biz_no'),
  822. Index('idx_create_dt', 'create_dt'),
  823. )
  824. class Config:
  825. orm_mode = True
  826. '''任务调度日志信息记录表'''
  827. class SjRetryTaskLogMessage(Base):
  828. __tablename__ = 'sj_retry_task_log_message'
  829. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  830. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  831. group_name = Column(String(64), nullable=False, comment='组名称')
  832. unique_id = Column(String(64), nullable=False, comment='同组下id唯一')
  833. message = Column(Text, nullable=False, comment='异常信息')
  834. log_num = Column(Integer, nullable=False, default=1, comment='日志数量')
  835. real_time = Column(BigInteger, nullable=False, default=0, comment='上报时间')
  836. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  837. # 定义索引
  838. __table_args__ = (
  839. Index('idx_namespace_id_group_name_unique_id', 'namespace_id', 'group_name', 'unique_id'),
  840. Index('idx_create_dt', 'create_dt'),
  841. )
  842. class Config:
  843. orm_mode = True
  844. '''场景配置'''
  845. class SjRetrySceneConfig(Base):
  846. __tablename__ = 'sj_retry_scene_config'
  847. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  848. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  849. scene_name = Column(String(64), nullable=False, comment='场景名称')
  850. group_name = Column(String(64), nullable=False, comment='组名称')
  851. scene_status = Column(TINYINT(4), nullable=False, default=0, comment='组状态')
  852. max_retry_count = Column(Integer, nullable=False, default=5, comment='最大重试次数')
  853. back_off = Column(TINYINT(4), nullable=False, default=1, comment='重试间隔类型')
  854. trigger_interval = Column(String(16), nullable=False, default='', comment='间隔时长')
  855. deadline_request = Column(BigInteger, nullable=False, default=60000, comment='Deadline Request 调用链超时 单位毫秒')
  856. executor_timeout = Column(Integer, nullable=False, default=5, comment='任务执行超时时间,单位秒')
  857. route_key = Column(TINYINT(4), nullable=False, default=4, comment='路由策略')
  858. description = Column(String(256), nullable=False, default='', comment='描述')
  859. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  860. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  861. # 定义唯一性约束条件
  862. __table_args__ = (
  863. UniqueConstraint('namespace_id', 'group_name', 'scene_name', name='uk_namespace_id_group_name_scene_name'),
  864. )
  865. class Config:
  866. orm_mode = True
  867. '''服务器节点'''
  868. class SjServerNode(Base):
  869. __tablename__ = 'sj_server_node'
  870. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  871. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  872. group_name = Column(String(64), nullable=False, comment='组名称')
  873. host_id = Column(String(64), nullable=False, comment='主机id')
  874. host_ip = Column(String(64), nullable=False, comment='机器ip')
  875. host_port = Column(Integer, nullable=False, comment='机器端口')
  876. expire_at = Column(DateTime, nullable=False, comment='过期时间')
  877. node_type = Column(TINYINT(4), nullable=False, comment='节点类型')
  878. ext_attrs = Column(String(256), nullable=True, default='', comment='扩展字段')
  879. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  880. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  881. # 定义索引和唯一性约束条件
  882. __table_args__ = (
  883. Index('idx_namespace_id_group_name', 'namespace_id', 'group_name'),
  884. Index('idx_expire_at_node_type', 'expire_at', 'node_type'),
  885. UniqueConstraint('host_id', 'host_ip', name='uk_host_id_host_ip'),
  886. )
  887. class Config:
  888. orm_mode = True
  889. '''锁定表'''
  890. class SjDistributedLock(Base):
  891. __tablename__ = 'sj_distributed_lock'
  892. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  893. name = Column(String(64), nullable=False, comment='锁名称')
  894. lock_until = Column(TIMESTAMP(3), nullable=False, default=datetime.now, onupdate=datetime.now, comment='锁定时长')
  895. locked_at = Column(TIMESTAMP(3), nullable=False, default=datetime.now, comment='锁定时间')
  896. locked_by = Column(String(255), nullable=False, comment='锁定者')
  897. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  898. update_dt = Column(DateTime, nullable=False, default=datetime.now, comment='修改时间')
  899. # 定义唯一性约束条件
  900. __table_args__ = (
  901. UniqueConstraint('name', name='uk_name'),
  902. )
  903. class Config:
  904. orm_mode = True
  905. '''系统用户表'''
  906. class SjSystemUser(Base):
  907. __tablename__ = 'sj_system_user'
  908. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  909. username = Column(String(64), nullable=False, unique=True, comment='账号') # 唯一约束在 SQLAlchemy 中用 unique=True 表示
  910. password = Column(String(128), nullable=False, comment='密码')
  911. role = Column(TINYINT(4), nullable=False, default=0, comment='角色')
  912. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  913. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  914. class Config:
  915. orm_mode = True
  916. '''系统用户权限表'''
  917. class SjSystemUserPermission(Base):
  918. __tablename__ = 'sj_system_user_permission'
  919. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  920. group_name = Column(String(64), nullable=False, comment='组名称')
  921. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  922. system_user_id = Column(BigInteger, nullable=False, comment='系统用户id')
  923. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  924. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  925. # 定义唯一性约束条件
  926. __table_args__ = (
  927. UniqueConstraint('namespace_id', 'group_name', 'system_user_id', name='uk_namespace_id_group_name_system_user_id'),
  928. )
  929. class Config:
  930. orm_mode = True
  931. '''号段模式序号ID分配表'''
  932. class SjSequenceAlloc(Base):
  933. __tablename__ = 'sj_sequence_alloc'
  934. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  935. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  936. group_name = Column(String(64), nullable=False, default='', comment='组名称')
  937. max_id = Column(BigInteger, nullable=False, default=1, comment='最大id')
  938. step = Column(Integer, nullable=False, default=100, comment='步长')
  939. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='更新时间')
  940. # 定义唯一性约束条件
  941. __table_args__ = (
  942. UniqueConstraint('namespace_id', 'group_name', name='uk_namespace_id_group_name'),
  943. )
  944. class Config:
  945. orm_mode = True
  946. '''任务信息'''
  947. class SjJob(Base):
  948. __tablename__ = 'sj_job'
  949. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  950. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  951. group_name = Column(String(64), nullable=False, comment='组名称')
  952. job_name = Column(String(64), nullable=False, comment='名称')
  953. args_str = Column(Text, default=None, comment='执行方法参数')
  954. args_type = Column(TINYINT(4), nullable=False, default=1, comment='参数类型')
  955. next_trigger_at = Column(BigInteger, nullable=False, comment='下次触发时间')
  956. job_status = Column(TINYINT(4), nullable=False, default=1, comment='任务状态')
  957. task_type = Column(TINYINT(4), nullable=False, default=1, comment='任务类型')
  958. route_key = Column(TINYINT(4), nullable=False, default=4, comment='路由策略')
  959. executor_type = Column(TINYINT(4), nullable=False, default=1, comment='执行器类型')
  960. executor_info = Column(String(255), default=None, comment='执行器名称')
  961. trigger_type = Column(TINYINT(4), nullable=False, comment='触发类型')
  962. trigger_interval = Column(String(255), nullable=False, comment='间隔时长')
  963. block_strategy = Column(TINYINT(4), nullable=False, default=1, comment='阻塞策略')
  964. executor_timeout = Column(Integer, nullable=False, default=0, comment='任务执行超时时间')
  965. max_retry_times = Column(Integer, nullable=False, default=0, comment='最大重试次数')
  966. parallel_num = Column(Integer, nullable=False, default=1, comment='并行数')
  967. retry_interval = Column(Integer, nullable=False, default=0, comment='重试间隔(s)')
  968. bucket_index = Column(Integer, nullable=False, default=0, comment='bucket')
  969. resident = Column(TINYINT(4), nullable=False, default=0, comment='是否是常驻任务')
  970. description = Column(String(256), nullable=False, default='', comment='描述')
  971. ext_attrs = Column(String(256), nullable=True, default='', comment='扩展字段')
  972. deleted = Column(TINYINT(4), nullable=False, default=0, comment='逻辑删除')
  973. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  974. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  975. # 定义索引
  976. __table_args__ = (
  977. Index('idx_namespace_id_group_name', 'namespace_id', 'group_name'),
  978. Index('idx_job_status_bucket_index', 'job_status', 'bucket_index'),
  979. Index('idx_create_dt', 'create_dt'),
  980. )
  981. class Config:
  982. orm_mode = True
  983. '''调度日志'''
  984. class SjJobLogMessage(Base):
  985. __tablename__ = 'sj_job_log_message'
  986. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  987. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  988. group_name = Column(String(64), nullable=False, comment='组名称')
  989. job_id = Column(BigInteger, nullable=False, comment='任务信息id')
  990. task_batch_id = Column(BigInteger, nullable=False, comment='任务批次id')
  991. task_id = Column(BigInteger, nullable=False, comment='调度任务id')
  992. message = Column(Text, nullable=False, comment='调度信息')
  993. log_num = Column(Integer, nullable=False, default=1, comment='日志数量')
  994. real_time = Column(BigInteger, nullable=False, default=0, comment='上报时间')
  995. ext_attrs = Column(String(256), nullable=True, default='', comment='扩展字段')
  996. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  997. # 定义索引
  998. __table_args__ = (
  999. Index('idx_task_batch_id_task_id', 'task_batch_id', 'task_id'),
  1000. Index('idx_create_dt', 'create_dt'),
  1001. Index('idx_namespace_id_group_name', 'namespace_id', 'group_name'),
  1002. )
  1003. class Config:
  1004. orm_mode = True
  1005. '''任务实例'''
  1006. class SjJobTask(Base):
  1007. __tablename__ = 'sj_job_task'
  1008. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  1009. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  1010. group_name = Column(String(64), nullable=False, comment='组名称')
  1011. job_id = Column(BigInteger, nullable=False, comment='任务信息id')
  1012. task_batch_id = Column(BigInteger, nullable=False, comment='调度任务id')
  1013. parent_id = Column(BigInteger, nullable=False, default=0, comment='父执行器id')
  1014. task_status = Column(TINYINT(4), nullable=False, default=0, comment='执行的状态')
  1015. retry_count = Column(Integer, nullable=False, default=0, comment='重试次数')
  1016. client_info = Column(String(128), default=None, comment='客户端地址')
  1017. result_message = Column(Text, nullable=False, comment='执行结果')
  1018. args_str = Column(Text, default=None, comment='执行方法参数')
  1019. args_type = Column(TINYINT(4), nullable=False, default=1, comment='参数类型')
  1020. ext_attrs = Column(String(256), nullable=True, default='', comment='扩展字段')
  1021. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  1022. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  1023. # 定义索引
  1024. __table_args__ = (
  1025. Index('idx_task_batch_id_task_status', 'task_batch_id', 'task_status'),
  1026. Index('idx_create_dt', 'create_dt'),
  1027. Index('idx_namespace_id_group_name', 'namespace_id', 'group_name'),
  1028. )
  1029. class Config:
  1030. orm_mode = True
  1031. '''任务批次'''
  1032. class SjJobTaskBatch(Base):
  1033. __tablename__ = 'sj_job_task_batch'
  1034. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  1035. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  1036. group_name = Column(String(64), nullable=False, comment='组名称')
  1037. job_id = Column(BigInteger, nullable=False, comment='任务id')
  1038. workflow_node_id = Column(BigInteger, nullable=False, default=0, comment='工作流节点id')
  1039. parent_workflow_node_id = Column(BigInteger, nullable=False, default=0, comment='工作流任务父批次id')
  1040. workflow_task_batch_id = Column(BigInteger, nullable=False, default=0, comment='工作流任务批次id')
  1041. task_batch_status = Column(TINYINT(4), nullable=False, default=0, comment='任务批次状态')
  1042. operation_reason = Column(TINYINT(4), nullable=False, default=0, comment='操作原因')
  1043. execution_at = Column(BigInteger, nullable=False, default=0, comment='任务执行时间')
  1044. system_task_type = Column(TINYINT(4), nullable=False, default=3, comment='任务类型')
  1045. parent_id = Column(String(64), nullable=False, default='', comment='父节点')
  1046. ext_attrs = Column(String(256), nullable=True, default='', comment='扩展字段')
  1047. deleted = Column(TINYINT(4), nullable=False, default=0, comment='逻辑删除')
  1048. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  1049. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  1050. # 定义索引
  1051. __table_args__ = (
  1052. Index('idx_job_id_task_batch_status', 'job_id', 'task_batch_status'),
  1053. Index('idx_create_dt', 'create_dt'),
  1054. Index('idx_namespace_id_group_name', 'namespace_id', 'group_name'),
  1055. Index('idx_workflow_task_batch_id_workflow_node_id', 'workflow_task_batch_id', 'workflow_node_id'),
  1056. )
  1057. class Config:
  1058. orm_mode = True
  1059. '''DashBoard_Job'''
  1060. class SjJobSummary(Base):
  1061. __tablename__ = 'sj_job_summary'
  1062. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  1063. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  1064. group_name = Column(String(64), nullable=False, default='', comment='组名称')
  1065. business_id = Column(BigInteger, nullable=False, comment='业务id')
  1066. system_task_type = Column(TINYINT(4), nullable=False, default=3, comment='任务类型')
  1067. trigger_at = Column(DateTime, nullable=False, default=datetime.now, comment='统计时间')
  1068. success_num = Column(Integer, nullable=False, default=0, comment='执行成功-日志数量')
  1069. fail_num = Column(Integer, nullable=False, default=0, comment='执行失败-日志数量')
  1070. fail_reason = Column(String(512), nullable=False, default='', comment='失败原因')
  1071. stop_num = Column(Integer, nullable=False, default=0, comment='执行停止-日志数量')
  1072. stop_reason = Column(String(512), nullable=False, default='', comment='停止原因')
  1073. cancel_num = Column(Integer, nullable=False, default=0, comment='执行取消-日志数量')
  1074. cancel_reason = Column(String(512), nullable=False, default='', comment='取消原因')
  1075. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  1076. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  1077. # 定义索引和唯一性约束条件
  1078. __table_args__ = (
  1079. Index('idx_namespace_id_group_name_business_id', 'namespace_id', 'group_name', 'business_id'),
  1080. UniqueConstraint('trigger_at', 'system_task_type', 'business_id', name='uk_trigger_at_system_task_type_business_id'),
  1081. )
  1082. class Config:
  1083. orm_mode = True
  1084. '''DashBoard_Retry'''
  1085. class SjRetrySummary(Base):
  1086. __tablename__ = 'sj_retry_summary'
  1087. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  1088. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  1089. group_name = Column(String(64), nullable=False, default='', comment='组名称')
  1090. scene_name = Column(String(50), nullable=False, default='', comment='场景名称')
  1091. trigger_at = Column(DateTime, nullable=False, default=datetime.now, comment='统计时间')
  1092. running_num = Column(Integer, nullable=False, default=0, comment='重试中-日志数量')
  1093. finish_num = Column(Integer, nullable=False, default=0, comment='重试完成-日志数量')
  1094. max_count_num = Column(Integer, nullable=False, default=0, comment='重试到达最大次数-日志数量')
  1095. suspend_num = Column(Integer, nullable=False, default=0, comment='暂停重试-日志数量')
  1096. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  1097. update_dt = Column(DateTime, nullable=False, onupdate=datetime.now, comment='修改时间')
  1098. # 定义索引和唯一性约束条件
  1099. __table_args__ = (
  1100. Index('idx_trigger_at', 'trigger_at'),
  1101. UniqueConstraint('namespace_id', 'group_name', 'scene_name', 'trigger_at', name='uk_scene_name_trigger_at'),
  1102. )
  1103. class Config:
  1104. orm_mode = True
  1105. '''工作流'''
  1106. class SjWorkflow(Base):
  1107. __tablename__ = 'sj_workflow'
  1108. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  1109. workflow_name = Column(String(64), nullable=False, comment='工作流名称')
  1110. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  1111. group_name = Column(String(64), nullable=False, comment='组名称')
  1112. workflow_status = Column(TINYINT(4), nullable=False, default=1, comment='工作流状态')
  1113. trigger_type = Column(TINYINT(4), nullable=False, comment='触发类型')
  1114. trigger_interval = Column(String(255), nullable=False, comment='间隔时长')
  1115. next_trigger_at = Column(BigInteger, nullable=False, comment='下次触发时间')
  1116. block_strategy = Column(TINYINT(4), nullable=False, default=1, comment='阻塞策略')
  1117. executor_timeout = Column(Integer, nullable=False, default=0, comment='任务执行超时时间')
  1118. description = Column(String(256), nullable=False, default='', comment='描述')
  1119. flow_info = Column(Text, default=None, comment='流程信息')
  1120. bucket_index = Column(Integer, nullable=False, default=0, comment='bucket')
  1121. version = Column(Integer, nullable=False, comment='版本号')
  1122. ext_attrs = Column(String(256), nullable=True, default='', comment='扩展字段')
  1123. deleted = Column(TINYINT(4), nullable=False, default=0, comment='逻辑删除')
  1124. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  1125. update_dt = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment='修改时间')
  1126. # 定义索引
  1127. __table_args__ = (
  1128. Index('idx_create_dt', 'create_dt'),
  1129. Index('idx_namespace_id_group_name', 'namespace_id', 'group_name'),
  1130. )
  1131. class Config:
  1132. orm_mode = True
  1133. '''工作流节点'''
  1134. class SjWorkflowNode(Base):
  1135. __tablename__ = 'sj_workflow_node'
  1136. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  1137. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  1138. node_name = Column(String(64), nullable=False, comment='节点名称')
  1139. group_name = Column(String(64), nullable=False, comment='组名称')
  1140. job_id = Column(BigInteger, nullable=False, comment='任务信息id')
  1141. workflow_id = Column(BigInteger, nullable=False, comment='工作流ID')
  1142. node_type = Column(TINYINT(4), nullable=False, default=1, comment='节点类型')
  1143. expression_type = Column(TINYINT(4), nullable=False, default=0, comment='表达式类型')
  1144. fail_strategy = Column(TINYINT(4), nullable=False, default=1, comment='失败策略')
  1145. workflow_node_status = Column(TINYINT(4), nullable=False, default=1, comment='工作流节点状态')
  1146. priority_level = Column(Integer, nullable=False, default=1, comment='优先级')
  1147. node_info = Column(Text, default=None, comment='节点信息')
  1148. version = Column(Integer, nullable=False, comment='版本号')
  1149. ext_attrs = Column(String(256), nullable=True, default='', comment='扩展字段')
  1150. deleted = Column(TINYINT(4), nullable=False, default=0, comment='逻辑删除')
  1151. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  1152. update_dt = Column(DateTime, nullable=False, onupdate=datetime.now, comment='修改时间')
  1153. # 定义索引
  1154. __table_args__ = (
  1155. Index('idx_create_dt', 'create_dt'),
  1156. Index('idx_namespace_id_group_name', 'namespace_id', 'group_name'),
  1157. )
  1158. class Config:
  1159. orm_mode = True
  1160. '''工作流批次'''
  1161. class SjWorkflowTaskBatch(Base):
  1162. __tablename__ = 'sj_workflow_task_batch'
  1163. id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键')
  1164. namespace_id = Column(String(64), nullable=False, default='764d604ec6fc45f68cd92514c40e9e1a', comment='命名空间id')
  1165. group_name = Column(String(64), nullable=False, comment='组名称')
  1166. workflow_id = Column(BigInteger, nullable=False, comment='工作流任务id')
  1167. task_batch_status = Column(TINYINT(4), nullable=False, default=0, comment='任务批次状态')
  1168. operation_reason = Column(TINYINT(4), nullable=False, default=0, comment='操作原因')
  1169. flow_info = Column(Text, default=None, comment='流程信息')
  1170. execution_at = Column(BigInteger, nullable=False, default=0, comment='任务执行时间')
  1171. ext_attrs = Column(String(256), nullable=True, default='', comment='扩展字段')
  1172. deleted = Column(TINYINT(4), nullable=False, default=0, comment='逻辑删除')
  1173. create_dt = Column(DateTime, nullable=False, default=datetime.now, comment='创建时间')
  1174. update_dt = Column(DateTime, nullable=False, onupdate=datetime.now, comment='修改时间')
  1175. # 定义索引
  1176. __table_args__ = (
  1177. Index('idx_workflow_id_task_batch_status', 'workflow_id', 'task_batch_status'),
  1178. Index('idx_create_dt', 'create_dt'),
  1179. Index('idx_namespace_id_group_name', 'namespace_id', 'group_name'),
  1180. )
  1181. class Config:
  1182. orm_mode = True