feat:完善信息
This commit is contained in:
@ -20,7 +20,7 @@ type IModel interface {
|
||||
|
||||
// Model
|
||||
type Model struct {
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement;comment:主键" json:"id" form:"id"`
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement;comment:主键" json:"-" form:"id"`
|
||||
|
||||
Database string `json:"-" gorm:"-"`
|
||||
}
|
||||
|
34
app/common/model/technology_patent.go
Normal file
34
app/common/model/technology_patent.go
Normal file
@ -0,0 +1,34 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// TechnologyPatent 技术专利
|
||||
type TechnologyPatent struct {
|
||||
Model
|
||||
ModelTenant
|
||||
Local
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户管理uuid" json:"-"`
|
||||
Title string `gorm:"column:title;type:varchar(50);default:null;comment:专利名称" json:"title"`
|
||||
IPCCode string `gorm:"column:ipc_code;type:varchar(30);default:null;comment:IPC分类号" json:"ipc_code"`
|
||||
CPCCode string `gorm:"column:cpc_code;type:varchar(30);default:null;comment:CPC分类号" json:"cpc_code"`
|
||||
ApplyCode string `gorm:"column:apply_code;type:varchar(30);default:null;comment:专利申请号" json:"apply_code"`
|
||||
ApplyName string `gorm:"column:apply_name;type:varchar(15);default:null;comment:专利申请人" json:"apply_name"`
|
||||
ApplyAddress string `gorm:"column:apply_address;type:varchar(100);default:null;comment:专利申请人地址" json:"apply_address"`
|
||||
ApplyZipCode string `gorm:"column:apply_zip_code;type:varchar(10);default:null;comment:专利申请人邮编" json:"apply_zip_code"`
|
||||
ApplyAt time.Time `gorm:"column:apply_at;type:date;not null;comment:专利申请人时间" json:"apply_at"`
|
||||
Inventor string `gorm:"column:inventor;type:varchar(15);default:null;comment:发明人" json:"inventor"`
|
||||
PriorityCode string `gorm:"column:priority_code;type:varchar(30);default:null;comment:优先权号" json:"priority_code"`
|
||||
PriorityAt time.Time `gorm:"column:priority_at;type:date;not null;comment:优先权日" json:"priority_at"`
|
||||
OpenCode string `gorm:"column:open_code;type:varchar(100);default:null;comment:公开(公告)号" json:"open_code"`
|
||||
OpenAt time.Time `gorm:"column:open_at;type:date;not null;comment:公开(公告)日" json:"open_at"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *TechnologyPatent) TableName() string {
|
||||
return m.NewTableName("technology_patent")
|
||||
}
|
||||
|
||||
func NewTechnologyPatent() *TechnologyPatent {
|
||||
return &TechnologyPatent{}
|
||||
}
|
@ -21,6 +21,22 @@ type (
|
||||
Tags []string `json:"tags" form:"tags"` // 标签
|
||||
Remark string `json:"remark" form:"remark"` // 备注
|
||||
}
|
||||
// patentForm 专利参数
|
||||
patentForm struct {
|
||||
Title string `json:"title" form:"title"`
|
||||
IPCCode string `json:"ipc_code" form:"ipc_code"`
|
||||
CPCCode string `json:"cpc_code" form:"cpc_code"`
|
||||
ApplyCode string `json:"apply_code" form:"apply_code"`
|
||||
ApplyName string `json:"apply_name" form:"apply_name"`
|
||||
ApplyAddress string `json:"apply_address" form:"apply_address"`
|
||||
ApplyZipCode string `json:"apply_zip_code" form:"apply_zip_code"`
|
||||
Inventor string `json:"inventor" form:"inventor"`
|
||||
PriorityCode string `json:"priority_code" form:"priority_code"`
|
||||
OpenCode string `json:"open_code" form:"open_code"`
|
||||
ApplyAt string `json:"apply_at" form:"apply_at"`
|
||||
PriorityAt string `json:"priority_at" form:"priority_at"`
|
||||
OpenAt string `json:"open_at" form:"open_at"`
|
||||
}
|
||||
// demandForm 需求参数
|
||||
demandForm struct {
|
||||
Title string `json:"title"`
|
||||
@ -99,6 +115,80 @@ func (a *Technology) PaperDelete(c *gin.Context) {
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (a *Technology) Patent(c *gin.Context) {
|
||||
form := &struct {
|
||||
Title string `json:"title" form:"title"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := technology.NewPatent()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
|
||||
List(form.Title, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (a *Technology) PatentDetail(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := technology.NewPatent()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
|
||||
Detail(form.Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (a *Technology) PatentAdd(c *gin.Context) {
|
||||
form := new(patentForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := technology.NewPatent()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
|
||||
Form(&technology.PatentParams{
|
||||
Title: form.Title, IPCCode: form.IPCCode, CPCCode: form.CPCCode, ApplyCode: form.ApplyCode,
|
||||
ApplyName: form.ApplyName, ApplyAddress: form.ApplyAddress, ApplyZipCode: form.ApplyZipCode,
|
||||
Inventor: form.Inventor, PriorityCode: form.PriorityCode, OpenCode: form.OpenCode, ApplyAt: form.ApplyAt,
|
||||
PriorityAt: form.PriorityAt, OpenAt: form.OpenAt,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (a *Technology) PatentEdit(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
patentForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := technology.NewPatent()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
|
||||
Form(&technology.PatentParams{
|
||||
ID: form.Convert(), Title: form.Title, IPCCode: form.IPCCode, CPCCode: form.CPCCode,
|
||||
ApplyCode: form.ApplyCode, ApplyName: form.ApplyName, ApplyAddress: form.ApplyAddress,
|
||||
ApplyZipCode: form.ApplyZipCode, Inventor: form.Inventor, PriorityCode: form.PriorityCode, OpenCode: form.OpenCode,
|
||||
ApplyAt: form.ApplyAt, PriorityAt: form.PriorityAt, OpenAt: form.OpenAt,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (a *Technology) PatentDelete(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := technology.NewPatent()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
|
||||
Delete(form.Convert())
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (a *Technology) Demand(c *gin.Context) {
|
||||
form := &struct {
|
||||
Status int `json:"status" form:"status"`
|
||||
|
@ -22,13 +22,15 @@ type DemandHandle func(enterprise *service.SessionEnterprise, local string) *Dem
|
||||
type (
|
||||
// DemandInfo 需求信息
|
||||
DemandInfo struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Name string `json:"name"`
|
||||
Mobile string `json:"mobile"`
|
||||
Kinds []string `json:"kinds"`
|
||||
Deadline time.Time `json:"deadline"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
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 {
|
||||
@ -71,14 +73,14 @@ func (c *Demand) List(status, page, pageSize int) (*controller.ReturnPages, erro
|
||||
out := make([]*model2.TechnologyDemand, 0)
|
||||
|
||||
if err := model2.PagesFields(mTechnologyDemand.TechnologyDemand, &out, []string{"id", "title", "kind", "name",
|
||||
"mobile", "deadline", "created_at"}, page, pageSize, &count, where...); err != nil {
|
||||
"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,
|
||||
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,
|
||||
})
|
||||
}
|
||||
|
@ -1,17 +1,154 @@
|
||||
package technology
|
||||
|
||||
import "SciencesServer/app/service"
|
||||
import (
|
||||
"SciencesServer/app/api/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/enterprise/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Patent 专利管理
|
||||
type Patent struct {
|
||||
*service.SessionEnterprise
|
||||
local uint64
|
||||
local string
|
||||
}
|
||||
|
||||
type PatentHandle func(enterprise *service.SessionEnterprise, local uint64) *Patent
|
||||
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 uint64) *Patent {
|
||||
return func(enterprise *service.SessionEnterprise, local string) *Patent {
|
||||
return &Patent{SessionEnterprise: enterprise, local: local}
|
||||
}
|
||||
}
|
||||
|
11
app/enterprise/model/technology_patent.go
Normal file
11
app/enterprise/model/technology_patent.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type TechnologyPatent struct {
|
||||
*model.TechnologyPatent
|
||||
}
|
||||
|
||||
func NewTechnologyPatent() *TechnologyPatent {
|
||||
return &TechnologyPatent{TechnologyPatent: model.NewTechnologyPatent()}
|
||||
}
|
Reference in New Issue
Block a user