feat:完善项目信息

This commit is contained in:
henry
2022-01-11 14:54:20 +08:00
parent 8006d57506
commit 72c2cb091d
15 changed files with 299 additions and 38 deletions

View File

@ -143,19 +143,21 @@ func (*Service) SolutionCaseDetail(c *gin.Context) {
func (*Service) SolutionCaseForm(c *gin.Context) { func (*Service) SolutionCaseForm(c *gin.Context) {
form := &struct { form := &struct {
api.IDStringForm api.IDStringForm
KindID string `json:"kind_id" form:"kind_id" binding:"required"` api.TenantIDStringForm
Title string `json:"title" form:"title" binding:"required"` KindID string `json:"kind_id" form:"kind_id" binding:"required"`
Content string `json:"content" form:"content" binding:"required"` Title string `json:"title" form:"title" binding:"required"`
Tags []string `json:"tags" form:"tags"` api.ImageForm
Sort int `json:"sort" form:"sort"` Description string `json:"description" form:"description" binding:"description"`
Content string `json:"content" form:"content" binding:"required"`
Sort int `json:"sort" form:"sort"`
}{} }{}
if err := api.Bind(form)(c); err != nil { if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c) api.APIFailure(err.(error))(c)
return return
} }
err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).Form(&service.SolutionCaseParams{ err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).Form(&service.SolutionCaseParams{
ID: form.Convert(), KindID: (&api.IDStringForm{ID: form.KindID}).Convert(), ID: form.IDStringForm.Convert(), TenantID: form.TenantIDStringForm.Convert(), KindID: (&api.IDStringForm{ID: form.KindID}).Convert(),
Title: form.Title, Content: form.Content, Sort: form.Sort, Image: form.FilterImageURL(), Title: form.Title, Description: form.Description, Content: form.Content, Sort: form.Sort,
}) })
api.APIResponse(err)(c) api.APIResponse(err)(c)
} }
@ -194,6 +196,7 @@ func (*Service) SolutionCaseKindSelect(c *gin.Context) {
func (*Service) SolutionCaseKindForm(c *gin.Context) { func (*Service) SolutionCaseKindForm(c *gin.Context) {
form := &struct { form := &struct {
api.IDStringForm api.IDStringForm
api.TenantIDStringForm
Mode int `json:"mode" form:"mode" binding:"required"` Mode int `json:"mode" form:"mode" binding:"required"`
Title string `json:"title" form:"title" binding:"required"` Title string `json:"title" form:"title" binding:"required"`
api.ImageForm api.ImageForm
@ -204,7 +207,8 @@ func (*Service) SolutionCaseKindForm(c *gin.Context) {
return return
} }
err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).KindForm(&service.SolutionCaseKindParams{ err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).KindForm(&service.SolutionCaseKindParams{
ID: form.Convert(), Mode: form.Mode, Image: form.FilterImageURL(), Title: form.Title, Sort: form.Sort, ID: form.IDStringForm.Convert(), TenantID: form.TenantIDStringForm.Convert(), Mode: form.Mode,
Image: form.FilterImageURL(), Title: form.Title, Sort: form.Sort,
}) })
api.APIResponse(err)(c) api.APIResponse(err)(c)
} }
@ -219,3 +223,33 @@ func (*Service) SolutionCaseKindDelete(c *gin.Context) {
err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).KindDelete(form.Convert()) err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).KindDelete(form.Convert())
api.APIResponse(err)(c) api.APIResponse(err)(c)
} }
func (*Service) Message(c *gin.Context) {
form := &struct {
api.TenantIDStringForm
Name string `json:"name" form:"name"`
Status int `json:"status" form:"status"`
Content string `json:"content" form:"content"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := service.NewMessage()(api.GetSession()(c).(*session.Admin)).Instance(form.TenantIDStringForm.Convert(),
form.Name, form.Status, form.Content, form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}
func (*Service) MessageHandle(c *gin.Context) {
form := &struct {
api.IDStringForm
Content string `json:"content" form:"content"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := service.NewMessage()(api.GetSession()(c).(*session.Admin)).Handle(form.Convert(), form.Content)
api.APIResponse(err)(c)
}

View File

@ -0,0 +1,105 @@
package service
import (
"SciencesServer/app/api/admin/model"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/session"
"SciencesServer/serve/orm"
"errors"
"gorm.io/gorm"
"time"
)
type Message struct {
*session.Admin
}
type MessageHandle func(session *session.Admin) *Message
type MessageInfo struct {
ID string `json:"id"`
*model.ServiceMessageInfo
Area string `json:"area"`
}
// Instance 列表信息
func (c *Message) Instance(tenantID uint64, name string, status int, content string, page, pageSize int) (*controller.ReturnPages, error) {
mServiceMessage := model.NewServiceMessage()
where := make([]*model2.ModelWhere, 0)
if c.TenantID > 0 {
where = append(where, model2.NewWhere("m.tenant_id", c.TenantID))
}
if tenantID > 0 {
where = append(where, model2.NewWhere("m.tenant_id", tenantID))
}
if name != "" {
where = append(where, model2.NewWhereLike("m.name", name))
}
if status > 0 {
where = append(where, model2.NewWhere("m.status", status))
}
if content != "" {
where = append(where, model2.NewWhereLike("m.content", content))
}
var count int64
out, err := mServiceMessage.Message(page, pageSize, &count, where...)
if err != nil {
return nil, err
}
list := make([]*MessageInfo, 0)
for _, v := range out {
list = append(list, &MessageInfo{
ID: v.GetEncodeID(),
ServiceMessageInfo: v,
Area: v.FormatBasic(),
})
}
return &controller.ReturnPages{Data: list, Count: count}, err
}
// Handle 处理操作
func (c *Message) Handle(id uint64, content string) error {
mServiceMessage := model.NewServiceMessage()
mServiceMessage.ID = id
isExist, err := model2.FirstField(mServiceMessage.ServiceMessage, []string{"id", "tenant_id", "status"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,留言信息不存在或已被删除")
} else if c.TenantID > 0 && mServiceMessage.TenantID != c.TenantID {
return errors.New("操作错误,无权限操作")
}
if mServiceMessage.Status != model2.ServiceMessageStatusForProcessing {
return errors.New("操作错误,当前留言信息已处理")
}
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
if err = model2.Updates(mServiceMessage.ServiceMessage, map[string]interface{}{
"status": model2.ServiceMessageStatusForProcessed, "updated_at": time.Now(),
}, tx); err != nil {
return err
}
mServiceMessageLog := model.NewServiceMessageLog()
mServiceMessageLog.UID = c.UID
mServiceMessageLog.MessageID = id
mServiceMessageLog.Content = content
if err = model2.Create(mServiceMessage.ServiceMessage); err != nil {
return err
}
return nil
})
}
func NewMessage() MessageHandle {
return func(session *session.Admin) *Message {
return &Message{session}
}
}

View File

@ -5,6 +5,7 @@ import (
"SciencesServer/app/basic/controller" "SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model" model2 "SciencesServer/app/common/model"
"SciencesServer/app/session" "SciencesServer/app/session"
config2 "SciencesServer/config"
"errors" "errors"
) )
@ -25,11 +26,12 @@ type (
SolutionCaseDetailInfo struct { SolutionCaseDetailInfo struct {
ID string `json:"id"` ID string `json:"id"`
*model2.ServiceSolutionCase *model2.ServiceSolutionCase
KindID string `json:"kind_id"` TenantID string `json:"tenant_id"`
KindID string `json:"kind_id"`
} }
// SolutionCaseParams 案例参数信息 // SolutionCaseParams 案例参数信息
SolutionCaseParams struct { SolutionCaseParams struct {
ID, KindID uint64 ID, TenantID, KindID uint64
Title, Image, Description, Content string Title, Image, Description, Content string
Sort int Sort int
} }
@ -37,7 +39,8 @@ type (
SolutionCaseKindInfo struct { SolutionCaseKindInfo struct {
ID string `json:"id"` ID string `json:"id"`
*model2.ServiceSolutionCaseKind *model2.ServiceSolutionCaseKind
Area string `json:"area"` TenantID string `json:"tenant_id"`
Area string `json:"area"`
} }
// SolutionCaseKindSelectInfo 案例分类筛选信息 // SolutionCaseKindSelectInfo 案例分类筛选信息
SolutionCaseKindSelectInfo struct { SolutionCaseKindSelectInfo struct {
@ -47,7 +50,7 @@ type (
} }
// SolutionCaseKindParams 案例分类参数信息 // SolutionCaseKindParams 案例分类参数信息
SolutionCaseKindParams struct { SolutionCaseKindParams struct {
ID uint64 ID, TenantID uint64
Mode int Mode int
Title, Image string Title, Image string
Sort int Sort int
@ -82,7 +85,7 @@ func (c *SolutionCase) Instance(tenantID uint64, title string, kindID uint64, pa
list := make([]*SolutionCaseInfo, 0) list := make([]*SolutionCaseInfo, 0)
for _, v := range out { for _, v := range out {
v.Image.Image = v.Image.Analysis("") v.Image.Image = v.Image.Analysis(config2.SettingInfo.Domain)
list = append(list, &SolutionCaseInfo{ list = append(list, &SolutionCaseInfo{
ID: v.GetEncodeID(), ID: v.GetEncodeID(),
@ -105,11 +108,12 @@ func (c *SolutionCase) Detail(id uint64) (*SolutionCaseDetailInfo, error) {
} else if !isExist { } else if !isExist {
return nil, errors.New("操作错误,案例信息不存在或已被删除") return nil, errors.New("操作错误,案例信息不存在或已被删除")
} }
mServiceSolutionCase.Image.Image = mServiceSolutionCase.Image.Analysis("") mServiceSolutionCase.Image.Image = mServiceSolutionCase.Image.Analysis(config2.SettingInfo.Domain)
return &SolutionCaseDetailInfo{ return &SolutionCaseDetailInfo{
ID: mServiceSolutionCase.GetEncodeID(), ID: mServiceSolutionCase.GetEncodeID(),
ServiceSolutionCase: mServiceSolutionCase.ServiceSolutionCase, ServiceSolutionCase: mServiceSolutionCase.ServiceSolutionCase,
TenantID: mServiceSolutionCase.GetEncodeTenantID(),
KindID: (&model2.Model{ID: mServiceSolutionCase.KindID}).GetEncodeID(), KindID: (&model2.Model{ID: mServiceSolutionCase.KindID}).GetEncodeID(),
}, nil }, nil
} }
@ -140,10 +144,16 @@ func (c *SolutionCase) Form(params *SolutionCaseParams) error {
mServiceSolutionCase.Sort = params.Sort mServiceSolutionCase.Sort = params.Sort
if mServiceSolutionCase.ID > 0 { if mServiceSolutionCase.ID > 0 {
if c.TenantID <= 0 {
mServiceSolutionCase.TenantID = params.TenantID
}
return model2.Updates(mServiceSolutionCase.ServiceSolutionCase, mServiceSolutionCase.ServiceSolutionCase) return model2.Updates(mServiceSolutionCase.ServiceSolutionCase, mServiceSolutionCase.ServiceSolutionCase)
} }
mServiceSolutionCase.TenantID = c.TenantID mServiceSolutionCase.TenantID = params.TenantID
if c.TenantID > 0 {
mServiceSolutionCase.TenantID = c.TenantID
}
return model2.Create(mServiceSolutionCase.ServiceSolutionCase) return model2.Create(mServiceSolutionCase.ServiceSolutionCase)
} }
@ -193,9 +203,12 @@ func (c *SolutionCase) Kind(tenantID uint64, mode int, title string, page, pageS
list := make([]*SolutionCaseKindInfo, 0) list := make([]*SolutionCaseKindInfo, 0)
for _, v := range out { for _, v := range out {
v.Image.Image = v.Image.Analysis(config2.SettingInfo.Domain)
list = append(list, &SolutionCaseKindInfo{ list = append(list, &SolutionCaseKindInfo{
ID: v.GetEncodeID(), ID: v.GetEncodeID(),
ServiceSolutionCaseKind: v.ServiceSolutionCaseKind, ServiceSolutionCaseKind: v.ServiceSolutionCaseKind,
TenantID: v.GetEncodeTenantID(),
Area: v.FormatBasic(), Area: v.FormatBasic(),
}) })
} }
@ -259,10 +272,16 @@ func (c *SolutionCase) KindForm(params *SolutionCaseKindParams) error {
mServiceSolutionCaseKind.Sort = params.Sort mServiceSolutionCaseKind.Sort = params.Sort
if mServiceSolutionCaseKind.ID > 0 { if mServiceSolutionCaseKind.ID > 0 {
if c.TenantID <= 0 {
mServiceSolutionCaseKind.TenantID = params.TenantID
}
return model2.Updates(mServiceSolutionCaseKind.ServiceSolutionCaseKind, mServiceSolutionCaseKind.ServiceSolutionCaseKind) return model2.Updates(mServiceSolutionCaseKind.ServiceSolutionCaseKind, mServiceSolutionCaseKind.ServiceSolutionCaseKind)
} }
mServiceSolutionCaseKind.TenantID = c.TenantID mServiceSolutionCaseKind.TenantID = params.TenantID
if c.TenantID > 0 {
mServiceSolutionCaseKind.TenantID = c.TenantID
}
return model2.Create(mServiceSolutionCaseKind.ServiceSolutionCaseKind) return model2.Create(mServiceSolutionCaseKind.ServiceSolutionCaseKind)
} }

View File

@ -0,0 +1,48 @@
package model
import (
"SciencesServer/app/common/model"
"SciencesServer/serve/orm"
"fmt"
"time"
)
type ServiceMessage struct {
*model.ServiceMessage
}
type ServiceMessageInfo struct {
*model.ServiceMessage
model.Area
HandleContent string `json:"handle_content"`
HandleCreatedAt time.Time `json:"handle_created_at"`
}
func (m *ServiceMessage) Message(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ServiceMessageInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS m").
Select("m.*", "l.content AS handle_content", "l.created_at AS handle_created_at",
"t.province", "t.city").
Joins(fmt.Sprintf("LEFT JOIN (SELECT MAX(id) AS id, message_id, MAX(created_at) AS created_at, MAX(content) AS content "+
"FROM %s WHERE is_deleted = %d GROUP BY message_id) AS l ON m.id = l.message_id",
model.NewServiceMessageLog().TableName(), model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON m.tenant_id = t.id", model.NewSysTenant().TableName()))
if len(where) > 0 {
for _, v := range where {
db = db.Where(v.Condition, v.Value)
}
}
out := make([]*ServiceMessageInfo, 0)
if err := db.Count(count).Error; err != nil {
return nil, err
}
if err := db.Order("m.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
return nil, err
}
return out, nil
}
func NewServiceMessage() *ServiceMessage {
return &ServiceMessage{model.NewServiceMessage()}
}

View File

@ -0,0 +1,11 @@
package model
import "SciencesServer/app/common/model"
type ServiceMessageLog struct {
*model.ServiceMessageLog
}
func NewServiceMessageLog() *ServiceMessageLog {
return &ServiceMessageLog{model.NewServiceMessageLog()}
}

View File

@ -14,6 +14,7 @@ type ServiceSolutionCase struct {
// ServiceSolutionCaseInfo 服务案例信息 // ServiceSolutionCaseInfo 服务案例信息
type ServiceSolutionCaseInfo struct { type ServiceSolutionCaseInfo struct {
model.Model model.Model
model.ModelTenant
Title string `json:"title"` Title string `json:"title"`
model.Image model.Image
Description string `json:"description"` Description string `json:"description"`
@ -26,7 +27,7 @@ type ServiceSolutionCaseInfo struct {
// SolutionCase 案例信息 // SolutionCase 案例信息
func (m *ServiceSolutionCase) SolutionCase(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ServiceSolutionCaseInfo, error) { func (m *ServiceSolutionCase) SolutionCase(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ServiceSolutionCaseInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS s"). db := orm.GetDB().Table(m.TableName()+" AS s").
Select("s.id", "s.title", "s.image", "s.description", "s.visits", "k.title AS kind_title", "s.created_at", Select("s.id", "s.tenant_id", "s.title", "s.image", "s.description", "s.visits", "k.title AS kind_title", "s.created_at",
"t.province", "t.city"). "t.province", "t.city").
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON s.tenant_id = t.id", model.NewSysTenant().TableName())). Joins(fmt.Sprintf("LEFT JOIN %s AS t ON s.tenant_id = t.id", model.NewSysTenant().TableName())).
Joins(fmt.Sprintf("LEFT JOIN %s AS k ON s.kind_id = k.id", model.NewServiceSolutionCaseKind().TableName())). Joins(fmt.Sprintf("LEFT JOIN %s AS k ON s.kind_id = k.id", model.NewServiceSolutionCaseKind().TableName())).

View File

@ -21,6 +21,6 @@ func (*Message) Launch(c *gin.Context) {
api.APIFailure(err.(error))(c) api.APIFailure(err.(error))(c)
return return
} }
err := controller.NewMessage()().Form(form.Name, form.Mobile, form.Email, form.Company, form.Content) err := controller.NewMessage()(api.GetTenantID()(c).(uint64)).Form(form.Name, form.Mobile, form.Email, form.Company, form.Content)
api.APIResponse(err)(c) api.APIResponse(err)(c)
} }

View File

@ -5,23 +5,28 @@ import (
model2 "SciencesServer/app/common/model" model2 "SciencesServer/app/common/model"
) )
type Message struct{} // Message 信息管理
type Message struct {
tenantID uint64
}
type MessageHandle func() *Message type MessageHandle func(tenantID uint64) *Message
// Form 留言发起 // Form 留言发起
func (c *Message) Form(name, mobile, email, company, content string) error { func (c *Message) Form(name, mobile, email, company, content string) error {
mServiceMessage := model.NewServiceMessage() mServiceMessage := model.NewServiceMessage()
mServiceMessage.TenantID = c.tenantID
mServiceMessage.Name = name mServiceMessage.Name = name
mServiceMessage.Mobile = mobile mServiceMessage.Mobile = mobile
mServiceMessage.Email = email mServiceMessage.Email = email
mServiceMessage.Company = company mServiceMessage.Company = company
mServiceMessage.Content = content mServiceMessage.Content = content
mServiceMessage.Status = model2.ServiceMessageStatusForProcessing
return model2.Create(mServiceMessage.ServiceMessage) return model2.Create(mServiceMessage.ServiceMessage)
} }
func NewMessage() MessageHandle { func NewMessage() MessageHandle {
return func() *Message { return func(tenantID uint64) *Message {
return &Message{} return &Message{tenantID: tenantID}
} }
} }

View File

@ -21,6 +21,8 @@ type synchronized struct {
} }
func (this *Instance) Handle() { func (this *Instance) Handle() {
fmt.Println("========================\n=== 数据开始迁移 ===\n========================")
db := this.gormDB db := this.gormDB
successCount, failureCount := 0, 0 successCount, failureCount := 0, 0
@ -136,17 +138,16 @@ func (this *Instance) Handle() {
&synchronized{iModel: model.NewTechnologyAchievement()}, &synchronized{iModel: model.NewTechnologyDemand()}, &synchronized{iModel: model.NewTechnologyAchievement()}, &synchronized{iModel: model.NewTechnologyDemand()},
&synchronized{iModel: model.NewTechnologyPaper()}, &synchronized{iModel: model.NewTechnologyProduct()}, &synchronized{iModel: model.NewTechnologyPaper()}, &synchronized{iModel: model.NewTechnologyProduct()},
&synchronized{iModel: model.NewTechnologyProject()}, &synchronized{iModel: model.NewTechnologyTopic()}, &synchronized{iModel: model.NewTechnologyProject()}, &synchronized{iModel: model.NewTechnologyTopic()},
&synchronized{iModel: model.NewServiceDocking()}, &synchronized{iModel: model.NewServiceMessage()}, &synchronized{iModel: model.NewServiceDocking()},
&synchronized{iModel: model.NewServiceMessage()}, &synchronized{iModel: model.NewServiceMessageLog()},
&synchronized{iModel: model.NewServiceSolutionCase()}, &synchronized{iModel: model.NewServiceSolutionCaseKind()}, &synchronized{iModel: model.NewServiceSolutionCase()}, &synchronized{iModel: model.NewServiceSolutionCaseKind()},
&synchronized{iModel: model.NewServiceInnovate()}, &synchronized{iModel: model.NewServiceInnovateKind()}, &synchronized{iModel: model.NewServiceInnovate()}, &synchronized{iModel: model.NewServiceInnovateKind()},
// 活动管理 // 活动管理
&synchronized{iModel: model.NewActivityInstance()}, &synchronized{iModel: model.NewActivityApply()}, &synchronized{iModel: model.NewActivityInstance()}, &synchronized{iModel: model.NewActivityApply()},
&synchronized{iModel: model.NewActivityExamine()}, &synchronized{iModel: model.NewActivityJoin()}, &synchronized{iModel: model.NewActivityExamine()}, &synchronized{iModel: model.NewActivityJoin()},
) )
fmt.Println("=== 数据开始迁移 ===") fmt.Printf("========================\n=== 数据完成迁移,成功【%d】失败【%d】 ===\n========================\n",
fmt.Printf("=== 成功【%d】 ===\n", successCount) successCount, failureCount)
fmt.Printf("=== 失败【%d】 ===\n", failureCount)
fmt.Println("=== 数据完成迁移 ===")
} }
func WithGormDBOption(db *gorm.DB) Option { func WithGormDBOption(db *gorm.DB) Option {

View File

@ -80,6 +80,13 @@ func (m *Model) GetEncodeID() string {
return utils.HASHIDEncode(int(m.ID)) return utils.HASHIDEncode(int(m.ID))
} }
func (m *ModelTenant) GetEncodeTenantID() string {
if m.TenantID <= 0 {
return ""
}
return utils.HASHIDEncode(int(m.TenantID))
}
func (m *Model) SetDatabase(database string, key ...string) { func (m *Model) SetDatabase(database string, key ...string) {
m.Database = database + "_" + strings.Join(key, "_") m.Database = database + "_" + strings.Join(key, "_")
} }

View File

@ -3,12 +3,13 @@ package model
// ServiceMessage 留言数据模型 // ServiceMessage 留言数据模型
type ServiceMessage struct { type ServiceMessage struct {
Model Model
Name string `gorm:"column:name;type:varchar(20);default:'';comment:联系人" json:"name"` ModelTenant
Mobile string `gorm:"column:mobile;type:varchar(15);default:'';comment:联系方式" json:"mobile"` Name string `gorm:"column:name;type:varchar(20);default:'';comment:联系" json:"name"`
Email string `gorm:"column:email;type:varchar(50);default:'';comment:邮箱" json:"email"` Mobile string `gorm:"column:mobile;type:varchar(15);default:'';comment:联系方式" json:"mobile"`
Company string `gorm:"column:company;type:varchar(100);default:'';comment:公司名称" json:"company"` Email string `gorm:"column:email;type:varchar(50);default:'';comment:邮箱" json:"email"`
Content string `gorm:"column:content;type:varchar(255);default:'';comment:联系内容" json:"content"` Company string `gorm:"column:company;type:varchar(100);default:'';comment:公司名称" json:"company"`
Status int `gorm:"column:status;type:tinyint(1);default:0;comment:状态" json:"status"` Content string `gorm:"column:content;type:varchar(255);default:'';comment:联系内容" json:"content"`
Status ServiceMessageStatus `gorm:"column:status;type:tinyint(1);default:0;comment:状态" json:"status"`
ModelDeleted ModelDeleted
ModelAt ModelAt
} }
@ -18,7 +19,7 @@ type ServiceMessageStatus int
const ( const (
// ServiceMessageStatusForProcessing 处理中 // ServiceMessageStatusForProcessing 处理中
ServiceMessageStatusForProcessing ServiceMessageStatus = iota ServiceMessageStatusForProcessing ServiceMessageStatus = iota + 1
// ServiceMessageStatusForProcessed 已处理 // ServiceMessageStatusForProcessed 已处理
ServiceMessageStatusForProcessed ServiceMessageStatusForProcessed
) )

View File

@ -0,0 +1,19 @@
package model
// ServiceMessageLog 留言数据日志模型
type ServiceMessageLog struct {
Model
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户ID" json:"-"`
MessageID uint64 `gorm:"column:message_id;type:int(11);default:0;comment:信息ID" json:"-"`
Content string `gorm:"column:content;type:varchar(255);default:'';comment:内容信息" json:"-"`
ModelDeleted
ModelAt
}
func (m *ServiceMessageLog) TableName() string {
return "service_message_log"
}
func NewServiceMessageLog() *ServiceMessageLog {
return &ServiceMessageLog{}
}

View File

@ -34,11 +34,11 @@ func (m *ServiceSolutionCaseKind) ModeTitle() string {
if m.Mode == ServiceSolutionCaseModeForSmallCompany { if m.Mode == ServiceSolutionCaseModeForSmallCompany {
return "中小型企业" return "中小型企业"
} else if m.Mode == ServiceSolutionCaseModeForBigCompany { } else if m.Mode == ServiceSolutionCaseModeForBigCompany {
return "中小型企业" return "型企业"
} else if m.Mode == ServiceSolutionCaseModeForGovernment { } else if m.Mode == ServiceSolutionCaseModeForGovernment {
return "政府单位"
} else if m.Mode == ServiceSolutionCaseModeForResearch { } else if m.Mode == ServiceSolutionCaseModeForResearch {
return "科研机构"
} }
return "" return ""
} }

View File

@ -8,6 +8,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"os" "os"
"time"
) )
type Config struct { type Config struct {
@ -76,7 +77,12 @@ func run() {
orm.WithSqliteOption(&logic.Sqlite{Path: _sqlite.Path, Name: _sqlite.Name}), orm.WithSqliteOption(&logic.Sqlite{Path: _sqlite.Path, Name: _sqlite.Name}),
).Init() ).Init()
time.Sleep(1 * time.Second)
fmt.Println("========================\n=== 数据引擎创建成功 ===\n========================") fmt.Println("========================\n=== 数据引擎创建成功 ===\n========================")
time.Sleep(1 * time.Second)
// 迁移数据 // 迁移数据
migrate.NewInstance(migrate.WithGormDBOption(engine.Engine)).Handle() migrate.NewInstance(migrate.WithGormDBOption(engine.Engine)).Handle()
@ -94,7 +100,9 @@ func run() {
fmt.Errorf("数据初始化文件错误:%v", err) fmt.Errorf("数据初始化文件错误:%v", err)
return return
} }
fmt.Println("========================\n=== 数据初始化成功 ===\n========================") time.Sleep(1 * time.Second)
fmt.Println("========================\n=== 数据初始化完成 ===\n========================")
} }
func saveFile(_file string, data *Config) error { func saveFile(_file string, data *Config) error {

View File

@ -263,6 +263,8 @@ func registerAdminAPI(app *gin.Engine) {
service.POST("/solution_case/kind/add", _api.SolutionCaseKindForm) service.POST("/solution_case/kind/add", _api.SolutionCaseKindForm)
service.POST("/solution_case/kind/edit", _api.SolutionCaseKindForm) service.POST("/solution_case/kind/edit", _api.SolutionCaseKindForm)
service.POST("/solution_case/kind/delete", _api.SolutionCaseKindDelete) service.POST("/solution_case/kind/delete", _api.SolutionCaseKindDelete)
service.POST("/message", _api.Message)
service.POST("/message/handle", _api.MessageHandle)
} }
// Logs 日志管理 // Logs 日志管理
log := v1.Group("/log") log := v1.Group("/log")