feat:完善项目信息
This commit is contained in:
@ -10,7 +10,9 @@ func getSession(c *gin.Context) *session.Enterprise {
|
|||||||
value := api.GetSession()(c)
|
value := api.GetSession()(c)
|
||||||
|
|
||||||
if value != "" {
|
if value != "" {
|
||||||
return session.NewEnterprise()
|
_session := session.NewEnterprise()
|
||||||
|
_session.UID = 2108051846374363136
|
||||||
|
return _session
|
||||||
}
|
}
|
||||||
return value.(*session.Enterprise)
|
return value.(*session.Enterprise)
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,6 @@ type Docking struct{}
|
|||||||
|
|
||||||
// Launch 联系客服对接
|
// Launch 联系客服对接
|
||||||
func (*Docking) Launch(c *gin.Context) {
|
func (*Docking) Launch(c *gin.Context) {
|
||||||
err := controller.NewDocking()(nil).Form()
|
err := controller.NewDocking()(getSession(c), api.GetTenantID()(c).(uint64)).Form(c.ClientIP())
|
||||||
api.APIResponse(err)(c)
|
api.APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@ type User struct{}
|
|||||||
func (*User) Collect(c *gin.Context) {
|
func (*User) Collect(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
Kind int `json:"kind" form:"kind" binding:"required"`
|
Kind int `json:"kind" form:"kind" binding:"required"`
|
||||||
ObjectID uint64 `json:"object_id" form:"object_id" binding:"required"`
|
ObjectID string `json:"object_id" form:"object_id" binding:"required"`
|
||||||
}{}
|
}{}
|
||||||
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 := user.NewCollect()(nil).Launch(form.Kind, form.ObjectID)
|
data, err := user.NewCollect()(getSession(c)).Launch(form.Kind, (&api.IDStringForm{ID: form.ObjectID}).Convert())
|
||||||
api.APIResponse(err)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
@ -8,22 +8,23 @@ import (
|
|||||||
|
|
||||||
type Docking struct {
|
type Docking struct {
|
||||||
*session.Enterprise
|
*session.Enterprise
|
||||||
|
tenantID uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type DockingHandle func(session *session.Enterprise) *Docking
|
type DockingHandle func(session *session.Enterprise, tenantID uint64) *Docking
|
||||||
|
|
||||||
// Form 联系客服对接
|
// Form 联系客服对接
|
||||||
func (c *Docking) Form() error {
|
func (c *Docking) Form(ip string) error {
|
||||||
mServiceDocking := model.NewServiceDocking()
|
mServiceDocking := model.NewServiceDocking()
|
||||||
|
mServiceDocking.TenantID = c.tenantID
|
||||||
|
mServiceDocking.UID = c.UID
|
||||||
|
mServiceDocking.IP = ip
|
||||||
|
|
||||||
if c.Enterprise != nil {
|
|
||||||
mServiceDocking.UID = c.UID
|
|
||||||
}
|
|
||||||
return model2.Create(mServiceDocking.ServiceDocking)
|
return model2.Create(mServiceDocking.ServiceDocking)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDocking() DockingHandle {
|
func NewDocking() DockingHandle {
|
||||||
return func(session *session.Enterprise) *Docking {
|
return func(session *session.Enterprise, tenantID uint64) *Docking {
|
||||||
return &Docking{
|
return &Docking{
|
||||||
Enterprise: session,
|
Enterprise: session,
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ func (c *Company) Instance(id uint64) (*CompanyInstanceInfo, error) {
|
|||||||
ID: mManageCompany.GetEncodeID(), Kind: mManageCompany.Kind, Name: mManageCompany.Name,
|
ID: mManageCompany.GetEncodeID(), Kind: mManageCompany.Kind, Name: mManageCompany.Name,
|
||||||
Image: mManageCompany.Image.Analysis(config2.SystemConfig[config2.SysImageDomain]),
|
Image: mManageCompany.Image.Analysis(config2.SystemConfig[config2.SysImageDomain]),
|
||||||
Url: mManageCompany.Url,
|
Url: mManageCompany.Url,
|
||||||
|
Product: mManageCompany.Product,
|
||||||
Keywords: mManageCompany.GetKeywordAttribute(),
|
Keywords: mManageCompany.GetKeywordAttribute(),
|
||||||
},
|
},
|
||||||
KindTitle: mManageCompany.KindTitle(),
|
KindTitle: mManageCompany.KindTitle(),
|
||||||
@ -76,7 +77,7 @@ func (c *Company) Instance(id uint64) (*CompanyInstanceInfo, error) {
|
|||||||
func (c *Company) Product(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
func (c *Company) Product(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
mManageCompany := model.NewManageCompany()
|
mManageCompany := model.NewManageCompany()
|
||||||
var count int64
|
var count int64
|
||||||
out, err := mManageCompany.Product(id, c.UID, page, pageSize, &count)
|
out, err := mManageCompany.Products(id, c.UID, page, pageSize, &count)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -96,7 +97,7 @@ func (c *Company) Product(id uint64, page, pageSize int) (*controller.ReturnPage
|
|||||||
list = append(list, &CompanyProductInfo{
|
list = append(list, &CompanyProductInfo{
|
||||||
ManageCompanyProduct: v,
|
ManageCompanyProduct: v,
|
||||||
ID: v.GetEncodeID(),
|
ID: v.GetEncodeID(),
|
||||||
IsCollect: v.IsCollect > 0,
|
IsCollect: v.CollectID > 0,
|
||||||
LeadStandardTitle: v.GetLeadStandardTitle(),
|
LeadStandardTitle: v.GetLeadStandardTitle(),
|
||||||
MaturityTitle: config.GetTechnologyMaturityTitle(v.Maturity),
|
MaturityTitle: config.GetTechnologyMaturityTitle(v.Maturity),
|
||||||
CooperationModeTitle: config.GetTechnologyCooperationModeTitle(v.CooperationMode),
|
CooperationModeTitle: config.GetTechnologyCooperationModeTitle(v.CooperationMode),
|
||||||
|
@ -13,7 +13,7 @@ type Collect struct {
|
|||||||
type CollectHandle func(session *session.Enterprise) *Collect
|
type CollectHandle func(session *session.Enterprise) *Collect
|
||||||
|
|
||||||
// Launch 收藏发起
|
// Launch 收藏发起
|
||||||
func (c *Collect) Launch(kind int, objectID uint64) error {
|
func (c *Collect) Launch(kind int, objectID uint64) (bool, error) {
|
||||||
mUserCollect := model.NewUserCollect()
|
mUserCollect := model.NewUserCollect()
|
||||||
|
|
||||||
where := []*model2.ModelWhere{
|
where := []*model2.ModelWhere{
|
||||||
@ -24,15 +24,15 @@ func (c *Collect) Launch(kind int, objectID uint64) error {
|
|||||||
isExist, err := model2.FirstField(mUserCollect.UserCollect, []string{"id"}, where...)
|
isExist, err := model2.FirstField(mUserCollect.UserCollect, []string{"id"}, where...)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
if isExist {
|
if isExist {
|
||||||
return model2.Delete(mUserCollect.UserCollect)
|
return false, model2.Delete(mUserCollect.UserCollect)
|
||||||
}
|
}
|
||||||
mUserCollect.UID = c.UID
|
mUserCollect.UID = c.UID
|
||||||
mUserCollect.Kind = model2.UserCollectKind(kind)
|
mUserCollect.Kind = model2.UserCollectKind(kind)
|
||||||
mUserCollect.ObjectID = objectID
|
mUserCollect.ObjectID = objectID
|
||||||
return model2.Create(mUserCollect.UserCollect)
|
return true, model2.Create(mUserCollect.UserCollect)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCollect() CollectHandle {
|
func NewCollect() CollectHandle {
|
||||||
|
@ -14,17 +14,17 @@ type ManageCompany struct {
|
|||||||
type ManageCompanyProduct struct {
|
type ManageCompanyProduct struct {
|
||||||
*model.TechnologyProduct
|
*model.TechnologyProduct
|
||||||
VisitCount int `json:"visit_count"`
|
VisitCount int `json:"visit_count"`
|
||||||
IsCollect uint64 `json:"-"`
|
CollectID uint64 `json:"-"`
|
||||||
CollectCount int `json:"collect_count"`
|
CollectCount int `json:"collect_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Product 产品信息
|
// Products 产品信息
|
||||||
func (m *ManageCompany) Product(id, uid uint64, page, pageSize int, count *int64) ([]*ManageCompanyProduct, error) {
|
func (m *ManageCompany) Products(id, uid uint64, page, pageSize int, count *int64) ([]*ManageCompanyProduct, error) {
|
||||||
mNewUserCollect := model.NewUserCollect()
|
mNewUserCollect := model.NewUserCollect()
|
||||||
|
|
||||||
db := orm.GetDB().Table(model.NewUserCompany().TableName()+" u_c").
|
db := orm.GetDB().Table(model.NewUserCompany().TableName()+" u_c").
|
||||||
Select("p.id", "p.title", "p.image", "p.industry", "p.maturity", "p.lead_standard", "p.cooperation_mode",
|
Select("p.id", "p.title", "p.image", "p.industry", "p.maturity", "p.lead_standard", "p.cooperation_mode",
|
||||||
"p.keyword", "v.count AS visit_count", "c_u.id AS is_collect", "c.count AS collect_count").
|
"p.keyword", "v.count AS visit_count", "c_u.id AS collect_id", "c.count AS collect_count").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u_c.uid = p.uid AND p.shelf_status = %d AND p.status = %d AND p.is_deleted = %d",
|
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u_c.uid = p.uid AND p.shelf_status = %d AND p.status = %d AND p.is_deleted = %d",
|
||||||
model.NewTechnologyProduct().TableName(), model.ShelfStatusForUp, model.TechnologyProductStatusForAgree, model.DeleteStatusForNot)).
|
model.NewTechnologyProduct().TableName(), model.ShelfStatusForUp, model.TechnologyProductStatusForAgree, model.DeleteStatusForNot)).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON p.id = v.object_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON p.id = v.object_id",
|
||||||
|
@ -21,7 +21,7 @@ type IModel interface {
|
|||||||
|
|
||||||
// Model
|
// Model
|
||||||
type Model struct {
|
type Model struct {
|
||||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement;type:int(11);comment:主键" json:"-"`
|
ID uint64 `gorm:"column:id;primaryKey;autoIncrement;comment:主键" json:"-" form:"id"` // 主键
|
||||||
|
|
||||||
Database string `json:"-" gorm:"-"`
|
Database string `json:"-" gorm:"-"`
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,9 @@ package model
|
|||||||
// ServiceDocking 对接信息数据模型
|
// ServiceDocking 对接信息数据模型
|
||||||
type ServiceDocking struct {
|
type ServiceDocking struct {
|
||||||
Model
|
Model
|
||||||
|
ModelTenant
|
||||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||||
|
IP string `gorm:"column:ip;type:char(16);default:'';comment:IP地址" json:"ip"`
|
||||||
ModelDeleted
|
ModelDeleted
|
||||||
ModelAt
|
ModelAt
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ package model
|
|||||||
type UserCollect struct {
|
type UserCollect struct {
|
||||||
Model
|
Model
|
||||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||||
Kind UserCollectKind `gorm:"column:kind;type:tinyint(3);default:0;comment:收藏数据类型" json:"kind"`
|
Kind UserCollectKind `gorm:"column:kind;type:smallint(6);default:0;comment:收藏数据类型" json:"kind"`
|
||||||
ObjectID uint64 `gorm:"column:object_id;type:int(11);default:0;comment:收藏对象ID" json:"-"`
|
ObjectID uint64 `gorm:"column:object_id;type:int(11);default:0;comment:收藏对象ID" json:"-"`
|
||||||
ModelDeleted
|
ModelDeleted
|
||||||
ModelAt
|
ModelAt
|
||||||
@ -14,7 +14,7 @@ type UserCollectKind int
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// UserCollectKindForLaboratory 实验室
|
// UserCollectKindForLaboratory 实验室
|
||||||
UserCollectKindForLaboratory UserCollectKind = iota + 1
|
UserCollectKindForLaboratory UserCollectKind = iota + 1001
|
||||||
// UserCollectKindForExpert 专家
|
// UserCollectKindForExpert 专家
|
||||||
UserCollectKindForExpert
|
UserCollectKindForExpert
|
||||||
// UserCollectKindForCompany 公司
|
// UserCollectKindForCompany 公司
|
||||||
|
23
app/event/visit.go
Normal file
23
app/event/visit.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package event
|
||||||
|
|
||||||
|
// Visit 浏览事件数据处理
|
||||||
|
type Visit struct{}
|
||||||
|
|
||||||
|
// Handle 操作处理
|
||||||
|
// @
|
||||||
|
func (this *Visit) Handle(arg ...interface{}) {
|
||||||
|
//&model.UserVisit{
|
||||||
|
// Model: model.Model{},
|
||||||
|
// UID: 0,
|
||||||
|
// Kind: 0,
|
||||||
|
// ObjectID: 0,
|
||||||
|
// Count: 0,
|
||||||
|
// Date: time.Time{},
|
||||||
|
// ModelDeleted: model.ModelDeleted{},
|
||||||
|
// ModelAt: model.ModelAt{},
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewVisit() *Visit {
|
||||||
|
return &Visit{}
|
||||||
|
}
|
Reference in New Issue
Block a user