Merge branch 'master' of http://101.43.70.124:3000/williamet/cas_tt_cloud_backend
This commit is contained in:
@ -91,16 +91,18 @@ func (c *Agent) Instance(tenantID uint64, name string, status int, page, pageSiz
|
||||
Total int `json:"total"`
|
||||
Complete int `json:"complete"`
|
||||
}{}
|
||||
// 筛选处理需求信息
|
||||
for _, val := range strings.Split(v.Demand, ";") {
|
||||
objs := strings.Split(val, ":")
|
||||
if v.Demand != "" {
|
||||
// 筛选处理需求信息
|
||||
for _, val := range strings.Split(v.Demand, ";") {
|
||||
objs := strings.Split(val, ":")
|
||||
|
||||
count := utils.StringToInt(objs[1])
|
||||
count := utils.StringToInt(objs[1])
|
||||
|
||||
if model2.TechnologyDemandServiceStatus(utils.StringToInt(objs[0])) == model2.TechnologyDemandServiceStatusForClosedQuestions {
|
||||
demand.Complete = count
|
||||
if model2.TechnologyDemandServiceStatus(utils.StringToInt(objs[0])) == model2.TechnologyDemandServiceStatusForClosedQuestions {
|
||||
demand.Complete = count
|
||||
}
|
||||
demand.Total += count
|
||||
}
|
||||
demand.Total += count
|
||||
}
|
||||
list = append(list, &AgentInfo{
|
||||
ID: v.GetEncodeID(), Name: v.Name, Mobile: v.Mobile, Industrys: industrys,
|
||||
|
||||
@ -151,7 +151,7 @@ func (c *Patent) Form(params *PatentParams) error {
|
||||
if params.ID > 0 {
|
||||
mTechnologyPatent.ID = params.ID
|
||||
|
||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "tenant_id", "uid", "apply_code", "ipc_code", "created_at"})
|
||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "apply_code", "ipc_code", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -268,7 +268,7 @@ func (c *Patent) Bind(id, uid uint64) error {
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
mTechnologyPatent.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid", "tenant_id"})
|
||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -70,7 +70,7 @@ func (*Activity) ApplyDelete(c *gin.Context) {
|
||||
func (*Activity) Joins(c *gin.Context) {
|
||||
form := &struct {
|
||||
Title string `json:"title" form:"title"`
|
||||
Status int `json:"status" form:"status"` // 1:未开始,2:进行中,3:已结束
|
||||
Status int `json:"status" form:"status"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
|
||||
@ -120,7 +120,7 @@ type (
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Description string `json:"description" form:"description" binding:"required"`
|
||||
api.ImageForm
|
||||
File string `json:"file" form:"file" binding:"required"`
|
||||
File string `json:"file" form:"file"`
|
||||
Industrys []string `json:"industrys" form:"industrys"`
|
||||
Customers []string `json:"customers" form:"customers"`
|
||||
Maturity int `json:"maturity" form:"maturity"`
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -3,7 +3,6 @@ package api
|
||||
import (
|
||||
"SciencesServer/app/api/website/controller"
|
||||
"SciencesServer/app/basic/api"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -19,6 +18,6 @@ func (*Config) Index(c *gin.Context) {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := controller.NewConfig()(nil).Instance(form.Kind, strings.Split(form.Key, ","))
|
||||
data, err := controller.NewConfig()(nil).Instance(form.Kind, form.Key)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ func GetTenantID() ApiHandle {
|
||||
value := c.GetHeader(config.ContentForTenantID)
|
||||
|
||||
if value == "" {
|
||||
// 登录身份
|
||||
return uint64(1)
|
||||
}
|
||||
return utils.StringToUnit64(value)
|
||||
|
||||
@ -139,7 +139,7 @@ func (this *Instance) Handle() {
|
||||
&synchronized{iModel: model.NewTechnologyProject()}, &synchronized{iModel: model.NewTechnologyTopic()},
|
||||
&synchronized{iModel: model.NewTechnologyDemandService()}, &synchronized{iModel: model.NewTechnologyDemandServiceProgress()},
|
||||
&synchronized{iModel: model.NewTechnologyPatent()}, &synchronized{iModel: model.NewTechnologyPatentExpert()}, &synchronized{iModel: model.NewTechnologyPatentClassify()},
|
||||
&synchronized{iModel: model.NewServiceDocking()},
|
||||
&synchronized{iModel: model.NewServiceDocking()}, &synchronized{iModel: model.NewServiceDemand()},
|
||||
&synchronized{iModel: model.NewServiceMessage()}, &synchronized{iModel: model.NewServiceMessageLog()},
|
||||
&synchronized{iModel: model.NewServiceSolutionCase()}, &synchronized{iModel: model.NewServiceSolutionCaseKind()},
|
||||
&synchronized{iModel: model.NewServiceInnovate()}, &synchronized{iModel: model.NewServiceInnovateKind()},
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -5,16 +5,34 @@ import (
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// [1,2,3, 4, 5,6,7]
|
||||
// 7
|
||||
// mid: 3
|
||||
func InArray(search, needle interface{}) bool {
|
||||
val := reflect.ValueOf(needle)
|
||||
|
||||
kind := val.Kind()
|
||||
|
||||
if kind == reflect.Slice || kind == reflect.Array {
|
||||
for i := 0; i < val.Len(); i++ {
|
||||
_length := val.Len()
|
||||
|
||||
if _length <= 0 {
|
||||
return false
|
||||
} else if _length == 1 {
|
||||
return val.Index(0).Interface() == search
|
||||
}
|
||||
mid := _length >> 1
|
||||
|
||||
for i := 0; i < mid; i++ {
|
||||
if val.Index(i).Interface() == search {
|
||||
return true
|
||||
}
|
||||
if val.Index((_length-1)-i).Interface() == search {
|
||||
return true
|
||||
}
|
||||
}
|
||||
if _length%2 > 0 {
|
||||
return val.Index(mid).Interface() == search
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
@ -84,6 +84,10 @@ func StructToMap(s interface{}, m map[string]interface{}) {
|
||||
fieldNum := tRef.NumField()
|
||||
|
||||
for index := 0; index < fieldNum; index++ {
|
||||
if mark, isExist := tRef.Field(index).Tag.Lookup("json"); isExist {
|
||||
m[mark] = vRef.FieldByName(tRef.Field(index).Name).Interface()
|
||||
continue
|
||||
}
|
||||
m[tRef.Field(index).Name] = vRef.FieldByName(tRef.Field(index).Name).Interface()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user