role_data.py 1.2 KB

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. from .__load__ import *
  3. class Role_data(Model):
  4. __table__ = 'role_data'
  5. __comment__ = '角色知识库'
  6. id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
  7. role_id = Fields(type='int', comment='角色id')
  8. data_id = Fields(type='int', comment='数据文件id')
  9. state = Fields(type='boolean', default='True', comment='数据存在状态')
  10. cdate = Fields(type='int', default='time', comment='创建时间')
  11. def getCur(self, id):
  12. self.id = id
  13. data = self.select(type='fetchone')
  14. return data
  15. def getList(self, page = 1, param = {}):
  16. cate = Demeter.model('video_cate').getCur()
  17. self.cate_id = cate['id']
  18. Demeter.config['page'] = {}
  19. Demeter.config['page']['current'] = page
  20. data = self.select(page=True)
  21. result = []
  22. if data:
  23. for key, value in enumerate(data):
  24. #cate = Demeter.service('common').one('video_cate', id=value['cate_id'])
  25. value['cdate'] = Demeter.date(value['cdate'])
  26. result.append([str(value['id']), value['name'], value['cdate'], ''])
  27. return result