ry_sys_base.py 71 KB

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