feat:完善项目
This commit is contained in:
113
app/api/admin/controller/technology/paper.go
Normal file
113
app/api/admin/controller/technology/paper.go
Normal file
@ -0,0 +1,113 @@
|
||||
package technology
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Paper struct {
|
||||
*session.Admin
|
||||
}
|
||||
|
||||
type PaperHandle func(session *session.Admin) *Paper
|
||||
|
||||
type (
|
||||
// PaperInfo 论文信息
|
||||
PaperInfo struct {
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
*model.TechnologyPaperInfo
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// PaperDetailInfo 论文详细信息
|
||||
PaperDetailInfo struct {
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
*model2.TechnologyPaper
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Paper) Instance(tenantID uint64, title string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mTechnologyPaper := model.NewTechnologyPaper()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("p.tenant_id", c.TenantID))
|
||||
}
|
||||
if tenantID > 0 {
|
||||
where = append(where, model2.NewWhere("p.tenant_id", tenantID))
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("p.title", title))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mTechnologyPaper.Paper(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*PaperInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &PaperInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
TenantID: v.GetEncodeTenantID(),
|
||||
TechnologyPaperInfo: v,
|
||||
Area: v.FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Paper) Detail(id uint64) (*PaperDetailInfo, error) {
|
||||
mTechnologyPaper := model.NewTechnologyPaper()
|
||||
mTechnologyPaper.ID = id
|
||||
|
||||
isExist, err := model2.First(mTechnologyPaper.TechnologyPaper)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,论文信息不存在或已被删除")
|
||||
}
|
||||
return &PaperDetailInfo{
|
||||
ID: mTechnologyPaper.GetEncodeID(),
|
||||
TenantID: mTechnologyPaper.GetEncodeTenantID(),
|
||||
TechnologyPaper: mTechnologyPaper.TechnologyPaper,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Paper) Form() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func (c *Paper) Delete(id uint64) error {
|
||||
mTechnologyPaper := model.NewTechnologyPaper()
|
||||
mTechnologyPaper.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mTechnologyPaper.TechnologyPaper, []string{"id", "tenant_id"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,论文信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && mTechnologyPaper.TenantID != c.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
return model2.Delete(mTechnologyPaper.TechnologyPaper)
|
||||
}
|
||||
|
||||
func NewPaper() PaperHandle {
|
||||
return func(session *session.Admin) *Paper {
|
||||
return &Paper{session}
|
||||
}
|
||||
}
|
@ -57,10 +57,6 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Patent) tree() {
|
||||
|
||||
}
|
||||
|
||||
func (c *Patent) ipcTree(src []*model2.SysPatentClassify, parentID uint64) []*PatentIPCInfo {
|
||||
out := make([]*PatentIPCInfo, 0)
|
||||
|
||||
|
Reference in New Issue
Block a user