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.
590 lines
19 KiB
590 lines
19 KiB
package archiveapi
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strconv"
|
|
"time"
|
|
|
|
"gin_server_admin/commonus"
|
|
"gin_server_admin/global"
|
|
"gin_server_admin/model/archivesmodel"
|
|
"gin_server_admin/model/common/response"
|
|
"gin_server_admin/model/testpage"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// 图文信息模块
|
|
type GraphicInformation struct{}
|
|
|
|
// 文档列表
|
|
func (g *GraphicInformation) ArchiveFileList(c *gin.Context) {
|
|
var requestData fileList
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
|
|
//查询条件
|
|
whereMap := commonus.MapOut()
|
|
|
|
if requestData.ParentId != 0 {
|
|
whereMap["g_parent"] = requestData.ParentId
|
|
}
|
|
|
|
if requestData.ParentIdStr != "" {
|
|
outIdVal, outIdErr := strconv.ParseInt(requestData.ParentIdStr, 10, 64)
|
|
if outIdErr != nil {
|
|
response.Result(102, requestData, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
whereMap["g_parent"] = outIdVal
|
|
}
|
|
//判断集团
|
|
if requestData.Group != 0 {
|
|
whereMap["g_write_group"] = requestData.Group
|
|
}
|
|
//判断分厂
|
|
if requestData.Factory != 0 {
|
|
whereMap["g_write_bfid"] = requestData.Factory
|
|
}
|
|
//判断工段
|
|
if requestData.Position != 0 {
|
|
whereMap["g_ws_id"] = requestData.Position
|
|
}
|
|
//判断班组
|
|
if requestData.Team != 0 {
|
|
whereMap["g_team"] = requestData.Team
|
|
}
|
|
//判断所属栏目
|
|
if requestData.ColumnId != 0 {
|
|
whereMap["g_parent_sun"] = requestData.ColumnId
|
|
}
|
|
if requestData.PageSize == 0 {
|
|
requestData.PageSize = 20
|
|
}
|
|
if requestData.Page <= 0 {
|
|
requestData.Page = 1
|
|
}
|
|
// psge := (requestData.Page - 1) * requestData.PageSize
|
|
appointPages := commonus.CalculatePages(requestData.Page, requestData.PageSize)
|
|
var fileList []archivesmodel.ArchiveFile
|
|
var total int64 //获取所有数据
|
|
if requestData.Title != "" {
|
|
listTitleErr := global.GVA_DB_BooImgkDate.Where(whereMap).Where("`g_title` LIKE %?% AND `g_state` IN ?", requestData.Title, []int{1, 2, 3}).Order("`g_id` DESC").Limit(requestData.PageSize).Offset(appointPages).Find(&fileList).Error
|
|
if listTitleErr != nil {
|
|
response.Result(103, listTitleErr, "数据获取失败!", c)
|
|
return
|
|
}
|
|
counrErr := global.GVA_DB_BooImgkDate.Model(&fileList).Where(whereMap).Where("`g_title` LIKE %?% AND `g_state` IN ?", requestData.Title, []int{1, 2, 3}).Count(&total).Error
|
|
if counrErr != nil {
|
|
total = 0
|
|
}
|
|
} else {
|
|
listErr := global.GVA_DB_BooImgkDate.Where(whereMap).Where("`g_state` IN ?", []int{1, 2, 3}).Order("`g_id` DESC").Limit(requestData.PageSize).Offset(appointPages).Find(&fileList).Error
|
|
if listErr != nil {
|
|
response.Result(104, listErr, "数据获取失败!", c)
|
|
return
|
|
}
|
|
counrErr := global.GVA_DB_BooImgkDate.Model(&fileList).Where(whereMap).Where("`g_state` IN ?", []int{1, 2, 3}).Count(&total).Error
|
|
if counrErr != nil {
|
|
total = 0
|
|
}
|
|
}
|
|
var fileListAry []callBackFilesList
|
|
for _, fileCont := range fileList {
|
|
var archiveTypeCont archivesmodel.ArchivesType
|
|
|
|
var fileListInfo callBackFilesList
|
|
fileListInfo.Id = fileCont.Id
|
|
fileListInfo.Title = fileCont.Title
|
|
fileListInfo.ColumnId = fileCont.ParentSun
|
|
|
|
fileListInfo.ParentColumnId = fileCont.Parent
|
|
|
|
archiveTypeCont.Id = fileCont.Parent
|
|
arcTypeErrParent := archiveTypeCont.GetArchiveTypeInfo()
|
|
if arcTypeErrParent == nil {
|
|
fileListInfo.ParentColumnTitle = archiveTypeCont.Title
|
|
} else {
|
|
fileListInfo.ParentColumnTitle = ""
|
|
}
|
|
|
|
archiveTypeCont.Id = fileCont.ParentSun
|
|
arcTypeErr := archiveTypeCont.GetArchiveTypeInfo()
|
|
if arcTypeErr == nil {
|
|
fileListInfo.ColumnTitle = archiveTypeCont.Title
|
|
} else {
|
|
fileListInfo.ColumnTitle = ""
|
|
}
|
|
reading, comment, collect, likes, tread, score := getBookArrter(fileCont.Id) //计算文章属性
|
|
|
|
fileListInfo.Reading = reading
|
|
fileListInfo.Comment = comment
|
|
fileListInfo.Collect = collect
|
|
fileListInfo.Likes = likes
|
|
fileListInfo.Tread = tread
|
|
fileListInfo.Score = score
|
|
|
|
fileListInfo.Scope = fileCont.VisitStrat
|
|
if fileCont.State == 2 {
|
|
fileListInfo.State = true
|
|
} else {
|
|
fileListInfo.State = false
|
|
}
|
|
fileListInfo.OutId = strconv.FormatInt(fileCont.Id, 10)
|
|
|
|
fileListAry = append(fileListAry, fileListInfo)
|
|
}
|
|
|
|
countSum := len(fileListAry)
|
|
printData := commonus.OutPutList(total, int64(countSum), requestData.Page, requestData.PageSize, fileListAry)
|
|
// fmt.Printf("%v\n", printData)
|
|
response.Result(0, printData, "查询成功!", c)
|
|
}
|
|
|
|
// 获取文档属性 global.GVA_DB_BookDate
|
|
func getBookArrter(id int64) (Reading, Comment, Collect, Likes, Tread, Score int64) {
|
|
var bookAttr archivesmodel.BookAttribute
|
|
readingErr := global.GVA_DB_BookDate.Model(&bookAttr).Where("`b_file_id` = ? AND `b_stater` = ? AND `b_type` = ?", id, 1, 1).Count(&Reading).Error
|
|
if readingErr != nil {
|
|
Reading = 0
|
|
}
|
|
collectErr := global.GVA_DB_BookDate.Model(&bookAttr).Where("`b_file_id` = ? AND `b_stater` = ? AND `b_type` = ?", id, 1, 2).Count(&Collect).Error
|
|
if collectErr != nil {
|
|
Collect = 0
|
|
}
|
|
likesErr := global.GVA_DB_BookDate.Model(&bookAttr).Where("`b_file_id` = ? AND `b_stater` = ? AND `b_type` = ?", id, 1, 3).Count(&Likes).Error
|
|
if likesErr != nil {
|
|
Likes = 0
|
|
}
|
|
treadErr := global.GVA_DB_BookDate.Model(&bookAttr).Where("`b_file_id` = ? AND `b_stater` = ? AND `b_type` = ?", id, 1, 3).Count(&Tread).Error
|
|
if treadErr != nil {
|
|
Tread = 0
|
|
}
|
|
var siscussMsg archivesmodel.DiscussMsg
|
|
commentErr := global.GVA_DB_BookDate.Model(&siscussMsg).Where("dis_file_id = ? AND dis_stater = ?", id, 2).Count(&Comment).Error
|
|
if commentErr != nil {
|
|
Comment = 0
|
|
}
|
|
return
|
|
}
|
|
|
|
// 添加文档
|
|
func (g *GraphicInformation) AddArchiveFileInfo(c *gin.Context) {
|
|
var archiveFileInfo archivesmodel.ArchiveFile
|
|
archiveFileInfo.InitInfo()
|
|
err := c.ShouldBindJSON(&archiveFileInfo)
|
|
|
|
if err != nil {
|
|
response.Result(101, archiveFileInfo, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.Title == "" {
|
|
response.Result(102, archiveFileInfo, "请输入文档标题!", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.Parent == 0 {
|
|
response.Result(103, archiveFileInfo, "请输入文档所属顶级分类!", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.ParentSun == 0 {
|
|
response.Result(104, archiveFileInfo, "请输入文档所属分类!", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.Source == 2 && archiveFileInfo.SourceUrl == "" {
|
|
response.Result(105, archiveFileInfo, "请输入文档转载地址!", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.Source != 2 && archiveFileInfo.Content == "" && archiveFileInfo.TestUrl == "" {
|
|
response.Result(106, archiveFileInfo, "正文内容不能为空", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.UserKey == 0 {
|
|
response.Result(109, archiveFileInfo, "请确认编辑人员KEY!", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.State <= 0 || archiveFileInfo.State > 4 {
|
|
archiveFileInfo.State = 2
|
|
}
|
|
if archiveFileInfo.OuterLink != "" {
|
|
urlIsTrue := commonus.JudgeHttpOrHttps(archiveFileInfo.OuterLink)
|
|
if urlIsTrue != true {
|
|
response.Result(107, archiveFileInfo, "您输入的外链格式不正确!", c)
|
|
return
|
|
}
|
|
}
|
|
addArchiveFileErr := global.GVA_DB_BooImgkDate.Create(&archiveFileInfo).Error
|
|
if addArchiveFileErr != nil {
|
|
response.Result(108, archiveFileInfo, "数据写入失败!", c)
|
|
} else {
|
|
response.Result(0, archiveFileInfo, "数据写入成功!", c)
|
|
}
|
|
}
|
|
|
|
// 获取文档信息
|
|
func (g *GraphicInformation) GetArchiveFileInfo(c *gin.Context) {
|
|
var getID commonus.SetId
|
|
err := c.ShouldBindJSON(&getID)
|
|
|
|
if err != nil {
|
|
response.Result(101, getID, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if getID.Id == 0 {
|
|
response.Result(101, getID, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if getID.OutId != "" {
|
|
outIdVal, outIdErr := strconv.ParseInt(getID.OutId, 10, 64)
|
|
if outIdErr != nil {
|
|
response.Result(102, getID, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
getID.Id = outIdVal
|
|
}
|
|
var archiveFileInfo archivesmodel.ArchiveFile
|
|
archiveFileInfo.InitInfo()
|
|
sysUserErr := global.GVA_DB_BooImgkDate.Where("g_id = ?", getID.Id).First(&archiveFileInfo).Error
|
|
if sysUserErr != nil {
|
|
response.Result(102, sysUserErr, "数据查询失败!", c)
|
|
} else {
|
|
response.Result(0, archiveFileInfo, "数据查询成功!", c)
|
|
}
|
|
}
|
|
|
|
// 修改文档信息
|
|
func (g *GraphicInformation) EiteArchiveFileInfo(c *gin.Context) {
|
|
var archiveFileInfo archivesmodel.ArchiveFile
|
|
err := c.ShouldBindJSON(&archiveFileInfo)
|
|
if err != nil {
|
|
response.Result(101, archiveFileInfo, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.Id == 0 {
|
|
response.Result(108, archiveFileInfo, "!请提交文档ID!", c)
|
|
return
|
|
}
|
|
|
|
if archiveFileInfo.Title == "" {
|
|
response.Result(102, archiveFileInfo, "请输入文档标题!", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.Parent == 0 {
|
|
response.Result(103, archiveFileInfo, "请输入文档所属顶级分类!", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.ParentSun == 0 {
|
|
response.Result(104, archiveFileInfo, "请输入文档所属分类!", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.Source == 2 && archiveFileInfo.SourceUrl == "" {
|
|
response.Result(105, archiveFileInfo, "请输入文档转载地址!", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.Source != 2 && archiveFileInfo.Content == "" && archiveFileInfo.TestUrl == "" {
|
|
response.Result(106, archiveFileInfo, "正文内容不能为空", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.UserKey == 0 {
|
|
response.Result(109, archiveFileInfo, "请确认编辑人员KEY!", c)
|
|
return
|
|
}
|
|
if archiveFileInfo.State <= 0 || archiveFileInfo.State > 4 {
|
|
archiveFileInfo.State = 2
|
|
}
|
|
if archiveFileInfo.OuterLink != "" {
|
|
urlIsTrue := commonus.JudgeHttpOrHttps(archiveFileInfo.OuterLink)
|
|
if urlIsTrue != true {
|
|
response.Result(107, archiveFileInfo, "您输入的外链格式不正确!", c)
|
|
return
|
|
}
|
|
}
|
|
// addArchiveFileErr := global.GVA_DB_BooImgkDate.Create(&archiveFileInfo).Error
|
|
// if addArchiveFileErr != nil {
|
|
// response.Result(108, archiveFileInfo, "数据写入失败!", c)
|
|
// } else {
|
|
// response.Result(0, archiveFileInfo, "数据写入成功!", c)
|
|
// }
|
|
archiveFileInfo.EiteTime = time.Now().Unix()
|
|
var archiveFileMod archivesmodel.ArchiveFile
|
|
addArchiveFileErr := global.GVA_DB_BooImgkDate.Model(&archiveFileMod).Where("g_id = ?", archiveFileInfo.Id).Updates(archiveFileInfo).Error
|
|
if addArchiveFileErr != nil {
|
|
response.Result(110, addArchiveFileErr, "数据写入失败!", c)
|
|
return
|
|
}
|
|
response.Result(0, archiveFileInfo, "数据写入成功!", c)
|
|
}
|
|
|
|
// 状态修改及软硬删除文档信息
|
|
func (g *GraphicInformation) ModifyArchiveFileInfo(c *gin.Context) {
|
|
var arrData archiveState
|
|
err := c.ShouldBindJSON(&arrData)
|
|
if err != nil {
|
|
response.Result(101, err, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if arrData.Id == 0 {
|
|
response.Result(102, arrData, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if arrData.OutId != "" {
|
|
outIdVal, outIdErr := strconv.ParseInt(arrData.OutId, 10, 64)
|
|
if outIdErr != nil {
|
|
response.Result(102, arrData, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
arrData.Id = outIdVal
|
|
}
|
|
if arrData.State == 0 {
|
|
arrData.State = 3
|
|
}
|
|
if arrData.IsDel != 1 {
|
|
isTrue := eiteArchiveFileState(arrData)
|
|
if isTrue != true {
|
|
response.Result(103, isTrue, "修改失败!", c)
|
|
return
|
|
}
|
|
response.Result(0, arrData, "修改成功!", c)
|
|
} else {
|
|
if arrData.State == 4 {
|
|
var archiveFileMod archivesmodel.ArchiveFile
|
|
archiveInfoErr := global.GVA_DB_BooImgkDate.Where("g_id = ?", arrData.Id).Delete(&archiveFileMod).Error
|
|
if archiveInfoErr != nil {
|
|
response.Result(104, arrData, "删除失败!", c)
|
|
return
|
|
}
|
|
response.Result(0, arrData, "删除成功!", c)
|
|
} else {
|
|
isTrue := eiteArchiveFileState(arrData)
|
|
if isTrue != true {
|
|
response.Result(105, isTrue, "修改失败!", c)
|
|
return
|
|
}
|
|
response.Result(0, arrData, "修改成功!", c)
|
|
}
|
|
}
|
|
}
|
|
|
|
// 修改文档状态
|
|
func eiteArchiveFileState(arrData archiveState) (isTrue bool) {
|
|
isTrue = false
|
|
//软处理
|
|
saveData := commonus.MapOut()
|
|
saveData["g_state"] = arrData.State
|
|
saveData["g_eite_time"] = time.Now().Unix()
|
|
var archiveFileMod archivesmodel.ArchiveFile
|
|
archiveInfoErr := global.GVA_DB_BooImgkDate.Model(&archiveFileMod).Where("g_id = ?", arrData.Id).Updates(saveData).Error
|
|
if archiveInfoErr != nil {
|
|
return
|
|
}
|
|
isTrue = true
|
|
return
|
|
}
|
|
|
|
// 批量删除
|
|
func (g *GraphicInformation) BatchDeleteArchiveFile(c *gin.Context) {
|
|
var arrData batchArchiveState
|
|
err := c.ShouldBindJSON(&arrData)
|
|
if err != nil {
|
|
response.Result(101, err, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if len(arrData.Id) < 1 {
|
|
response.Result(102, arrData, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if arrData.State == 0 {
|
|
arrData.State = 3
|
|
}
|
|
if arrData.IsDel != 1 {
|
|
isTrue := batchEiteArchiveFileState(arrData)
|
|
if isTrue != true {
|
|
response.Result(103, isTrue, "修改失败!", c)
|
|
return
|
|
}
|
|
response.Result(0, arrData, "修改成功!", c)
|
|
} else {
|
|
if arrData.State == 4 {
|
|
var archiveFileMod archivesmodel.ArchiveFile
|
|
archiveInfoErr := global.GVA_DB_BooImgkDate.Where("g_id IN ?", arrData.Id).Delete(&archiveFileMod).Error
|
|
if archiveInfoErr != nil {
|
|
response.Result(104, arrData, "删除失败!", c)
|
|
return
|
|
}
|
|
response.Result(0, arrData, "删除成功!", c)
|
|
} else {
|
|
isTrue := batchEiteArchiveFileState(arrData)
|
|
if isTrue != true {
|
|
response.Result(105, isTrue, "修改失败!", c)
|
|
return
|
|
}
|
|
response.Result(0, arrData, "修改成功!", c)
|
|
}
|
|
}
|
|
}
|
|
|
|
// 批量修改文档状态
|
|
func batchEiteArchiveFileState(arrData batchArchiveState) (isTrue bool) {
|
|
isTrue = false
|
|
//软处理
|
|
saveData := commonus.MapOut()
|
|
saveData["g_state"] = arrData.State
|
|
saveData["g_eite_time"] = time.Now().Unix()
|
|
var archiveFileMod archivesmodel.ArchiveFile
|
|
archiveInfoErr := global.GVA_DB_BooImgkDate.Model(&archiveFileMod).Where("g_id IN ?", arrData.Id).Updates(saveData).Error
|
|
if archiveInfoErr != nil {
|
|
return
|
|
}
|
|
isTrue = true
|
|
return
|
|
}
|
|
|
|
// 获取文档属性列表
|
|
func (g *GraphicInformation) GetArchiveFileAttributeList(c *gin.Context) {
|
|
var fileAttribute archiveFileAttr
|
|
err := c.ShouldBindJSON(&fileAttribute)
|
|
if err != nil {
|
|
response.Result(101, err, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if fileAttribute.FileID == 0 {
|
|
response.Result(102, err, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if fileAttribute.Type == 0 {
|
|
fileAttribute.Type = 1
|
|
}
|
|
if fileAttribute.PageSize == 0 {
|
|
fileAttribute.PageSize = 20
|
|
}
|
|
if fileAttribute.Page <= 0 {
|
|
fileAttribute.Page = 1
|
|
}
|
|
appointPages := commonus.CalculatePages(fileAttribute.Page, fileAttribute.PageSize)
|
|
var bookAttrbuteList []archivesmodel.BookAttribute
|
|
var total int64 //获取所有数据
|
|
|
|
//查询条件
|
|
whereMap := commonus.MapOut()
|
|
whereMap["b_file_id"] = fileAttribute.FileID
|
|
whereMap["b_type"] = fileAttribute.Type
|
|
whereMap["b_stater"] = 1
|
|
|
|
listErr := global.GVA_DB_BookDate.Where(whereMap).Order("`b_id` DESC").Limit(fileAttribute.PageSize).Offset(appointPages).Find(&bookAttrbuteList).Error
|
|
if listErr != nil {
|
|
response.Result(104, listErr, "数据获取失败!", c)
|
|
return
|
|
}
|
|
counrErr := global.GVA_DB_BookDate.Model(&bookAttrbuteList).Where(whereMap).Count(&total).Error
|
|
if counrErr != nil {
|
|
total = 0
|
|
}
|
|
var bookAttrContMap []archiveFileAttrOutPut
|
|
for _, bookAttrVal := range bookAttrbuteList {
|
|
var bookAttrCont archiveFileAttrOutPut
|
|
getMyInfo, myInfoIstrue := GetUserInfo([]string{"worker_man.wm_number", "worker_man_data.wmd_name"}, map[string]interface{}{"wm_key": bookAttrVal.UserId})
|
|
bookAttrCont.Id = bookAttrVal.Id
|
|
bookAttrCont.OutId = strconv.FormatInt(bookAttrVal.Id, 10)
|
|
bookAttrCont.FileId = bookAttrVal.FileId
|
|
bookAttrCont.UserId = bookAttrVal.UserId
|
|
bookAttrCont.Time = bookAttrVal.Time
|
|
bookAttrCont.Type = bookAttrVal.Type
|
|
bookAttrCont.Stater = bookAttrVal.Stater
|
|
bookAttrCont.EiteTime = bookAttrVal.EiteTime
|
|
bookAttrCont.Source = bookAttrVal.Source
|
|
if myInfoIstrue == true {
|
|
bookAttrCont.Number = getMyInfo.Number
|
|
bookAttrCont.Name = getMyInfo.Name
|
|
}
|
|
bookAttrContMap = append(bookAttrContMap, bookAttrCont)
|
|
}
|
|
|
|
countSum := len(bookAttrContMap)
|
|
printData := commonus.OutPutList(total, int64(countSum), fileAttribute.Page, fileAttribute.PageSize, bookAttrContMap)
|
|
// fmt.Printf("%v\n", printData)
|
|
response.Result(0, printData, "查询成功!", c)
|
|
}
|
|
|
|
// 获取人员信息
|
|
func GetUserInfo(field []string, whereMap map[string]interface{}) (userCont testpage.PersonalDetails, isTrue bool) {
|
|
isTrue = false
|
|
var userInfo testpage.WorkMan
|
|
userErr := global.GVA_DB_Master.Model(&userInfo).Select(field).Joins("left join worker_man_data on worker_man_data.wmd_key = worker_man.wm_key").Where(whereMap).Find(&userCont).Error
|
|
if userErr == nil {
|
|
isTrue = true
|
|
}
|
|
return
|
|
}
|
|
|
|
// 获取归档评论列表
|
|
func (g *GraphicInformation) GetDiscussFileMsg(c *gin.Context) {
|
|
var fileAttribute archiveFileAttr
|
|
err := c.ShouldBindJSON(&fileAttribute)
|
|
if err != nil {
|
|
response.Result(101, err, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if fileAttribute.FileID == 0 {
|
|
response.Result(102, err, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if fileAttribute.Type == 0 {
|
|
fileAttribute.Type = 1
|
|
}
|
|
if fileAttribute.PageSize == 0 {
|
|
fileAttribute.PageSize = 20
|
|
}
|
|
if fileAttribute.Page <= 0 {
|
|
fileAttribute.Page = 1
|
|
}
|
|
appointPages := commonus.CalculatePages(fileAttribute.Page, fileAttribute.PageSize)
|
|
var total int64 //获取所有数据
|
|
var siscussMsg []archivesmodel.DiscussMsg
|
|
|
|
//查询条件
|
|
whereMap := commonus.MapOut()
|
|
whereMap["dis_file_id"] = fileAttribute.FileID
|
|
whereMap["dis_source"] = fileAttribute.Type
|
|
whereMap["dis_stater"] = 2
|
|
listErr := global.GVA_DB_BookDate.Where(whereMap).Order("`dis_id` DESC").Limit(fileAttribute.PageSize).Offset(appointPages).Find(&siscussMsg).Error
|
|
if listErr != nil {
|
|
response.Result(104, listErr, "数据获取失败!", c)
|
|
return
|
|
}
|
|
counrErr := global.GVA_DB_BookDate.Model(&siscussMsg).Where(whereMap).Count(&total).Error
|
|
if counrErr != nil {
|
|
total = 0
|
|
}
|
|
var bookAttrContMap []archiveFileDiscussAttrOutPut
|
|
for _, bookAttrVal := range siscussMsg {
|
|
var bookAttrCont archiveFileDiscussAttrOutPut
|
|
|
|
bookAttrCont.Id = bookAttrVal.Id
|
|
bookAttrCont.FileId = bookAttrVal.FileId
|
|
bookAttrCont.UserId = bookAttrVal.UserId
|
|
bookAttrCont.Prent = bookAttrVal.Prent
|
|
bookAttrCont.Content = bookAttrVal.Content
|
|
bookAttrCont.Time = bookAttrVal.Time
|
|
bookAttrCont.Stater = bookAttrVal.Stater
|
|
bookAttrCont.EiteTime = bookAttrVal.EiteTime
|
|
bookAttrCont.Source = bookAttrVal.Source
|
|
bookAttrCont.UserJson = bookAttrVal.UserJson
|
|
var discussJson discussJson
|
|
errDisJson := json.Unmarshal([]byte(bookAttrVal.UserJson), &discussJson)
|
|
if errDisJson == nil {
|
|
bookAttrCont.UserJsonCont = discussJson
|
|
}
|
|
getMyInfo, myInfoIstrue := GetUserInfo([]string{"worker_man.wm_number", "worker_man_data.wmd_name"}, map[string]interface{}{"wm_key": bookAttrVal.UserId})
|
|
if myInfoIstrue == true {
|
|
bookAttrCont.Number = getMyInfo.Number
|
|
bookAttrCont.Name = getMyInfo.Name
|
|
}
|
|
bookAttrContMap = append(bookAttrContMap, bookAttrCont)
|
|
}
|
|
|
|
countSum := len(bookAttrContMap)
|
|
printData := commonus.OutPutList(total, int64(countSum), fileAttribute.Page, fileAttribute.PageSize, bookAttrContMap)
|
|
// fmt.Printf("%v\n", printData)
|
|
response.Result(0, printData, "查询成功!", c)
|
|
}
|
|
|