ry_sys_base.py 76 KB

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