Merge branch 'master' of http://101.43.70.124:3000/williamet/cas_tt_cloud_backend
This commit is contained in:
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
- 编译项目
|
- 编译项目
|
||||||
```bash
|
```bash
|
||||||
go bulid [-x|-o]
|
go build [-x|-o]
|
||||||
```
|
```
|
||||||
|
|
||||||
- 运行项目
|
- 运行项目
|
||||||
|
|||||||
@ -91,16 +91,18 @@ func (c *Agent) Instance(tenantID uint64, name string, status int, page, pageSiz
|
|||||||
Total int `json:"total"`
|
Total int `json:"total"`
|
||||||
Complete int `json:"complete"`
|
Complete int `json:"complete"`
|
||||||
}{}
|
}{}
|
||||||
// 筛选处理需求信息
|
if v.Demand != "" {
|
||||||
for _, val := range strings.Split(v.Demand, ";") {
|
// 筛选处理需求信息
|
||||||
objs := strings.Split(val, ":")
|
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 {
|
if model2.TechnologyDemandServiceStatus(utils.StringToInt(objs[0])) == model2.TechnologyDemandServiceStatusForClosedQuestions {
|
||||||
demand.Complete = count
|
demand.Complete = count
|
||||||
|
}
|
||||||
|
demand.Total += count
|
||||||
}
|
}
|
||||||
demand.Total += count
|
|
||||||
}
|
}
|
||||||
list = append(list, &AgentInfo{
|
list = append(list, &AgentInfo{
|
||||||
ID: v.GetEncodeID(), Name: v.Name, Mobile: v.Mobile, Industrys: industrys,
|
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 {
|
if params.ID > 0 {
|
||||||
mTechnologyPatent.ID = params.ID
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -268,7 +268,7 @@ func (c *Patent) Bind(id, uid uint64) error {
|
|||||||
mTechnologyPatent := model.NewTechnologyPatent()
|
mTechnologyPatent := model.NewTechnologyPatent()
|
||||||
mTechnologyPatent.ID = id
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@ -70,7 +70,7 @@ func (*Activity) ApplyDelete(c *gin.Context) {
|
|||||||
func (*Activity) Joins(c *gin.Context) {
|
func (*Activity) Joins(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
Title string `json:"title" form:"title"`
|
Title string `json:"title" form:"title"`
|
||||||
Status int `json:"status" form:"status"` // 1:未开始,2:进行中,3:已结束
|
Status int `json:"status" form:"status"`
|
||||||
api.PageForm
|
api.PageForm
|
||||||
}{}
|
}{}
|
||||||
if err := api.Bind(form)(c); err != nil {
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
|||||||
@ -120,7 +120,7 @@ type (
|
|||||||
Title string `json:"title" form:"title" binding:"required"`
|
Title string `json:"title" form:"title" binding:"required"`
|
||||||
Description string `json:"description" form:"description" binding:"required"`
|
Description string `json:"description" form:"description" binding:"required"`
|
||||||
api.ImageForm
|
api.ImageForm
|
||||||
File string `json:"file" form:"file" binding:"required"`
|
File string `json:"file" form:"file"`
|
||||||
Industrys []string `json:"industrys" form:"industrys"`
|
Industrys []string `json:"industrys" form:"industrys"`
|
||||||
Customers []string `json:"customers" form:"customers"`
|
Customers []string `json:"customers" form:"customers"`
|
||||||
Maturity int `json:"maturity" form:"maturity"`
|
Maturity int `json:"maturity" form:"maturity"`
|
||||||
@ -239,6 +239,19 @@ func (a *Technology) Paper(c *gin.Context) {
|
|||||||
api.APIResponse(err, data)(c)
|
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) {
|
func (a *Technology) PaperAdd(c *gin.Context) {
|
||||||
form := new(paperForm)
|
form := new(paperForm)
|
||||||
|
|
||||||
@ -301,6 +314,19 @@ func (a *Technology) Patent(c *gin.Context) {
|
|||||||
api.APIResponse(err, data)(c)
|
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) {
|
func (a *Technology) PatentDetail(c *gin.Context) {
|
||||||
form := new(api.IDStringForm)
|
form := new(api.IDStringForm)
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,10 @@ type Paper struct {
|
|||||||
type PaperHandle func(session *session.Enterprise, tenantID uint64) *Paper
|
type PaperHandle func(session *session.Enterprise, tenantID uint64) *Paper
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
PaperBasic struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
PaperInfo struct {
|
PaperInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
*model2.TechnologyPaper
|
*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
|
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 参数信息
|
// Form 参数信息
|
||||||
func (c *Paper) Form(params *PaperParams) error {
|
func (c *Paper) Form(params *PaperParams) error {
|
||||||
mTechnologyPaper := model.NewTechnologyPaper()
|
mTechnologyPaper := model.NewTechnologyPaper()
|
||||||
|
|||||||
@ -22,6 +22,10 @@ type Patent struct {
|
|||||||
type PatentHandle func(session *session.Enterprise, tenantID uint64) *Patent
|
type PatentHandle func(session *session.Enterprise, tenantID uint64) *Patent
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
PatentBasic struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
// PatentInfo 专利信息
|
// PatentInfo 专利信息
|
||||||
PatentInfo struct {
|
PatentInfo struct {
|
||||||
ID string `json:"id"`
|
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
|
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 搜索信息
|
// Match 搜索信息
|
||||||
func (c *Patent) Match(title string, industrys, keywords []string) (*controller.ReturnPages, error) {
|
func (c *Patent) Match(title string, industrys, keywords []string) (*controller.ReturnPages, error) {
|
||||||
params := strings.Join([]string{
|
params := strings.Join([]string{
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package api
|
|||||||
import (
|
import (
|
||||||
"SciencesServer/app/api/website/controller"
|
"SciencesServer/app/api/website/controller"
|
||||||
"SciencesServer/app/basic/api"
|
"SciencesServer/app/basic/api"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@ -19,6 +18,6 @@ func (*Config) Index(c *gin.Context) {
|
|||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
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)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,6 +36,7 @@ func GetTenantID() ApiHandle {
|
|||||||
value := c.GetHeader(config.ContentForTenantID)
|
value := c.GetHeader(config.ContentForTenantID)
|
||||||
|
|
||||||
if value == "" {
|
if value == "" {
|
||||||
|
// 登录身份
|
||||||
return uint64(1)
|
return uint64(1)
|
||||||
}
|
}
|
||||||
return utils.StringToUnit64(value)
|
return utils.StringToUnit64(value)
|
||||||
|
|||||||
@ -139,7 +139,7 @@ func (this *Instance) Handle() {
|
|||||||
&synchronized{iModel: model.NewTechnologyProject()}, &synchronized{iModel: model.NewTechnologyTopic()},
|
&synchronized{iModel: model.NewTechnologyProject()}, &synchronized{iModel: model.NewTechnologyTopic()},
|
||||||
&synchronized{iModel: model.NewTechnologyDemandService()}, &synchronized{iModel: model.NewTechnologyDemandServiceProgress()},
|
&synchronized{iModel: model.NewTechnologyDemandService()}, &synchronized{iModel: model.NewTechnologyDemandServiceProgress()},
|
||||||
&synchronized{iModel: model.NewTechnologyPatent()}, &synchronized{iModel: model.NewTechnologyPatentExpert()}, &synchronized{iModel: model.NewTechnologyPatentClassify()},
|
&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.NewServiceMessage()}, &synchronized{iModel: model.NewServiceMessageLog()},
|
||||||
&synchronized{iModel: model.NewServiceSolutionCase()}, &synchronized{iModel: model.NewServiceSolutionCaseKind()},
|
&synchronized{iModel: model.NewServiceSolutionCase()}, &synchronized{iModel: model.NewServiceSolutionCaseKind()},
|
||||||
&synchronized{iModel: model.NewServiceInnovate()}, &synchronized{iModel: model.NewServiceInnovateKind()},
|
&synchronized{iModel: model.NewServiceInnovate()}, &synchronized{iModel: model.NewServiceInnovateKind()},
|
||||||
|
|||||||
@ -522,10 +522,12 @@ func registerEnterpriseAPI(app *gin.Engine) {
|
|||||||
{
|
{
|
||||||
_api := new(api3.Technology)
|
_api := new(api3.Technology)
|
||||||
technologyV1.POST("/paper", _api.Paper)
|
technologyV1.POST("/paper", _api.Paper)
|
||||||
|
technologyV1.POST("/paper/select", _api.PaperSelect)
|
||||||
technologyV1.POST("/paper/add", _api.PaperAdd)
|
technologyV1.POST("/paper/add", _api.PaperAdd)
|
||||||
technologyV1.POST("/paper/edit", _api.PaperEdit)
|
technologyV1.POST("/paper/edit", _api.PaperEdit)
|
||||||
technologyV1.POST("/paper/delete", _api.PaperDelete)
|
technologyV1.POST("/paper/delete", _api.PaperDelete)
|
||||||
technologyV1.POST("/patent", _api.Patent)
|
technologyV1.POST("/patent", _api.Patent)
|
||||||
|
technologyV1.POST("/patent/select", _api.PatentSelect)
|
||||||
technologyV1.POST("/patent/detail", _api.PatentDetail)
|
technologyV1.POST("/patent/detail", _api.PatentDetail)
|
||||||
technologyV1.POST("/patent/add", _api.PatentAdd)
|
technologyV1.POST("/patent/add", _api.PatentAdd)
|
||||||
technologyV1.POST("/patent/edit", _api.PatentEdit)
|
technologyV1.POST("/patent/edit", _api.PatentEdit)
|
||||||
|
|||||||
@ -5,16 +5,34 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// [1,2,3, 4, 5,6,7]
|
||||||
|
// 7
|
||||||
|
// mid: 3
|
||||||
func InArray(search, needle interface{}) bool {
|
func InArray(search, needle interface{}) bool {
|
||||||
val := reflect.ValueOf(needle)
|
val := reflect.ValueOf(needle)
|
||||||
|
|
||||||
kind := val.Kind()
|
kind := val.Kind()
|
||||||
|
|
||||||
if kind == reflect.Slice || kind == reflect.Array {
|
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 {
|
if val.Index(i).Interface() == search {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if val.Index((_length-1)-i).Interface() == search {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _length%2 > 0 {
|
||||||
|
return val.Index(mid).Interface() == search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|||||||
@ -84,6 +84,10 @@ func StructToMap(s interface{}, m map[string]interface{}) {
|
|||||||
fieldNum := tRef.NumField()
|
fieldNum := tRef.NumField()
|
||||||
|
|
||||||
for index := 0; index < fieldNum; index++ {
|
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()
|
m[tRef.Field(index).Name] = vRef.FieldByName(tRef.Field(index).Name).Interface()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user