master
howell 4 years ago
parent a18462f5db
commit 1910a59f3f

@ -59,7 +59,9 @@ func (o logic) List(args ArgsCompanyList) (res []company.Info, total int64, err
}
}
query.Count(&total)
query.Preload(clause.Associations).Preload("Logs.ManageUserInfo").Offset(args.GetStart()).Limit(args.GetLimit()).Find(&res)
query.Preload("Logs.ManageUserInfo").
Preload(clause.Associations).
Offset(args.GetStart()).Limit(args.GetLimit()).Find(&res)
for i, v := range res {
var u1 user.RecookUserInfoModel
mysql.Db.First(&u1, "id = ?", v.UserID)
@ -179,7 +181,7 @@ func (o logic) All() (res []string) {
}
type CompanySureApply struct {
ID uint `json:"id" validate:"required`
ID uint `json:"id" validate:"required"`
UserID uint `json:"-"`
}

@ -1,10 +1,11 @@
package company
import (
"fmt"
"recook/internal/v2/model/recook/manage"
"github.com/golangkit/formatime"
"github.com/jinzhu/gorm"
"gorm.io/gorm"
)
type State uint
@ -86,7 +87,8 @@ func (o *Info) TableName() string {
return "jyy_company_info"
}
func (o *Info) AfterFind(db *gorm.DB) error {
func (o *Info) AfterFind(tx *gorm.DB) error {
fmt.Println(123)
o.ProcessUserName = o.ProcessUserInfo.Name
o.ApplyUserName = o.ApplyUserInfo.Name
o.StateStr = o.State.Str()
@ -98,17 +100,17 @@ type Log struct {
ID uint `json:"id"`
Text string `json:"text"`
UserID uint `json:"-"`
ManageUserInfo manage.RecookManageUserInfoModel `json:"-" gorm:"foreignKey:user_id"`
ManageUserInfo manage.RecookManageUserInfoModel `json:"-" gorm:"references:user_id;foreignKey:id"`
ManageUserName string `json:"manage_user_name" gorm:"-"`
CreatedAt formatime.Second `json:"created_at"`
CompanyID uint `json:"company_i"`
CompanyID uint `json:"company_id"`
}
func (o Log) TableName() string {
return "jyy_company_log"
}
func (o *Log) AfterFind(db *gorm.DB) error {
func (o *Log) AfterFind(tx *gorm.DB) error {
o.ManageUserName = o.ManageUserInfo.Name
return nil
}

@ -772,7 +772,7 @@ func routerManage(manageRouter *gin.RouterGroup) {
}
{
companyRouter := manageRouter.Group("company", authorize)
companyRouter := manageRouter.Group("company")
{
proxy := company.Proxy{}
{

Loading…
Cancel
Save