package sys import ( "SciencesServer/app/api/enterprise/model" "SciencesServer/app/basic/controller" model2 "SciencesServer/app/common/model" "SciencesServer/app/session" "SciencesServer/utils" "strings" ) // Patent 专利信息 type Patent struct { *session.Enterprise } type PatentHandle func(session *session.Enterprise) *Patent type ( // PatentInfo 专利信息 PatentInfo struct { ID string `json:"id"` Kind model2.SysParentKind `json:"kind"` Title string `json:"title"` } ) func (c *Patent) filter(src string) string { src = utils.ReplaceAllCompile(src, "\t", "") src = utils.ReplaceAllCompile(src, "\n", "") src = strings.TrimLeft(src, " ") src = strings.TrimRight(src, " ") return src } func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page, pageSize int) (*controller.ReturnPages, error) { mSysPatent := model.NewSysPatent() where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{Order: model2.NewOrder("id", model2.OrderModeToDesc)}} if kind <= 0 { where = append(where, &model2.ModelWhereOrder{ Where: model2.NewWhere("kind", kind), }) } if title != "" { where = append(where, &model2.ModelWhereOrder{ Where: model2.NewWhereLike("title", title), }) } if applyCode != "" { where = append(where, &model2.ModelWhereOrder{ Where: model2.NewWhereLike("apply_code", applyCode), }) } if openCode != "" { where = append(where, &model2.ModelWhereOrder{ Where: model2.NewWhereLike("open_code", openCode), }) } if ipcCode != "" { where = append(where, &model2.ModelWhereOrder{ Where: model2.NewWhereLike("ipc_code", ipcCode), }) } out := make([]*model2.SysPatent, 0) var count int64 if err := model2.Pages(mSysPatent.SysPatent, &out, page, pageSize, &count); err != nil { return nil, err } list := make([]*PatentInfo, 0) for _, v := range out { list = append(list, &PatentInfo{ ID: v.GetEncodeID(), Kind: v.Kind, Title: v.Title, }) v.ApplyName = c.filter(v.ApplyName) v.ApplyAddress = c.filter(v.ApplyAddress) v.Inventor = c.filter(v.Inventor) v.Description = c.filter(v.Description) } return &controller.ReturnPages{ Data: out, Count: count, }, nil } func NewPatent() PatentHandle { return func(session *session.Enterprise) *Patent { return &Patent{Enterprise: session} } }