ry_sys_base.py 75 KB

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