mirror of
https://github.com/veops/cmdb.git
synced 2025-08-08 23:09:52 +08:00
前后端全面升级
This commit is contained in:
24
cmdb-api/api/lib/common_setting/company_info.py
Normal file
24
cmdb-api/api/lib/common_setting/company_info.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
from api.models.common_setting import CompanyInfo
|
||||
|
||||
|
||||
class CompanyInfoCRUD(object):
|
||||
|
||||
@staticmethod
|
||||
def get():
|
||||
return CompanyInfo.get_by(first=True) or {}
|
||||
|
||||
@staticmethod
|
||||
def create(**kwargs):
|
||||
return CompanyInfo.create(**kwargs)
|
||||
|
||||
@staticmethod
|
||||
def update(_id, **kwargs):
|
||||
kwargs.pop('id', None)
|
||||
existed = CompanyInfo.get_by_id(_id)
|
||||
if not existed:
|
||||
return CompanyInfoCRUD.create(**kwargs)
|
||||
else:
|
||||
existed = existed.update(**kwargs)
|
||||
return existed
|
Reference in New Issue
Block a user