feat:完善网站信息
This commit is contained in:
40
app/api/website/api/es.go
Normal file
40
app/api/website/api/es.go
Normal file
@ -0,0 +1,40 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/app/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ES struct{}
|
||||
|
||||
func (*ES) Create(c *gin.Context) {
|
||||
form := &struct {
|
||||
ID uint64 `json:"id" form:"id"`
|
||||
Title string `json:"title" form:"title"`
|
||||
Keyword string `json:"keyword" form:"keyword"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
manage := service.NewManage(
|
||||
service.WithManageID(form.ID),
|
||||
service.WithManageTitle(form.Title),
|
||||
service.WithManageKeyword(form.Keyword),
|
||||
)
|
||||
api.APIResponse(manage.Create())(c)
|
||||
}
|
||||
|
||||
func (*ES) Search(c *gin.Context) {
|
||||
form := &struct {
|
||||
Params map[string]interface{} `json:"params" form:"params"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
manage := service.NewManage()
|
||||
data, err := manage.Search(form.Params)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
62
app/api/website/api/technology.go
Normal file
62
app/api/website/api/technology.go
Normal file
@ -0,0 +1,62 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/controller/technology"
|
||||
"SciencesServer/app/basic/api"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Technology struct{}
|
||||
|
||||
func (*Technology) Patent(c *gin.Context) {
|
||||
form := &struct {
|
||||
Title string `json:"title" form:"title"`
|
||||
Industry string `json:"industry" form:"industry"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := technology.NewPatent()().Instance(form.Title, form.Industry, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Technology) PatentDetail(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := technology.NewPatent()().Detail(form.Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Technology) Demand(c *gin.Context) {
|
||||
form := &struct {
|
||||
Title string `json:"title" form:"title"`
|
||||
Industry string `json:"industry" form:"industry"`
|
||||
Kind string `json:"kind" form:"kind"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := technology.NewDemand()(nil).Instance(form.Title, form.Industry, form.Kind, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Technology) DemandDetail(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := technology.NewDemand()(nil).Detail(form.Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
121
app/api/website/controller/manage/search.go
Normal file
121
app/api/website/controller/manage/search.go
Normal file
@ -0,0 +1,121 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Search struct{}
|
||||
|
||||
type SearchHandle func() *Search
|
||||
|
||||
type (
|
||||
// SearchParams 搜索参数
|
||||
SearchParams struct {
|
||||
}
|
||||
)
|
||||
|
||||
// searchIdentityHandle 搜索信息处理
|
||||
var searchIdentityHandle = map[int]func(ids []uint64) (interface{}, error){
|
||||
config.TenantUserIdentityForCompany: company,
|
||||
config.TenantUserIdentityForExpert: company,
|
||||
config.TenantUserIdentityForResearch: company,
|
||||
config.TenantUserIdentityForLaboratory: company,
|
||||
config.TenantUserIdentityForAgent: company,
|
||||
}
|
||||
|
||||
func company(ids []uint64) (interface{}, error) {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
out := make([]*model2.ManageCompany, 0)
|
||||
|
||||
if err := model2.ScanFields(mManageCompany.ManageCompany, &out, []string{}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereIn("id", ids),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree),
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func expert(ids []uint64) (interface{}, error) {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
out := make([]*model2.ManageCompany, 0)
|
||||
|
||||
if err := model2.ScanFields(mManageCompany.ManageCompany, &out, []string{}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereIn("id", ids),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree),
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func research(ids []uint64) (interface{}, error) {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
out := make([]*model2.ManageCompany, 0)
|
||||
|
||||
if err := model2.ScanFields(mManageCompany.ManageCompany, &out, []string{}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereIn("id", ids),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree),
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func laboratory(ids []uint64) (interface{}, error) {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
out := make([]*model2.ManageCompany, 0)
|
||||
|
||||
if err := model2.ScanFields(mManageCompany.ManageCompany, &out, []string{}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereIn("id", ids),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree),
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *Search) Launch(identity int, params string) (interface{}, error) {
|
||||
manage := service.NewManage()
|
||||
|
||||
_params := map[string]interface{}{
|
||||
"title": params, "keyword": params, "research": params,
|
||||
}
|
||||
data, err := manage.Search(_params)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ids := make([]uint64, 0)
|
||||
|
||||
for _, v := range data.([]*service.Manage) {
|
||||
if v.Identity != identity {
|
||||
continue
|
||||
}
|
||||
ids = append(ids, v.ID)
|
||||
}
|
||||
handle, has := searchIdentityHandle[identity]
|
||||
|
||||
if !has {
|
||||
return nil, errors.New("操作错误,未知的身份信息")
|
||||
}
|
||||
return handle(ids)
|
||||
}
|
||||
|
||||
func NewSearch() SearchHandle {
|
||||
return func() *Search {
|
||||
return &Search{}
|
||||
}
|
||||
}
|
100
app/api/website/controller/technology/demand.go
Normal file
100
app/api/website/controller/technology/demand.go
Normal file
@ -0,0 +1,100 @@
|
||||
package technology
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/model"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Demand struct {
|
||||
*session.Enterprise
|
||||
}
|
||||
|
||||
type DemandHandle func(session *session.Enterprise) *Demand
|
||||
|
||||
type (
|
||||
// DemandInfo 需求基本信息
|
||||
DemandInfo struct {
|
||||
ID string `json:"id"`
|
||||
Kinds []string `json:"kinds"`
|
||||
Industrys []string `json:"industrys"`
|
||||
Deadline time.Time `json:"deadline"`
|
||||
}
|
||||
// DemandDetailInfo 需求详细信息
|
||||
DemandDetailInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.TechnologyDemand
|
||||
Kinds []string `json:"kinds"`
|
||||
Industrys []string `json:"industrys"`
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 需求信息
|
||||
func (c *Demand) Instance(title, industry, kind string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mTechnologyDemand := model.NewTechnologyDemand()
|
||||
|
||||
out := make([]*model2.TechnologyDemand, 0)
|
||||
|
||||
var count int64
|
||||
|
||||
where := []*model2.ModelWhereOrder{
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("status", model2.TechnologyDemandStatusForAgree),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
},
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhere("title", title)})
|
||||
}
|
||||
if industry != "" {
|
||||
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereCondition("industry", "LIKE",
|
||||
"%"+fmt.Sprintf(`"%v`, industry)+"%")})
|
||||
}
|
||||
if kind != "" {
|
||||
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereLike("kind", kind)})
|
||||
}
|
||||
err := model2.PagesFields(mTechnologyDemand.TechnologyDemand, &out, []string{}, page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*DemandInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &DemandInfo{
|
||||
ID: v.GetEncodeID(), Kinds: v.GetKindAttribute(),
|
||||
Industrys: v.GetIndustryAttribute(), Deadline: v.Deadline,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Demand) Detail(id uint64) (*DemandDetailInfo, error) {
|
||||
mTechnologyDemand := model.NewTechnologyDemand()
|
||||
mTechnologyDemand.ID = id
|
||||
|
||||
isExist, err := model2.First(mTechnologyDemand.TechnologyDemand)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,需求信息不存在或已被删除")
|
||||
}
|
||||
return &DemandDetailInfo{
|
||||
ID: mTechnologyDemand.GetEncodeID(),
|
||||
TechnologyDemand: mTechnologyDemand.TechnologyDemand,
|
||||
Kinds: mTechnologyDemand.GetKindAttribute(),
|
||||
Industrys: mTechnologyDemand.GetIndustryAttribute(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewDemand() DemandHandle {
|
||||
return func(session *session.Enterprise) *Demand {
|
||||
return &Demand{Enterprise: session}
|
||||
}
|
||||
}
|
78
app/api/website/controller/technology/patent.go
Normal file
78
app/api/website/controller/technology/patent.go
Normal file
@ -0,0 +1,78 @@
|
||||
package technology
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/model"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Patent struct{}
|
||||
|
||||
type PatentHandle func() *Patent
|
||||
|
||||
type (
|
||||
// PatentInfo 专利信息
|
||||
PatentInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.SysPatentInfo
|
||||
}
|
||||
// PatentDetailInfo 专利详细信息
|
||||
PatentDetailInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.SysPatent
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 查询信息
|
||||
func (c *Patent) Instance(title, industry string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("p.title", title))
|
||||
}
|
||||
if industry != "" {
|
||||
where = append(where, model2.NewWhereCondition("c.industry_detail", "LIKE",
|
||||
"%"+fmt.Sprintf(`"%v`, industry)+"%"))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mSysPatent.Patent(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*PatentInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &PatentInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
SysPatentInfo: v,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Patent) Detail(id uint64) (*PatentDetailInfo, error) {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mSysPatent.ID = id
|
||||
|
||||
isExist, err := model2.First(mSysPatent.SysPatent)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,专利信息不存在或已被删除")
|
||||
}
|
||||
return &PatentDetailInfo{ID: mSysPatent.GetEncodeID(), SysPatent: mSysPatent.SysPatent}, nil
|
||||
}
|
||||
|
||||
func NewPatent() PatentHandle {
|
||||
return func() *Patent {
|
||||
return &Patent{}
|
||||
}
|
||||
}
|
@ -10,6 +10,40 @@ type SysPatent struct {
|
||||
*model.SysPatent
|
||||
}
|
||||
|
||||
type SysPatentInfo struct {
|
||||
model.Model
|
||||
Kind model.SysParentKind `json:"kind"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
ApplyAt string `json:"apply_at"`
|
||||
}
|
||||
|
||||
// Patent 专利信息
|
||||
func (m *SysPatent) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS p").
|
||||
Select("p.id", "p.title", "LEFT(p.description, 80) AS description", "p.apply_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON p.ipc_code = c.ipc AND c.is_deleted = %d",
|
||||
model.NewSysPatentClassify().TableName(), model.DeleteStatusForNot)).
|
||||
Where("p.shelf_status = ?", model.ShelfStatusForUp).
|
||||
Where("p.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*SysPatentInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := db.Order("p.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Distribution 分布信息
|
||||
func (m *SysPatent) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
out := make([]*DataAreaDistributionInfo, 0)
|
||||
|
Reference in New Issue
Block a user