feat:完善企业信息
This commit is contained in:
@ -503,6 +503,20 @@ func (*Technology) Product(c *gin.Context) {
|
|||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Technology) ProductVisit(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
api.IDStringForm
|
||||||
|
api.PageForm
|
||||||
|
}{}
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||||
|
Visit(form.Convert(), form.Page, form.PageSize)
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
|
||||||
func (*Technology) ProductAdd(c *gin.Context) {
|
func (*Technology) ProductAdd(c *gin.Context) {
|
||||||
form := new(productForm)
|
form := new(productForm)
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ type CompanyHandle func(session *session.Enterprise, local string) *Company
|
|||||||
type CompanyInfo struct {
|
type CompanyInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
*model2.ManageCompany
|
*model2.ManageCompany
|
||||||
Kinds []int `json:"kinds"`
|
|
||||||
Industry []string `json:"industrys"`
|
Industry []string `json:"industrys"`
|
||||||
Keywords []string `json:"keywords"`
|
Keywords []string `json:"keywords"`
|
||||||
}
|
}
|
||||||
@ -46,7 +45,6 @@ func (c *Company) Get(code string) (*CompanyInfo, error) {
|
|||||||
return &CompanyInfo{
|
return &CompanyInfo{
|
||||||
ID: mManageCompany.GetEncodeID(),
|
ID: mManageCompany.GetEncodeID(),
|
||||||
ManageCompany: mManageCompany.ManageCompany,
|
ManageCompany: mManageCompany.ManageCompany,
|
||||||
Kinds: mManageCompany.GetKindAttribute(),
|
|
||||||
Industry: mManageCompany.GetIndustryAttribute(),
|
Industry: mManageCompany.GetIndustryAttribute(),
|
||||||
Keywords: mManageCompany.GetKeywordAttribute(),
|
Keywords: mManageCompany.GetKeywordAttribute(),
|
||||||
}, nil
|
}, nil
|
||||||
@ -84,7 +82,7 @@ func (c *Company) Launch(params *BasicParams, inviterID uint64, other *config.Id
|
|||||||
}
|
}
|
||||||
mManageCompany.Local.Local = c.local
|
mManageCompany.Local.Local = c.local
|
||||||
mManageCompany.InviterID = inviterID
|
mManageCompany.InviterID = inviterID
|
||||||
mManageCompany.SetKindAttribute(other.Kinds)
|
mManageCompany.Kind = model2.ManageCompanyKind(other.Kind)
|
||||||
mManageCompany.Name = params.Name
|
mManageCompany.Name = params.Name
|
||||||
mManageCompany.Code = params.Code
|
mManageCompany.Code = params.Code
|
||||||
mManageCompany.Image = model2.Image{Image: params.Image}
|
mManageCompany.Image = model2.Image{Image: params.Image}
|
||||||
|
@ -3,8 +3,10 @@ package technology
|
|||||||
import (
|
import (
|
||||||
"SciencesServer/app/api/enterprise/model"
|
"SciencesServer/app/api/enterprise/model"
|
||||||
"SciencesServer/app/basic/config"
|
"SciencesServer/app/basic/config"
|
||||||
|
"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"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -30,6 +32,12 @@ type (
|
|||||||
Customers []string `json:"customers"`
|
Customers []string `json:"customers"`
|
||||||
Keywords []string `json:"keywords"`
|
Keywords []string `json:"keywords"`
|
||||||
}
|
}
|
||||||
|
// ProductVisitInfo 产品浏览信息
|
||||||
|
ProductVisitInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
*model.TechnologyProductVisitInfo
|
||||||
|
CompanyKeywords []string `json:"company_keywords"`
|
||||||
|
}
|
||||||
// ProductParams 产品参数信息
|
// ProductParams 产品参数信息
|
||||||
ProductParams struct {
|
ProductParams struct {
|
||||||
ID uint64
|
ID uint64
|
||||||
@ -105,10 +113,36 @@ func (c *Product) Match(id uint64) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Product) Visit(id uint64, page, pageSize int) {
|
// Visit 访问信息
|
||||||
|
func (c *Product) Visit(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
mTechnologyProductVisit := model.NewTechnologyProductVisit()
|
mTechnologyProductVisit := model.NewTechnologyProductVisit()
|
||||||
|
|
||||||
|
where := []*model2.ModelWhere{
|
||||||
|
model2.NewWhere("product_id", id),
|
||||||
|
}
|
||||||
var count int64
|
var count int64
|
||||||
mTechnologyProductVisit.Visit(page, pageSize, &count)
|
|
||||||
|
out, err := mTechnologyProductVisit.Visit(page, pageSize, &count, where...)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*ProductVisitInfo, 0)
|
||||||
|
|
||||||
|
mManageCompany := model.NewManageCompany()
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
mManageCompany.Keyword = v.CompanyKeyword
|
||||||
|
mManageCompany.Image.Image = v.CompanyImage
|
||||||
|
v.CompanyImage = mManageCompany.Image.Analysis(config2.SettingInfo.Domain)
|
||||||
|
|
||||||
|
list = append(list, &ProductVisitInfo{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
TechnologyProductVisitInfo: v,
|
||||||
|
CompanyKeywords: mManageCompany.GetKeywordAttribute(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Form 数据操作
|
// Form 数据操作
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"SciencesServer/app/common/model"
|
"SciencesServer/app/common/model"
|
||||||
"SciencesServer/serve/orm"
|
"SciencesServer/serve/orm"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TechnologyProductVisit struct {
|
type TechnologyProductVisit struct {
|
||||||
@ -11,11 +12,15 @@ type TechnologyProductVisit struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TechnologyProductVisitInfo struct {
|
type TechnologyProductVisitInfo struct {
|
||||||
|
model.Model
|
||||||
|
VisitAt time.Time `json:"visit_at"`
|
||||||
|
model.ManageCompanyBasic
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *TechnologyProductVisit) Visit(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyProductVisitInfo, error) {
|
func (m *TechnologyProductVisit) Visit(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyProductVisitInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS v").
|
db := orm.GetDB().Table(m.TableName()+" AS v").
|
||||||
Select("v.id").
|
Select("v.id", "v.visit_at", "c.id AS company_id", "c.name AS company_name", "c.image AS company_image",
|
||||||
|
"c.kind AS company_kind", "c.url AS company_url").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON v.company_id = c.id", model.NewManageCompany().TableName())).
|
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON v.company_id = c.id", model.NewManageCompany().TableName())).
|
||||||
Where("v.is_deleted = ?", model.DeleteStatusForNot)
|
Where("v.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
@ -11,10 +11,10 @@ type Area struct {
|
|||||||
type (
|
type (
|
||||||
// IdentityForCompany 公司附加信息
|
// IdentityForCompany 公司附加信息
|
||||||
IdentityForCompany struct {
|
IdentityForCompany struct {
|
||||||
Kinds []int `json:"kinds" form:"kinds"`
|
Kind int `json:"kind" form:"kind" binding:"required"` // 企业类型
|
||||||
Product string `json:"product" form:"product" binding:"required"`
|
Product string `json:"product" form:"product" binding:"required"` // 企业产品
|
||||||
Url string `json:"url" form:"url"` // 企业网站
|
Url string `json:"url" form:"url"` // 企业网站
|
||||||
License string `json:"license" form:"license" binding:"required"`
|
License string `json:"license" form:"license" binding:"required"` // 营业执照
|
||||||
}
|
}
|
||||||
// IdentityForExpert 专家附加信息
|
// IdentityForExpert 专家附加信息
|
||||||
IdentityForExpert struct {
|
IdentityForExpert struct {
|
||||||
|
@ -6,10 +6,10 @@ import "SciencesServer/utils"
|
|||||||
type ManageCompany struct {
|
type ManageCompany struct {
|
||||||
Model
|
Model
|
||||||
Local
|
Local
|
||||||
InviterID uint64 `gorm:"column:inviter_id;type:int;default:0;comment:邀请人ID" json:"inviter_id"`
|
InviterID uint64 `gorm:"column:inviter_id;type:int;default:0;comment:邀请人ID" json:"inviter_id"`
|
||||||
Kind string `gorm:"column:kind;type:varchar(255);default:'';comment:类型" json:"kind"`
|
Kind ManageCompanyKind `gorm:"column:kind;type:tinyint(1);default:0;comment:企业类型" json:"kind"`
|
||||||
Name string `gorm:"column:name;type:varchar(30);default:'';comment:名称" json:"name"`
|
Name string `gorm:"column:name;type:varchar(30);default:'';comment:企业名称" json:"name"`
|
||||||
Code string `gorm:"column:code;type:varchar(30);default:'';comment:信用代码" json:"code"`
|
Code string `gorm:"column:code;type:varchar(30);default:'';comment:信用代码" json:"code"`
|
||||||
Image
|
Image
|
||||||
Area
|
Area
|
||||||
Product string `gorm:"column:product;type:varchar(255);default:'';comment:产品信息" json:"product"`
|
Product string `gorm:"column:product;type:varchar(255);default:'';comment:产品信息" json:"product"`
|
||||||
@ -23,6 +23,16 @@ type ManageCompany struct {
|
|||||||
ModelAt
|
ModelAt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ManageCompanyBasic 公司信息
|
||||||
|
type ManageCompanyBasic struct {
|
||||||
|
CompanyID uint64 `json:"company_id"`
|
||||||
|
CompanyKind ManageCompanyKind `json:"company_kind"`
|
||||||
|
CompanyName string `json:"company_name"`
|
||||||
|
CompanyImage string `json:"company_image"`
|
||||||
|
CompanyUrl string `json:"company_url"`
|
||||||
|
CompanyKeyword string `json:"company_keyword"`
|
||||||
|
}
|
||||||
|
|
||||||
type ManageCompanyKind int
|
type ManageCompanyKind int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -33,16 +43,6 @@ func (m *ManageCompany) TableName() string {
|
|||||||
return "manage_company"
|
return "manage_company"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ManageCompany) GetKindAttribute() []int {
|
|
||||||
out := make([]int, 0)
|
|
||||||
_ = utils.FromJSON(m.Industry, &out)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *ManageCompany) SetKindAttribute(value []int) {
|
|
||||||
m.Industry = utils.AnyToJSON(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *ManageCompany) GetIndustryAttribute() []string {
|
func (m *ManageCompany) GetIndustryAttribute() []string {
|
||||||
out := make([]string, 0)
|
out := make([]string, 0)
|
||||||
_ = utils.FromJSON(m.Industry, &out)
|
_ = utils.FromJSON(m.Industry, &out)
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
// TechnologyProductVisit 技术产品访问数据模型
|
// TechnologyProductVisit 技术产品访问数据模型
|
||||||
type TechnologyProductVisit struct {
|
type TechnologyProductVisit struct {
|
||||||
Model
|
Model
|
||||||
ProductID uint64 `gorm:"column:product_id;type:int(11);default:0;comment:科技产品ID" json:"product_id"`
|
ProductID uint64 `gorm:"column:product_id;index:idx_product_visit_product;type:int(11);default:0;comment:科技产品ID" json:"product_id"`
|
||||||
CompanyID uint64 `gorm:"column:company_id;type:int(11);default:0;comment:公司ID" json:"company_id"`
|
CompanyID uint64 `gorm:"column:company_id;type:int(11);default:0;comment:公司ID" json:"company_id"`
|
||||||
|
VisitAt time.Time `gorm:"column:visit_at;type:datetime;not null;comment:浏览时间" json:"visit_at"`
|
||||||
ModelDeleted
|
ModelDeleted
|
||||||
ModelAt
|
ModelAt
|
||||||
}
|
}
|
||||||
|
@ -202,6 +202,7 @@ func registerEnterpriseAPI(app *gin.Engine) {
|
|||||||
technologyV1.POST("/topic/edit", _api.TopicEdit)
|
technologyV1.POST("/topic/edit", _api.TopicEdit)
|
||||||
technologyV1.POST("/topic/delete", _api.TopicDelete)
|
technologyV1.POST("/topic/delete", _api.TopicDelete)
|
||||||
technologyV1.POST("/product", _api.Product)
|
technologyV1.POST("/product", _api.Product)
|
||||||
|
technologyV1.POST("/product/visit", _api.ProductVisit)
|
||||||
technologyV1.POST("/product/add", _api.ProductAdd)
|
technologyV1.POST("/product/add", _api.ProductAdd)
|
||||||
technologyV1.POST("/product/edit", _api.ProductEdit)
|
technologyV1.POST("/product/edit", _api.ProductEdit)
|
||||||
technologyV1.POST("/product/shelf", _api.ProductShelf)
|
technologyV1.POST("/product/shelf", _api.ProductShelf)
|
||||||
|
Reference in New Issue
Block a user