package sys import ( "SciencesServer/app/api/enterprise/model" "SciencesServer/app/basic/controller" model2 "SciencesServer/app/common/model" "SciencesServer/app/session" "SciencesServer/utils" "strings" "time" ) // Patent 专利信息 type Patent struct { *session.Enterprise } type PatentHandle func(session *session.Enterprise) *Patent type ( // PatentInfo 专利信息 PatentInfo struct { ID string `json:"id"` Kind model2.TechnologyPatentKind `json:"kind"` Title string `json:"title"` ApplyName string `json:"apply_name"` ApplyCode string `json:"apply_code"` ApplyAt string `json:"apply_at"` Inventor string `json:"inventor"` CreatedAt time.Time `json:"created_at"` } ) 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) { mTechnologyPatent := model.NewTechnologyPatent() where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{ Where: model2.NewWhere("shelf_status", model2.ShelfStatusForUp), 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.TechnologyPatent, 0) var count int64 if err := model2.PagesFields(mTechnologyPatent.TechnologyPatent, &out, []string{"id", "title", "apply_code", "apply_name", "apply_at", "created_at"}, 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, ApplyName: v.ApplyName, ApplyCode: v.ApplyCode, ApplyAt: v.ApplyAt, CreatedAt: v.CreatedAt, }) //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 (c *Patent) Select() { } func NewPatent() PatentHandle { return func(session *session.Enterprise) *Patent { return &Patent{Enterprise: session} } }