ry_sys_base.py 73 KB

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