ry_sys_base.py 71 KB

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