ry_sys_base.py 73 KB

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