ry_sys_base.py 72 KB

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