123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package controllers
- import (
- "rtzh_elec_temperature/rtelec_app_public_lib/service"
- "rtzh_elec_temperature/rtelec_app_public_lib/utils"
- "rtzh_elec_temperature/tools"
- )
- //物模型相关服务
- type ModelController struct {
- BaseController
- }
- //模型查询
- // @Summary 获取本应用的模型列表
- // @Description 获取本应用的模型列表。应用使用的模型需要通过业务场景进行配置,否则会返回中台的所有模型。
- // @Tags api
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Success 200 [{object}] ApiOK|ApiError 服务访问成功
- // @Failure 401 status 认证未通过,一般是未指定token或token已失效
- // @Failure 500 status 服务器|后台发生错误
- // @router /get_south_model [get]
- func (c *ModelController) GetSouthModel() {
- modelobj := new(service.ModelService)
- modelobj.UserInfo = c.GetCurrentUserInfo_rt()
- list := modelobj.GetModelListObj()
- if len(list) == 0 {
- var messageId = tools.GetUid()
- msgObj := new(utils.MsgStateManage)
- msgObj.SetMessageStateObj(messageId, utils.MsgState{Success: false, State: false, Message: ""})
- new(service.ModelService).QueryAllModel(messageId)
- Result := msgObj.HanderMesage(messageId, 5)
- if Result.Success {
- list = modelobj.GetModelListObj()
- c.Data["json"] = c.ApiOK(list)
- } else {
- c.Data["json"] = c.ApiError(Result.Message)
- }
- } else {
- c.Data["json"] = c.ApiOK(list)
- }
- c.ServeJSON()
- }
- //查询模型属性列表
- // @Summary 获取指定模型的属性列表
- // @Description 获取指定模型的属性列表。该模型定义由数据中台管理。
- // @Tags api
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param modelid query int true "数据模型ID。"
- // @Success 200 [{object}] ApiOK|ApiError 服务访问成功
- // @Failure 401 status 认证未通过,一般是未指定token或token已失效
- // @Failure 500 status 服务器|后台发生错误
- // @router /get_model_attr [get]
- func (c *ModelController) GetModelAttr() {
- modelObj := new(service.ModelService)
- modelId, _ := c.GetInt64("modelid")
- if modelId == 0 {
- c.Data["json"] = c.ApiError("模型id参数不允许为空!")
- } else {
- modelObj.UserInfo = c.GetCurrentUserInfo_rt()
- list := modelObj.GetModelAttrList(modelId)
- if list != nil && len(list) > 0 {
- c.Data["json"] = c.ApiOK(list)
- c.ServeJSON()
- return
- }
- var messageId = tools.GetUid()
- msgObj := new(utils.MsgStateManage)
- msgObj.SetMessageStateObj(messageId, utils.MsgState{Success: false, State: false, Message: ""})
- modelObj.QueryModelAttr(modelId, messageId)
- Result := msgObj.HanderMesage(messageId, 5)
- if Result.Success {
- list = modelObj.GetModelAttrList(modelId)
- c.Data["json"] = c.ApiOK(list)
- } else {
- c.Data["json"] = c.ApiError(Result.Message)
- }
- }
- c.ServeJSON()
- }
|