应用集成平台服务端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.8 KiB

package matrixapi
import (
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2023-07-04 13:05:25
@ 功能: 获取矩阵列表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) MatrixList(c *gin.Context) {
var requestData SearchMatrix
c.ShouldBindJSON(&requestData)
if requestData.Page == 0 {
requestData.Page = 1
}
if requestData.PageSize == 0 {
requestData.PageSize = 15
}
var matrixInfoList []modelAppPlatform.MatrixContent
gormDb := overall.CONSTANT_DB_AppPlatform.Where("`state` = 1")
if requestData.KeyWords != "" {
gormDb = gormDb.Where("`name` like ?", "%"+requestData.KeyWords+"%")
}
if requestData.AdminOrg != 0 {
var sunOrg publicmethod.GetOrgAllParent
sunOrg.GetOrgSonAllId(requestData.AdminOrg)
sunOrg.Id = append(sunOrg.Id, requestData.AdminOrg)
gormDb = gormDb.Where("`org` IN ?", sunOrg.Id)
}
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
err := gormDb.Find(&matrixInfoList).Error
if err != nil {
publicmethod.Result(105, err, c)
return
}
var sendList []SendMatrix
for _, v := range matrixInfoList {
var sendCont SendMatrix
sendCont.Id = v.Id
sendCont.Name = v.Name
sendCont.Center = v.Center
sendCont.Org = v.Org
var orgCont modelshr.AdministrativeOrganization
orgCont.GetCont(map[string]interface{}{"`id`": v.Org}, "`name`")
sendCont.OrgName = orgCont.Name
sendCont.State = v.State
sendCont.Time = v.Time
sendList = append(sendList, sendCont)
}
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendList)), sendList, c)
}