feat:完善信息

This commit is contained in:
henry
2022-03-08 13:56:34 +08:00
parent 6f265db820
commit 8eeab34c34
4 changed files with 81 additions and 0 deletions

View File

@ -239,6 +239,19 @@ func (a *Technology) Paper(c *gin.Context) {
api.APIResponse(err, data)(c)
}
func (a *Technology) PaperSelect(c *gin.Context) {
form := &struct {
Title string `json:"title" form:"title" binding:"required"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := technology2.NewPaper()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)).
Select(form.Title)
api.APIResponse(err, data)(c)
}
func (a *Technology) PaperAdd(c *gin.Context) {
form := new(paperForm)
@ -301,6 +314,19 @@ func (a *Technology) Patent(c *gin.Context) {
api.APIResponse(err, data)(c)
}
func (a *Technology) PatentSelect(c *gin.Context) {
form := &struct {
Title string `json:"title" form:"title" binding:"required"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)).
Select(form.Title)
api.APIResponse(err, data)(c)
}
func (a *Technology) PatentDetail(c *gin.Context) {
form := new(api.IDStringForm)

View File

@ -19,6 +19,10 @@ type Paper struct {
type PaperHandle func(session *session.Enterprise, tenantID uint64) *Paper
type (
PaperBasic struct {
ID string `json:"id"`
Title string `json:"title"`
}
PaperInfo struct {
ID string `json:"id"`
*model2.TechnologyPaper
@ -60,6 +64,27 @@ func (c *Paper) List(title string, page, pageSize int) (*controller.ReturnPages,
return &controller.ReturnPages{Data: list, Count: count}, nil
}
func (c *Paper) Select(title string) ([]*PaperBasic, error) {
mTechnologyPaper := model.NewTechnologyPaper()
where := make([]*model2.ModelWhereOrder, 0)
if title != "" {
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereLike("title", title)})
}
out := make([]*model2.TechnologyPaper, 0)
if err := model2.ScanFields(mTechnologyPaper.TechnologyPaper, &out, []string{"id", "title"}, where...); err != nil {
return nil, err
}
list := make([]*PaperBasic, 0)
for _, v := range out {
list = append(list, &PaperBasic{ID: v.GetEncodeID(), Title: v.Title})
}
return list, nil
}
// Form 参数信息
func (c *Paper) Form(params *PaperParams) error {
mTechnologyPaper := model.NewTechnologyPaper()

View File

@ -22,6 +22,10 @@ type Patent struct {
type PatentHandle func(session *session.Enterprise, tenantID uint64) *Patent
type (
PatentBasic struct {
ID string `json:"id"`
Title string `json:"title"`
}
// PatentInfo 专利信息
PatentInfo struct {
ID string `json:"id"`
@ -247,6 +251,30 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Select 列表信息
func (c *Patent) Select(title string) ([]*PatentBasic, error) {
where := make([]*model2.ModelWhereOrder, 0)
if title != "" {
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereLike("title", title)})
}
mTechnologyPatent := model.NewTechnologyPatent()
out := make([]*model2.TechnologyPatent, 0)
if err := model2.ScanFields(mTechnologyPatent.TechnologyPatent, &out, []string{"id", "title"}, where...); err != nil {
return nil, err
}
list := make([]*PatentBasic, 0)
for _, v := range out {
list = append(list, &PatentBasic{
ID: v.GetEncodeID(), Title: v.Title,
})
}
return list, nil
}
// Match 搜索信息
func (c *Patent) Match(title string, industrys, keywords []string) (*controller.ReturnPages, error) {
params := strings.Join([]string{

View File

@ -522,10 +522,12 @@ func registerEnterpriseAPI(app *gin.Engine) {
{
_api := new(api3.Technology)
technologyV1.POST("/paper", _api.Paper)
technologyV1.POST("/paper/select", _api.PaperSelect)
technologyV1.POST("/paper/add", _api.PaperAdd)
technologyV1.POST("/paper/edit", _api.PaperEdit)
technologyV1.POST("/paper/delete", _api.PaperDelete)
technologyV1.POST("/patent", _api.Patent)
technologyV1.POST("/patent/select", _api.PatentSelect)
technologyV1.POST("/patent/detail", _api.PatentDetail)
technologyV1.POST("/patent/add", _api.PatentAdd)
technologyV1.POST("/patent/edit", _api.PatentEdit)