ry_sys_base.py 74 KB

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