ry_sys_base.py 75 KB

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