feat:完善信息

This commit is contained in:
henry
2021-10-15 15:06:02 +08:00
parent af8691e943
commit ae9fb8ea0f
86 changed files with 215 additions and 216 deletions

View File

@ -0,0 +1,188 @@
package technology
import (
"SciencesServer/app/api/enterprise/model"
"SciencesServer/app/api/manage/controller"
"SciencesServer/app/basic/config"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
"SciencesServer/utils"
"errors"
"time"
)
// Demand 技术需求管理
type Demand struct {
*service.SessionEnterprise
local string
}
type DemandHandle func(enterprise *service.SessionEnterprise, local string) *Demand
type (
// DemandInfo 需求信息
DemandInfo struct {
ID string `json:"id"`
Title string `json:"title"`
Name string `json:"name"`
Mobile string `json:"mobile"`
Kinds []string `json:"kinds"`
Budget float64 `json:"budget"`
BudgetMode model2.TechnologyDemandBudgetMode `json:"budget_mode"`
Deadline time.Time `json:"deadline"`
CreatedAt time.Time `json:"created_at"`
}
// DemandDetailInfo 需求详细信息
DemandDetailInfo struct {
ID string `json:"id"`
*model2.TechnologyDemand
Kinds []string `json:"kinds"`
Industry []string `json:"industry"`
*model2.TechnologyDemandOther
}
// DemandParams 需求参数信息
DemandParams struct {
ID uint64
Title, Introduce, Name, Mobile, Deadline string
Industry, Kinds []string
config.Area
Budget float64
BudgetMode int
Expect []string `json:"expect"` // 期望合作的企业及模式
Demand struct {
Basic string `json:"basic"` // 基础
Expect string `json:"expect"` // 预期
Benefit string `json:"benefit"` // 效益
} `json:"demand"` // 需求详细信息
Status int `json:"status"`
}
)
// List 列表信息
func (c *Demand) List(status, page, pageSize int) (*controller.ReturnPages, error) {
mTechnologyDemand := model.NewTechnologyDemand()
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
Where: model2.NewWhere("uid", c.ManageUID),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}, &model2.ModelWhereOrder{
Where: model2.NewWhere("status", status),
}}
var count int64
out := make([]*model2.TechnologyDemand, 0)
if err := model2.PagesFields(mTechnologyDemand.TechnologyDemand, &out, []string{"id", "title", "kind", "name",
"mobile", "budget", "budget_mode", "deadline", "created_at"}, page, pageSize, &count, where...); err != nil {
return nil, err
}
list := make([]*DemandInfo, 0)
for _, v := range out {
list = append(list, &DemandInfo{
ID: v.GetEncodeID(), Title: v.Title, Name: v.Name, Mobile: v.Mobile, Budget: v.Budget, BudgetMode: v.BudgetMode,
Kinds: v.GetKindAttribute(), Deadline: v.Deadline, CreatedAt: v.CreatedAt,
})
}
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(), Industry: mTechnologyDemand.GetIndustryAttribute(),
TechnologyDemandOther: mTechnologyDemand.GetOtherAttribute(),
}, nil
}
// Form 数据操作
func (c *Demand) Form(params *DemandParams) error {
mTechnologyDemand := model.NewTechnologyDemand()
if params.ID > 0 {
mTechnologyDemand.ID = params.ID
isExist, err := model2.FirstField(mTechnologyDemand.TechnologyDemand, []string{"id", "uid", "status"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,数据不存在")
} else if mTechnologyDemand.UID != c.ManageUID {
return errors.New("无权限操作")
} else if mTechnologyDemand.Status != model2.TechnologyDemandStatusForRefuse &&
mTechnologyDemand.Status != model2.TechnologyDemandStatusForDraft {
return errors.New("操作错误,当前状态不允许修改")
}
}
mTechnologyDemand.Title = params.Title
mTechnologyDemand.Name = params.Name
mTechnologyDemand.Mobile = params.Mobile
mTechnologyDemand.Area = model2.Area{
Province: params.Area.Province, City: params.Area.City, District: params.Area.District,
Address: params.Area.Address,
}
mTechnologyDemand.Introduce = params.Introduce
mTechnologyDemand.SetKindAttribute(params.Kinds)
mTechnologyDemand.SetIndustryAttribute(params.Industry)
mTechnologyDemand.Budget = params.Budget
mTechnologyDemand.BudgetMode = model2.TechnologyDemandBudgetMode(params.BudgetMode)
mTechnologyDemand.Deadline = utils.DataTimeToDate(params.Deadline)
mTechnologyDemand.Status = model2.TechnologyDemandStatus(params.Status)
mTechnologyDemand.SetOtherAttribute(&model2.TechnologyDemandOther{
Expect: params.Expect,
Demand: struct {
Basic string `json:"basic"`
Expect string `json:"expect"`
Benefit string `json:"benefit"`
}{
Basic: params.Demand.Basic, Expect: params.Demand.Expect, Benefit: params.Demand.Benefit,
},
})
if mTechnologyDemand.ID > 0 {
mTechnologyDemand.UpdatedAt = time.Now()
return model2.Updates(mTechnologyDemand.TechnologyDemand, mTechnologyDemand.TechnologyDemand)
}
mTechnologyDemand.TenantID = c.TenantID
mTechnologyDemand.UID = c.ManageUID
mTechnologyDemand.Local.Local = c.local
return model2.Create(mTechnologyDemand.TechnologyDemand)
}
// Delete 删除操作
func (c *Demand) Delete(id uint64) error {
mTechnologyDemand := model.NewTechnologyDemand()
mTechnologyDemand.ID = id
isExist, err := model2.FirstField(mTechnologyDemand.TechnologyDemand, []string{"id", "uid", "status"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,数据不存在")
} else if mTechnologyDemand.UID != c.ManageUID {
return errors.New("无权限操作")
}
if err = model2.Delete(mTechnologyDemand.TechnologyDemand); err != nil {
return err
}
return nil
}
func NewDemand() DemandHandle {
return func(enterprise *service.SessionEnterprise, local string) *Demand {
return &Demand{SessionEnterprise: enterprise, local: local}
}
}

View File

@ -0,0 +1,163 @@
package technology
import (
"SciencesServer/app/api/enterprise/model"
"SciencesServer/app/api/manage/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
"errors"
"time"
)
// Instance 技术管理
type Instance struct {
*service.SessionEnterprise
local string
}
type InstanceHandle func(enterprise *service.SessionEnterprise, local string) *Instance
type (
// InstanceInfo 详细信息
InstanceInfo struct {
ID string `json:"id"`
*model2.TechnologyInstance
Products []string `json:"products"`
Keywords []string `json:"keywords"`
}
// InstanceParams 参数信息
InstanceParams struct {
ID, PatentID, Territory uint64
Title, Company, Images, ProveImages, Introduce, Purpose, Remark string
Maturity, Prototype, Source, Transaction, Status int
Products, Keywords []string
}
)
// List 列表信息
func (c *Instance) List(status, page, pageSize int) (*controller.ReturnPages, error) {
mTechnologyInstance := model.NewTechnologyInstance()
out := make([]*model2.TechnologyInstance, 0)
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
Where: model2.NewWhere("status", status),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}}
var count int64
if err := model2.Pages(mTechnologyInstance.TechnologyInstance, &out, page, pageSize, &count, where...); err != nil {
return nil, err
}
list := make([]*InstanceInfo, 0)
for _, v := range out {
list = append(list, &InstanceInfo{
ID: v.GetEncodeID(), TechnologyInstance: v,
Products: v.GetProductAttribute(), Keywords: v.GetKeywordAttribute(),
})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Form 数据操作
func (c *Instance) Form(params *InstanceParams) error {
mTechnologyInstance := model.NewTechnologyInstance()
if params.ID > 0 {
mTechnologyInstance.ID = params.ID
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "uid",
"status", "created_at", "updated_at"})
if err != nil {
return err
} else if !isExist {
return errors.New("信息不存在")
} else if c.ManageUID != mTechnologyInstance.UID {
return errors.New("操作错误,无权限操作")
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForDraft &&
mTechnologyInstance.Status != model2.TechnologyInstanceStatusForRefuse {
return errors.New("操作错误,当前状态不允许修改")
}
}
mTechnologyInstance.PatentID = params.PatentID
mTechnologyInstance.Title = params.Title
mTechnologyInstance.Company = params.Company
mTechnologyInstance.Maturity = model2.TechnologyInstanceMaturity(params.Maturity)
mTechnologyInstance.Prototype = params.Prototype
mTechnologyInstance.SetProductAttribute(params.Products)
mTechnologyInstance.Source = model2.TechnologyInstanceSource(params.Source)
mTechnologyInstance.SetKeywordAttribute(params.Keywords)
mTechnologyInstance.Territory = params.Territory
mTechnologyInstance.Transaction = params.Transaction
mTechnologyInstance.Images = model2.Images{Images: params.Images}
mTechnologyInstance.ProveImages = params.ProveImages
mTechnologyInstance.Introduce = params.Introduce
mTechnologyInstance.Purpose = params.Purpose
mTechnologyInstance.Remark = params.Remark
mTechnologyInstance.Status = model2.TechnologyInstanceStatus(params.Status)
if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForDraft &&
mTechnologyInstance.Status != model2.TechnologyInstanceStatusForExamining {
return errors.New("操作错误,状态参数错误")
}
if params.ID > 0 {
mTechnologyInstance.UpdatedAt = time.Now()
return model2.Updates(mTechnologyInstance.TechnologyInstance, mTechnologyInstance.TechnologyInstance)
}
mTechnologyInstance.UID = c.ManageUID
mTechnologyInstance.Local.Local = c.local
mTechnologyInstance.TenantID = c.TenantID
return model2.Create(mTechnologyInstance.TechnologyInstance)
}
// Shelf 上下架操作
func (c *Instance) Shelf(id uint64, status int) error {
mTechnologyInstance := model.NewTechnologyInstance()
mTechnologyInstance.ID = id
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "uid", "shelf_status", "status"})
if err != nil {
return err
} else if !isExist {
return errors.New("信息不存在")
} else if c.ManageUID != mTechnologyInstance.UID {
return errors.New("操作错误,无权限操作")
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForAgree {
return errors.New("操作错误,当前状态不允许处理上下架")
} else if mTechnologyInstance.ShelfStatus.ShelfStatus == model2.ShelfStatusKind(status) {
return errors.New("操作错误,状态异常")
}
if err = model2.Updates(mTechnologyInstance.TechnologyInstance, map[string]interface{}{
"shelf_status": status, "updated_at": time.Now(),
}); err != nil {
return err
}
return nil
}
// Delete 删除操作
func (c *Instance) Delete(id uint64) error {
mTechnologyInstance := model.NewTechnologyInstance()
mTechnologyInstance.ID = id
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "uid"})
if err != nil {
return err
} else if !isExist {
return errors.New("信息不存在")
} else if c.ManageUID != mTechnologyInstance.UID {
return errors.New("操作错误,无权限操作")
}
if err = model2.Delete(mTechnologyInstance.TechnologyInstance); err != nil {
return err
}
return nil
}
func NewInstance() InstanceHandle {
return func(enterprise *service.SessionEnterprise, local string) *Instance {
return &Instance{SessionEnterprise: enterprise, local: local}
}
}

View File

@ -0,0 +1,119 @@
package technology
import (
"SciencesServer/app/api/enterprise/model"
"SciencesServer/app/api/manage/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
"SciencesServer/utils"
"errors"
"time"
)
// Paper 论文管理
type Paper struct {
*service.SessionEnterprise
local string
}
type PaperHandle func(enterprise *service.SessionEnterprise, local string) *Paper
type (
PaperInfo struct {
ID string `json:"id"`
*model2.TechnologyPaper
Tags []string `json:"tags"`
}
PaperParams struct {
ID uint64
Title, Ext, Author, PublishAt, Keyword, Remark string
Tags []string
}
)
// List 列表信息
func (c *Paper) List(title string, page, pageSize int) (*controller.ReturnPages, error) {
mTechnologyPaper := model.NewTechnologyPaper()
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
Where: model2.NewWhere("tenant_id", c.TenantID),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}, &model2.ModelWhereOrder{
Where: model2.NewWhere("local", c.local),
}}
if title != "" {
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereLike("title", title)})
}
out := make([]*model2.TechnologyPaper, 0)
var count int64
if err := model2.Pages(mTechnologyPaper.TechnologyPaper, &out, page, pageSize, &count, where...); err != nil {
return nil, err
}
list := make([]*PaperInfo, 0)
for _, v := range out {
list = append(list, &PaperInfo{ID: v.GetEncodeID(), TechnologyPaper: v, Tags: v.GetTagAttribute()})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Form 参数信息
func (c *Paper) Form(params *PaperParams) error {
mTechnologyPaper := model.NewTechnologyPaper()
if params.ID > 0 {
mTechnologyPaper.ID = params.ID
if isExist, err := model2.First(mTechnologyPaper.TechnologyPaper); err != nil {
return err
} else if !isExist {
return errors.New("当前论文信息不存在")
} else if mTechnologyPaper.UID != c.ManageUID {
return errors.New("无权限操作")
}
}
mTechnologyPaper.Title = params.Title
mTechnologyPaper.Ext = params.Ext
mTechnologyPaper.Author = params.Author
mTechnologyPaper.PublishAt = utils.DateTimeToTime(params.PublishAt)
mTechnologyPaper.Keyword = params.Keyword
mTechnologyPaper.SetTagAttribute(params.Tags)
mTechnologyPaper.Remark = params.Remark
if params.ID <= 0 {
mTechnologyPaper.TenantID = c.TenantID
mTechnologyPaper.UID = c.ManageUID
mTechnologyPaper.Local.Local = c.local
return model2.Create(mTechnologyPaper.TechnologyPaper)
}
mTechnologyPaper.UpdatedAt = time.Now()
return model2.Updates(mTechnologyPaper.TechnologyPaper, mTechnologyPaper.TechnologyPaper)
}
// Delete 删除操作
func (c *Paper) Delete(id uint64) error {
mTechnologyPaper := model.NewTechnologyPaper()
mTechnologyPaper.ID = id
var count int64
err := model2.Count(mTechnologyPaper.TechnologyPaper, &count, model2.NewWhere("id", id), model2.NewWhere("uid", c.ManageUID))
if err != nil {
return err
} else if count <= 0 {
return errors.New("当前论文信息不存在")
}
if err = model2.Delete(mTechnologyPaper.TechnologyPaper); err != nil {
return err
}
return nil
}
func NewPaper() PaperHandle {
return func(enterprise *service.SessionEnterprise, local string) *Paper {
return &Paper{SessionEnterprise: enterprise, local: local}
}
}

View File

@ -0,0 +1,154 @@
package technology
import (
"SciencesServer/app/api/enterprise/model"
"SciencesServer/app/api/manage/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
"SciencesServer/utils"
"errors"
"time"
)
// Patent 专利管理
type Patent struct {
*service.SessionEnterprise
local string
}
type PatentHandle func(enterprise *service.SessionEnterprise, local string) *Patent
type (
// PatentInfo 专利信息
PatentInfo struct {
ID string `json:"id"`
Title string `json:"title"`
ApplyCode string `json:"apply_code"` // 申请号
ApplyName string `json:"apply_name"` // 申请人
ApplyAt time.Time `json:"apply_at"` // 申请时间
Inventor string `json:"inventor"` // 发明人
}
// PatentDetailInfo 专利详细信息
PatentDetailInfo struct {
ID string `json:"id"`
*model2.TechnologyPatent
}
// PatentParams 专利参数信息
PatentParams struct {
ID uint64
Title, IPCCode, CPCCode, ApplyCode, ApplyName, ApplyAddress, ApplyZipCode,
Inventor, PriorityCode, OpenCode, ApplyAt, PriorityAt, OpenAt string
}
)
// List 列表信息
func (c *Patent) List(title string, page, pageSize int) (*controller.ReturnPages, error) {
mTechnologyPatent := model.NewTechnologyPatent()
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
Where: model2.NewWhere("uid", c.ManageUID),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}}
if title != "" {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhereLike("title", title),
})
}
out := make([]*model2.TechnologyPatent, 0)
var count int64
if err := model2.PagesFields(mTechnologyPatent.TechnologyPatent, &out, []string{"id", "title", "apply_code", "inventor",
"apply_name", "apply_at"}, page, pageSize, &count, where...); err != nil {
return nil, err
}
list := make([]*PatentInfo, 0)
for _, v := range out {
list = append(list, &PatentInfo{
ID: v.GetEncodeID(), Title: v.Title, ApplyCode: v.ApplyCode, ApplyName: v.ApplyName,
ApplyAt: v.ApplyAt, Inventor: v.Inventor,
})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Detail 详细信息
func (c *Patent) Detail(id uint64) (*PatentDetailInfo, error) {
mTechnologyPatent := model.NewTechnologyPatent()
mTechnologyPatent.ID = id
isExist, err := model2.First(mTechnologyPatent.TechnologyPatent)
if err != nil {
return nil, err
} else if !isExist {
return nil, errors.New("操作错误,专利信息不存在")
}
return &PatentDetailInfo{
ID: mTechnologyPatent.GetEncodeID(), TechnologyPatent: mTechnologyPatent.TechnologyPatent,
}, nil
}
func (c *Patent) Form(params *PatentParams) error {
mTechnologyPatent := model.NewTechnologyPatent()
if params.ID > 0 {
mTechnologyPatent.ID = params.ID
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,专利信息不存在")
} else if mTechnologyPatent.UID != c.ManageUID {
return errors.New("无权限操作")
}
}
mTechnologyPatent.Title = params.Title
mTechnologyPatent.IPCCode = params.IPCCode
mTechnologyPatent.CPCCode = params.CPCCode
mTechnologyPatent.ApplyCode = params.ApplyCode
mTechnologyPatent.ApplyName = params.ApplyName
mTechnologyPatent.ApplyZipCode = params.ApplyZipCode
mTechnologyPatent.ApplyAt = utils.DataTimeToDate(params.ApplyAt)
mTechnologyPatent.Inventor = params.Inventor
mTechnologyPatent.PriorityCode = params.PriorityCode
mTechnologyPatent.PriorityAt = utils.DataTimeToDate(params.PriorityAt)
mTechnologyPatent.OpenCode = params.OpenCode
mTechnologyPatent.OpenAt = utils.DataTimeToDate(params.OpenAt)
if mTechnologyPatent.ID > 0 {
mTechnologyPatent.UpdatedAt = time.Now()
return model2.Updates(mTechnologyPatent.TechnologyPatent, mTechnologyPatent.TechnologyPatent)
}
mTechnologyPatent.TenantID = c.TenantID
mTechnologyPatent.Local.Local = c.local
mTechnologyPatent.UID = c.ManageUID
return model2.Create(mTechnologyPatent.TechnologyPatent)
}
// Delete 删除操作
func (c *Patent) Delete(id uint64) error {
mTechnologyPatent := model.NewTechnologyPatent()
mTechnologyPatent.ID = id
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,专利信息不存在")
} else if mTechnologyPatent.UID != c.ManageUID {
return errors.New("无权限操作")
}
return model2.Delete(mTechnologyPatent.TechnologyPatent)
}
func NewPatent() PatentHandle {
return func(enterprise *service.SessionEnterprise, local string) *Patent {
return &Patent{SessionEnterprise: enterprise, local: local}
}
}