mirror of
https://github.com/veops/cmdb.git
synced 2025-08-07 00:02:46 +08:00
feat: add cmdb custom icon manage
This commit is contained in:
35
cmdb-api/api/views/common_setting/common_data.py
Normal file
35
cmdb-api/api/views/common_setting/common_data.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from flask import request
|
||||
|
||||
from api.lib.common_setting.common_data import CommonDataCRUD
|
||||
from api.resource import APIView
|
||||
|
||||
prefix = '/data'
|
||||
|
||||
|
||||
class DataView(APIView):
|
||||
url_prefix = (f'{prefix}/<string:data_type>',)
|
||||
|
||||
def get(self, data_type):
|
||||
data_list = CommonDataCRUD.get_data_by_type(data_type)
|
||||
|
||||
return self.jsonify(data_list)
|
||||
|
||||
def post(self, data_type):
|
||||
params = request.json
|
||||
CommonDataCRUD.create_new_data(data_type, **params)
|
||||
|
||||
return self.jsonify(params)
|
||||
|
||||
|
||||
class DataViewWithId(APIView):
|
||||
url_prefix = (f'{prefix}/<string:data_type>/<int:_id>',)
|
||||
|
||||
def put(self, data_type, _id):
|
||||
params = request.json
|
||||
res = CommonDataCRUD.update_data(_id, **params)
|
||||
|
||||
return self.jsonify(res.to_dict())
|
||||
|
||||
def delete(self, data_type, _id):
|
||||
CommonDataCRUD.delete(_id)
|
||||
return self.jsonify({})
|
Reference in New Issue
Block a user