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