lanjianrong 4 jaren geleden
bovenliggende
commit
89d19e739d

+ 4 - 9
dao/project_message_dao.go

@@ -8,7 +8,7 @@ package dao
 
 import (
 	"github.com/go-xorm/xorm"
-	"go.mod/models"
+	"go.mod/web/viewmodels"
 )
 
 //数据库操作引擎
@@ -24,14 +24,9 @@ func NewProjectMessageDao(engine *xorm.Engine) *ProjectMessageDao {
 }
 
 // 获得项目下 账号的消息
-func (d *ProjectMessageDao) GetAll(projectId int, accountId int) []models.CmProjectMessage {
+func (d *ProjectMessageDao) GetAll(projectId int, accountId int) []viewmodels.ProjectMessageVM {
 
-	datalist := make([]models.CmProjectMessage, 0)
-	_ = d.engine.
-		Where("project_id=? and account_id=? ",
-			projectId, accountId).
-		Desc("id").
-		Limit(10, 0).
-		Find(&datalist)
+	datalist := make([]viewmodels.ProjectMessageVM, 0)
+	_ = d.engine.SQL("select pm.*, b.name as bidsection_name from cm_project_message as pm left join cm_bidsection as b on b.id = pm.bidsection_id where pm.project_id=? and pm.account_id=? order by pm.id desc limit 10", projectId, accountId).Find(&datalist)
 	return datalist
 }

+ 11 - 12
services/project_message_service.go

@@ -7,8 +7,6 @@
 package services
 
 import (
-	"strconv"
-
 	"go.mod/comm"
 	"go.mod/conf"
 	"go.mod/dao"
@@ -18,7 +16,7 @@ import (
 
 //定义项目Service接口
 type ProjectMessageService interface {
-	GetAll(projectId int, accountId int) []*viewmodels.ProjectMessage
+	GetAll(projectId int, accountId int) []*viewmodels.ProjectMessageVM
 }
 
 //返回service操作类
@@ -34,17 +32,17 @@ func NewProjectMessageService() ProjectMessageService {
 }
 
 // 获得需要关注人
-func (s *projectMessageService) GetAll(projectId int, accountId int) []*viewmodels.ProjectMessage {
+func (s *projectMessageService) GetAll(projectId int, accountId int) []*viewmodels.ProjectMessageVM {
 	dataList := s.projectMessagedao.GetAll(projectId, accountId)
 
-	projectMessageVM := make([]*viewmodels.ProjectMessage, 0)
+	projectMessageVM := make([]*viewmodels.ProjectMessageVM, 0)
 	for _, item := range dataList {
-		viewProjectMessage := &viewmodels.ProjectMessage{}
-		id, _ := comm.AesEncrypt(strconv.Itoa(item.Id), conf.SignSecret)
-		projectId, _ := comm.AesEncrypt(strconv.Itoa(item.ProjectId), conf.SignSecret)
-		bidsectionId, _ := comm.AesEncrypt(strconv.Itoa(item.BidsectionId), conf.SignSecret)
-		accountId, _ := comm.AesEncrypt(strconv.Itoa(item.AccountId), conf.SignSecret)
-		dataId, _ := comm.AesEncrypt(strconv.Itoa(item.DataId), conf.SignSecret)
+		viewProjectMessage := &viewmodels.ProjectMessageVM{}
+		id, _ := comm.AesEncrypt(item.Id, conf.SignSecret)
+		projectId, _ := comm.AesEncrypt(item.ProjectId, conf.SignSecret)
+		bidsectionId, _ := comm.AesEncrypt(item.BidsectionId, conf.SignSecret)
+		accountId, _ := comm.AesEncrypt(item.AccountId, conf.SignSecret)
+		dataId, _ := comm.AesEncrypt(item.DataId, conf.SignSecret)
 
 		viewProjectMessage.Id = id
 		viewProjectMessage.ProjectId = projectId
@@ -54,7 +52,8 @@ func (s *projectMessageService) GetAll(projectId int, accountId int) []*viewmode
 		viewProjectMessage.DataId = dataId
 		viewProjectMessage.Title = item.Title
 		viewProjectMessage.Content = item.Content
-		viewProjectMessage.CreateTime = item.CreateTime.Format(conf.SysTimeform)
+		viewProjectMessage.CreateTime = item.CreateTime
+		viewProjectMessage.BidsectionName = item.BidsectionName
 
 		projectMessageVM = append(projectMessageVM, viewProjectMessage)
 	}

+ 1 - 1
services/quality_audit.service.go

@@ -88,7 +88,7 @@ func (s *qualityAuditService) StartAudit(qualityId int, bidsectionId int, audito
 		return errors.New("该用户没有操作权限")
 	}
 	// 清除可能有的旧的审批流程
-	err := s.daoApprover.DeleteOldAuditors(bidsectionId, 1, qualityId)
+	err := s.daoApprover.DeleteOldAuditors(bidsectionId, 2, qualityId)
 	if err != nil {
 		return err
 	}

+ 13 - 0
web/viewmodels/project_message.go

@@ -18,6 +18,19 @@ type ProjectMessage struct {
 	CreateTime   string `form:"createTime" json:"createTime"`
 }
 
+type ProjectMessageVM struct {
+	Id             string `form:"id" json:"id"`
+	ProjectId      string `form:"projectId" json:"projectId"`
+	BidsectionId   string `form:"bidsectionId" json:"bidsectionId"`
+	AccountId      string `form:"accountId" json:"accountId"`
+	DataType       int    `form:"dataType" json:"dataType"`
+	DataId         string `form:"dataId" json:"dataId"`
+	Title          string `form:"title" json:"title"`
+	Content        string `form:"content" json:"content"`
+	CreateTime     string `form:"createTime" json:"createTime"`
+	BidsectionName string
+}
+
 // func (l ProjectMessage) Validate() error {
 // 	return validation.ValidateStruct(&l,
 // 		validation.Field(&l.BidsectionType, validation.Required.Error("请求类型不能为空"), validation.In(0, 1, 2).Error("未找到相关请求类型")),