ry_sys_base.py 69 KB

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