88 lines
3.3 KiB
Python
88 lines
3.3 KiB
Python
import base64
|
|
import json
|
|
|
|
from odoo import http, fields
|
|
from odoo.http import request
|
|
from urllib.parse import quote
|
|
|
|
|
|
class YuthonNotice(http.Controller):
|
|
|
|
@http.route('/yuthon/yuthon/notice', methods=['POST'], type='http', auth='none', csrf=False)
|
|
def index(self, **kwargs):
|
|
id = kwargs.get('id')
|
|
|
|
data = request.env['yuthon.notice'].sudo().search([("id", "=", int(id))])
|
|
documents = []
|
|
for document in data.documents_ids:
|
|
documents.append({
|
|
'id': document.id,
|
|
'name': document.name,
|
|
'url': document.url,
|
|
'type': document.type,
|
|
'file_size': document.file_size,
|
|
'file_size_display':document.file_size_display,
|
|
'mimetype': document.mimetype,
|
|
'datas': document.datas.decode('utf-8') if document.datas else None,
|
|
})
|
|
|
|
result = {
|
|
'id': data.id,
|
|
'title': data.name,
|
|
'code': data.code,
|
|
'create_date1': fields.Date.to_string(data.create_date1),
|
|
'notice_text': data.notice_text,
|
|
'documents':documents,
|
|
'user_name':data.users_id.name,
|
|
'read_number': data.read_number,
|
|
}
|
|
return json.dumps({
|
|
'data':result,
|
|
'code':200,
|
|
'message':'success'
|
|
})
|
|
|
|
@http.route('/yuthon/notice/list', methods=['POST'], type='http', auth='none', csrf=False)
|
|
def yuthon_notice_list(self, **kwargs):
|
|
notice_ids = request.env['yuthon.notice'].sudo().search([])
|
|
data_list = []
|
|
for notice in notice_ids:
|
|
result = {
|
|
'id': notice.id,
|
|
'create_date1': fields.Date.to_string(notice.create_date1) if notice.create_date1 else None,
|
|
'users_id': notice.users_id.name,
|
|
'name': notice.name,
|
|
}
|
|
data_list.append(result)
|
|
return json.dumps({'data': data_list, 'code': 200, 'message': 'success'})
|
|
|
|
@http.route('/yuthon/notice/detail', methods=['POST'], type='http', auth='none', csrf=False)
|
|
def yuthon_notice_detail(self, **kwargs):
|
|
notice = request.env['yuthon.notice'].sudo().search([('id', '=', kwargs.get('id'))])
|
|
result = {
|
|
'id': notice.id,
|
|
'create_date': "2026-1-16",
|
|
'users_id': notice.users_id.name,
|
|
'name': notice.name,
|
|
# 'notice_type_id': notice.notice_type_id.name,
|
|
'notice_text': "这实打实的环境哦阿什顿啊送到哈斯哦很多网友和打火机阿德阿斯顿"
|
|
"哈数据库的哈我要和uowidbjlaasdhkasdioywiod哦爱上对哦啊苏大ios的奥斯丁要稍等哈稍等奥迪要说的话",
|
|
|
|
}
|
|
|
|
return json.dumps({
|
|
'code': 200,
|
|
'message': 'success',
|
|
'data': result
|
|
})
|
|
|
|
@http.route('/yuthon/notice/confirm', methods=['POST'], type='http', auth='none', csrf=False)
|
|
def yuthon_notice_confirm(self, **kwargs):
|
|
notice_id = kwargs.get('id')
|
|
employee_id = kwargs.get('employee_id')
|
|
confirm_id = request.env['yuthon.confirm.users'].sudo().search([('notice_id', '=', notice_id),('employee_id', '=', employee_id)])
|
|
confirm_id.write({'state': 'yes'})
|
|
return json.dumps({'code': 200, 'message': 'OK'})
|
|
|
|
|