feat:优化项目信息
This commit is contained in:
38
app/api/admin/api/order.go
Normal file
38
app/api/admin/api/order.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/admin/controller/order"
|
||||||
|
"SciencesServer/app/basic/api"
|
||||||
|
"SciencesServer/app/session"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Order struct{}
|
||||||
|
|
||||||
|
func (*Order) Instance(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
OrderNo string `json:"order_no" form:"order_no"`
|
||||||
|
Name string `json:"name" form:"name"`
|
||||||
|
Mobile string `json:"mobile" form:"mobile"`
|
||||||
|
Status string `json:"status" form:"status"`
|
||||||
|
api.PageForm
|
||||||
|
}{}
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := order.NewInstance()(api.GetSession()(c).(*session.Admin)).Index(form.OrderNo, form.Name, form.Name,
|
||||||
|
form.Status, form.Page, form.PageSize)
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Order) Detail(c *gin.Context) {
|
||||||
|
form := new(api.IDStringForm)
|
||||||
|
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := order.NewInstance()(api.GetSession()(c).(*session.Admin)).Detail(form.Convert())
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
@ -203,6 +203,7 @@ func (*Service) SolutionCaseKindForm(c *gin.Context) {
|
|||||||
api.TenantIDStringForm
|
api.TenantIDStringForm
|
||||||
Mode int `json:"mode" form:"mode" binding:"required"`
|
Mode int `json:"mode" form:"mode" binding:"required"`
|
||||||
Title string `json:"title" form:"title" binding:"required"`
|
Title string `json:"title" form:"title" binding:"required"`
|
||||||
|
Description string `json:"description" form:"description" binding:"required"`
|
||||||
api.ImageForm
|
api.ImageForm
|
||||||
Sort int `json:"sort" form:"sort"`
|
Sort int `json:"sort" form:"sort"`
|
||||||
}{}
|
}{}
|
||||||
@ -212,7 +213,7 @@ func (*Service) SolutionCaseKindForm(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).KindForm(&service.SolutionCaseKindParams{
|
err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).KindForm(&service.SolutionCaseKindParams{
|
||||||
ID: form.IDStringForm.Convert(), TenantID: form.TenantIDStringForm.Convert(), Mode: form.Mode,
|
ID: form.IDStringForm.Convert(), TenantID: form.TenantIDStringForm.Convert(), Mode: form.Mode,
|
||||||
Image: form.FilterImageURL(), Title: form.Title, Sort: form.Sort,
|
Description: form.Description, Image: form.FilterImageURL(), Title: form.Title, Sort: form.Sort,
|
||||||
})
|
})
|
||||||
api.APIResponse(err)(c)
|
api.APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ func (c *Company) Form(params *BasicParams, other *config.IdentityForCompany) er
|
|||||||
if params.ID > 0 {
|
if params.ID > 0 {
|
||||||
mManageCompany.ID = params.ID
|
mManageCompany.ID = params.ID
|
||||||
|
|
||||||
isExist, err := model2.FirstField(mManageCompany.ManageCompany, []string{"id", "name", "code", "tenant_id", "created_at"})
|
isExist, err := model2.FirstField(mManageCompany.ManageCompany, []string{"id", "name", "code", "tenant_id", "examine_status", "created_at"})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -5,10 +5,12 @@ import (
|
|||||||
"SciencesServer/app/basic/config"
|
"SciencesServer/app/basic/config"
|
||||||
"SciencesServer/app/basic/controller"
|
"SciencesServer/app/basic/controller"
|
||||||
model2 "SciencesServer/app/common/model"
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/service"
|
||||||
"SciencesServer/app/session"
|
"SciencesServer/app/session"
|
||||||
config2 "SciencesServer/config"
|
config2 "SciencesServer/config"
|
||||||
"SciencesServer/utils"
|
"SciencesServer/utils"
|
||||||
"errors"
|
"errors"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -136,7 +138,7 @@ func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) erro
|
|||||||
if params.ID > 0 {
|
if params.ID > 0 {
|
||||||
mManageExpert.ID = params.ID
|
mManageExpert.ID = params.ID
|
||||||
|
|
||||||
isExist, err := model2.FirstField(mManageExpert.ManageExpert, []string{"id", "name", "mobile", "tenant_id", "created_at"})
|
isExist, err := model2.FirstField(mManageExpert.ManageExpert, []string{"id", "name", "mobile", "tenant_id", "examine_status", "created_at"})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -158,6 +160,7 @@ func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) erro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mManageExpert.TenantID = c.TenantID
|
mManageExpert.TenantID = c.TenantID
|
||||||
|
mManageExpert.Name = params.Name
|
||||||
mManageExpert.ResearchID = other.ConvertResearch()
|
mManageExpert.ResearchID = other.ConvertResearch()
|
||||||
mManageExpert.LaboratoryID = other.ConvertLaboratory()
|
mManageExpert.LaboratoryID = other.ConvertLaboratory()
|
||||||
mManageExpert.Image.Image = params.Image
|
mManageExpert.Image.Image = params.Image
|
||||||
@ -179,11 +182,26 @@ func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) erro
|
|||||||
if c.TenantID <= 0 {
|
if c.TenantID <= 0 {
|
||||||
mManageExpert.TenantID = params.TenantID
|
mManageExpert.TenantID = params.TenantID
|
||||||
}
|
}
|
||||||
|
_industrys := make([]string, 0)
|
||||||
|
|
||||||
|
for _, v := range params.Industrys {
|
||||||
|
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "-").Value)
|
||||||
|
}
|
||||||
|
manage := service.NewESManage(
|
||||||
|
service.WithManageIdentity(config.TenantUserIdentityForExpert),
|
||||||
|
service.WithManageIndustry(strings.Join(_industrys, ";")),
|
||||||
|
service.WithManageKeyword(strings.Join(params.Keywords, ";")),
|
||||||
|
)
|
||||||
if mManageExpert.ID > 0 {
|
if mManageExpert.ID > 0 {
|
||||||
return model2.Updates(mManageExpert.ManageExpert, mManageExpert.ManageExpert)
|
if err := model2.Updates(mManageExpert.ManageExpert, mManageExpert.ManageExpert); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if mManageExpert.ExamineStatus == model2.ExamineStatusForAgree {
|
||||||
|
_ = manage.Update()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
// 查询手机号码是否在当前租户下是否已经注册了
|
// 查询手机号码是否在当前租户下是否已经注册了
|
||||||
mManageExpert.Name = params.Name
|
|
||||||
mManageExpert.Mobile = params.Mobile
|
mManageExpert.Mobile = params.Mobile
|
||||||
mManageExpert.ExamineStatus = model2.ExamineStatusForAgree
|
mManageExpert.ExamineStatus = model2.ExamineStatusForAgree
|
||||||
mManageExpert.ExamineRemark = "主动创建,无需审核"
|
mManageExpert.ExamineRemark = "主动创建,无需审核"
|
||||||
@ -194,7 +212,13 @@ func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) erro
|
|||||||
} else if isExist {
|
} else if isExist {
|
||||||
return errors.New("操作错误,已存在相同手机号码")
|
return errors.New("操作错误,已存在相同手机号码")
|
||||||
}
|
}
|
||||||
return model2.Create(mManageExpert.ManageExpert)
|
if err := model2.Create(mManageExpert.ManageExpert); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
service.WithManageID(mManageExpert.ID)(manage)
|
||||||
|
service.WithManageTitle(params.Name)(manage)
|
||||||
|
|
||||||
|
return manage.Create()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patent 专利信息
|
// Patent 专利信息
|
||||||
|
@ -119,7 +119,7 @@ func (c *Laboratory) Form(params *BasicParams, other *config.IdentityForLaborato
|
|||||||
|
|
||||||
if params.ID > 0 {
|
if params.ID > 0 {
|
||||||
mManageLaboratory.ID = params.ID
|
mManageLaboratory.ID = params.ID
|
||||||
isExist, err := model2.FirstField(mManageLaboratory.ManageLaboratory, []string{"id", "name", "code", "tenant_id", "created_at"})
|
isExist, err := model2.FirstField(mManageLaboratory.ManageLaboratory, []string{"id", "name", "code", "tenant_id", "examine_status", "created_at"})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -128,7 +128,7 @@ func (c *Research) Form(params *BasicParams, other *config.IdentityForResearch)
|
|||||||
|
|
||||||
if params.ID > 0 {
|
if params.ID > 0 {
|
||||||
mManageResearch.ID = params.ID
|
mManageResearch.ID = params.ID
|
||||||
isExist, err := model2.FirstField(mManageResearch.ManageResearch, []string{"id", "name", "code", "tenant_id", "created_at"})
|
isExist, err := model2.FirstField(mManageResearch.ManageResearch, []string{"id", "name", "code", "tenant_id", "examine_status", "created_at"})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
99
app/api/admin/controller/order/instance.go
Normal file
99
app/api/admin/controller/order/instance.go
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/admin/model"
|
||||||
|
"SciencesServer/app/basic/controller"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/session"
|
||||||
|
"SciencesServer/utils"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Instance struct {
|
||||||
|
*session.Admin
|
||||||
|
}
|
||||||
|
|
||||||
|
type InstanceHandle func(session *session.Admin) *Instance
|
||||||
|
|
||||||
|
type (
|
||||||
|
// InstanceInfo 订单信息
|
||||||
|
InstanceInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
*model.OrderInstanceInfo
|
||||||
|
}
|
||||||
|
// InstanceDetail 订单详细信息
|
||||||
|
InstanceDetail struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
*model.OrderInstanceInfo
|
||||||
|
Params *model2.OrderInstanceParams `json:"params"`
|
||||||
|
}
|
||||||
|
// InstancePageInfo 订单分页信息
|
||||||
|
InstancePageInfo struct {
|
||||||
|
*controller.ReturnPages
|
||||||
|
Amount float64 `json:"amount"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Index 首页信息
|
||||||
|
func (c *Instance) Index(orderNo, name, mobile, status string, page, pageSize int) (*InstancePageInfo, error) {
|
||||||
|
mOrderInstance := model.NewOrderInstance()
|
||||||
|
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
where := make([]*model2.ModelWhere, 0)
|
||||||
|
|
||||||
|
if orderNo != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("o.order_no", orderNo))
|
||||||
|
}
|
||||||
|
if name != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("u.name", name))
|
||||||
|
}
|
||||||
|
if mobile != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("u.mobile", mobile))
|
||||||
|
}
|
||||||
|
if status != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("o.status", utils.StringToInt(status)))
|
||||||
|
}
|
||||||
|
var amount float64
|
||||||
|
|
||||||
|
out, err := mOrderInstance.Orders(page, pageSize, &count, &amount)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*InstanceInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &InstanceInfo{
|
||||||
|
ID: v.GetEncodeID(), OrderInstanceInfo: v,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &InstancePageInfo{
|
||||||
|
ReturnPages: &controller.ReturnPages{Data: list, Count: count},
|
||||||
|
Amount: amount,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail 详细信息
|
||||||
|
func (c *Instance) Detail(id uint64) (*InstanceDetail, error) {
|
||||||
|
mOrderInstance := model.NewOrderInstance()
|
||||||
|
|
||||||
|
out, err := mOrderInstance.Detail(id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if out.ID <= 0 {
|
||||||
|
return nil, errors.New("操作错误,订单信息不存在或已被删除")
|
||||||
|
}
|
||||||
|
return &InstanceDetail{
|
||||||
|
ID: mOrderInstance.GetEncodeID(),
|
||||||
|
OrderInstanceInfo: out,
|
||||||
|
Params: out.GetParamsAttribute(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewInstance() InstanceHandle {
|
||||||
|
return func(session *session.Admin) *Instance {
|
||||||
|
return &Instance{session}
|
||||||
|
}
|
||||||
|
}
|
@ -52,7 +52,7 @@ type (
|
|||||||
SolutionCaseKindParams struct {
|
SolutionCaseKindParams struct {
|
||||||
ID, TenantID uint64
|
ID, TenantID uint64
|
||||||
Mode int
|
Mode int
|
||||||
Title, Image string
|
Title, Image, Description string
|
||||||
Sort int
|
Sort int
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -260,7 +260,8 @@ func (c *SolutionCase) KindForm(params *SolutionCaseKindParams) error {
|
|||||||
if params.ID > 0 {
|
if params.ID > 0 {
|
||||||
mServiceSolutionCaseKind.ID = params.ID
|
mServiceSolutionCaseKind.ID = params.ID
|
||||||
|
|
||||||
isExist, err := model2.FirstField(mServiceSolutionCaseKind.ServiceSolutionCaseKind, []string{"id", "tenant_id", "created_at"})
|
isExist, err := model2.FirstField(mServiceSolutionCaseKind.ServiceSolutionCaseKind,
|
||||||
|
[]string{"id", "tenant_id", "created_at"})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -274,6 +275,7 @@ func (c *SolutionCase) KindForm(params *SolutionCaseKindParams) error {
|
|||||||
mServiceSolutionCaseKind.Mode = model2.ServiceSolutionCaseMode(params.Mode)
|
mServiceSolutionCaseKind.Mode = model2.ServiceSolutionCaseMode(params.Mode)
|
||||||
mServiceSolutionCaseKind.Title = params.Title
|
mServiceSolutionCaseKind.Title = params.Title
|
||||||
mServiceSolutionCaseKind.Image.Image = params.Image
|
mServiceSolutionCaseKind.Image.Image = params.Image
|
||||||
|
mServiceSolutionCaseKind.Description = params.Description
|
||||||
mServiceSolutionCaseKind.Sort = params.Sort
|
mServiceSolutionCaseKind.Sort = params.Sort
|
||||||
|
|
||||||
if mServiceSolutionCaseKind.ID > 0 {
|
if mServiceSolutionCaseKind.ID > 0 {
|
||||||
|
@ -8,13 +8,8 @@ import (
|
|||||||
func TestNewBanner(t *testing.T) {
|
func TestNewBanner(t *testing.T) {
|
||||||
banner := new(Banner)
|
banner := new(Banner)
|
||||||
out := []string{
|
out := []string{
|
||||||
"首页banner",
|
"首页>1>首页",
|
||||||
"登录注册",
|
|
||||||
"解决方案>中小型企业",
|
"解决方案>中小型企业",
|
||||||
"解决方案>大型企业",
|
|
||||||
"找专家>专家列表",
|
|
||||||
"找专家>专家列表1",
|
|
||||||
"找专家>专家列表>专家详情",
|
|
||||||
}
|
}
|
||||||
_out := banner.filter(out, ">")
|
_out := banner.filter(out, ">")
|
||||||
t.Log(_out)
|
t.Log(_out)
|
||||||
|
@ -248,7 +248,7 @@ func (c *Patent) Filter(applyName, inventor string) (*PatentFilterInfo, error) {
|
|||||||
|
|
||||||
experts := make([]*model2.ManageExpert, 0)
|
experts := make([]*model2.ManageExpert, 0)
|
||||||
|
|
||||||
if err = model2.ScanFields(mManageExpert.ManageExpert, &experts, []string{"id", "uid", "name", "mobile"},
|
if err = model2.ScanFields(mManageExpert.ManageExpert, &experts, []string{"id", "name", "mobile"},
|
||||||
&model2.ModelWhereOrder{
|
&model2.ModelWhereOrder{
|
||||||
Where: model2.NewWhere("name", inventor),
|
Where: model2.NewWhere("name", inventor),
|
||||||
}, &model2.ModelWhereOrder{
|
}, &model2.ModelWhereOrder{
|
||||||
@ -288,7 +288,7 @@ func (c *Patent) Delete(id 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"})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
61
app/api/admin/model/order_instance.go
Normal file
61
app/api/admin/model/order_instance.go
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/serve/orm"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OrderInstance struct {
|
||||||
|
*model.OrderInstance
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrderInstanceInfo 订单信息
|
||||||
|
type OrderInstanceInfo struct {
|
||||||
|
*model.OrderInstance
|
||||||
|
Name string `json:"name"`
|
||||||
|
Mobile string `json:"mobile"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Orders 订单信息
|
||||||
|
func (m *OrderInstance) Orders(page, pageSize int, count *int64, amount *float64, where ...*model.ModelWhere) ([]*OrderInstanceInfo, error) {
|
||||||
|
db := orm.GetDB().Table(m.TableName()+" AS o").
|
||||||
|
Select("o.*", "u.name", "u.mobile").
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON o.uid = u.uuid", model.NewUserInstance().TableName())).
|
||||||
|
Where("o.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
if len(where) > 0 {
|
||||||
|
for _, v := range where {
|
||||||
|
db = db.Where(v.Condition, v.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out := make([]*OrderInstanceInfo, 0)
|
||||||
|
|
||||||
|
if err := db.Count(count).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := db.Order("o.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail 订单信息
|
||||||
|
func (m *OrderInstance) Detail(id uint64) (*OrderInstanceInfo, error) {
|
||||||
|
db := orm.GetDB().Table(m.TableName()+" AS o").
|
||||||
|
Select("o.*", "u.name", "u.mobile").
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON o.uid = u.uuid", model.NewUserInstance().TableName())).
|
||||||
|
Where("o.id = ?", id)
|
||||||
|
|
||||||
|
out := new(OrderInstanceInfo)
|
||||||
|
|
||||||
|
if err := db.Scan(&out).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewOrderInstance() *OrderInstance {
|
||||||
|
return &OrderInstance{model.NewOrderInstance()}
|
||||||
|
}
|
@ -1 +0,0 @@
|
|||||||
package api
|
|
@ -118,6 +118,7 @@ type (
|
|||||||
achievementForm struct {
|
achievementForm struct {
|
||||||
Mode int `json:"mode" form:"mode" binding:"required"`
|
Mode int `json:"mode" form:"mode" binding:"required"`
|
||||||
Title string `json:"title" form:"title" binding:"required"`
|
Title string `json:"title" form:"title" 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" binding:"required"`
|
||||||
Industrys []string `json:"industrys" form:"industrys"`
|
Industrys []string `json:"industrys" form:"industrys"`
|
||||||
@ -732,7 +733,7 @@ func (*Technology) AchievementAdd(c *gin.Context) {
|
|||||||
err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)).
|
err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)).
|
||||||
Form(&technology2.AchievementParams{Mode: form.Mode,
|
Form(&technology2.AchievementParams{Mode: form.Mode,
|
||||||
Title: form.Title, Image: form.FilterImageURL(), File: form.FilterFile(),
|
Title: form.Title, Image: form.FilterImageURL(), File: form.FilterFile(),
|
||||||
Introduce: form.Introduce, Industrys: form.Industrys,
|
Description: form.Description, Introduce: form.Introduce, Industrys: form.Industrys,
|
||||||
Maturity: form.Maturity, LeadStandard: form.LeadStandard, CooperationMode: form.CooperationMode,
|
Maturity: form.Maturity, LeadStandard: form.LeadStandard, CooperationMode: form.CooperationMode,
|
||||||
Customers: form.Customers, Keywords: form.Keywords, IsSubmit: form.IsSubmit,
|
Customers: form.Customers, Keywords: form.Keywords, IsSubmit: form.IsSubmit,
|
||||||
})
|
})
|
||||||
@ -751,7 +752,7 @@ func (*Technology) AchievementEdit(c *gin.Context) {
|
|||||||
err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)).
|
err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)).
|
||||||
Form(&technology2.AchievementParams{ID: form.Convert(), Mode: form.Mode,
|
Form(&technology2.AchievementParams{ID: form.Convert(), Mode: form.Mode,
|
||||||
Title: form.Title, Image: form.FilterImageURL(), File: form.FilterFile(),
|
Title: form.Title, Image: form.FilterImageURL(), File: form.FilterFile(),
|
||||||
Introduce: form.Introduce, Industrys: form.Industrys,
|
Description: form.Description, Introduce: form.Introduce, Industrys: form.Industrys,
|
||||||
Maturity: form.Maturity, LeadStandard: form.LeadStandard, CooperationMode: form.CooperationMode,
|
Maturity: form.Maturity, LeadStandard: form.LeadStandard, CooperationMode: form.CooperationMode,
|
||||||
Customers: form.Customers, Keywords: form.Keywords, IsSubmit: form.IsSubmit,
|
Customers: form.Customers, Keywords: form.Keywords, IsSubmit: form.IsSubmit,
|
||||||
})
|
})
|
||||||
|
@ -173,6 +173,8 @@ func (*User) ConsumeDelete(c *gin.Context) {
|
|||||||
api.APIResponse(err)(c)
|
api.APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 提现管理
|
||||||
|
|
||||||
func (*User) Withdrawal(c *gin.Context) {
|
func (*User) Withdrawal(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
Status int `json:"status" form:"status"`
|
Status int `json:"status" form:"status"`
|
||||||
|
@ -22,7 +22,7 @@ type (
|
|||||||
InstanceLoginParams struct {
|
InstanceLoginParams struct {
|
||||||
UID uint64
|
UID uint64
|
||||||
Avatar, Name, Mobile string
|
Avatar, Name, Mobile string
|
||||||
Vip model2.UserInstanceVipKind
|
Vip uint64
|
||||||
VipStatus bool
|
VipStatus bool
|
||||||
VipDeadline time.Time
|
VipDeadline time.Time
|
||||||
Currency float64
|
Currency float64
|
||||||
|
@ -1 +0,0 @@
|
|||||||
package config
|
|
1
app/api/enterprise/controller/sys/instance.go
Normal file
1
app/api/enterprise/controller/sys/instance.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package sys
|
54
app/api/enterprise/controller/sys/vip.go
Normal file
54
app/api/enterprise/controller/sys/vip.go
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package sys
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/enterprise/model"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/session"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Vip struct {
|
||||||
|
*session.Enterprise
|
||||||
|
}
|
||||||
|
|
||||||
|
type VipHandle func(session *session.Enterprise) *Vip
|
||||||
|
|
||||||
|
type (
|
||||||
|
// VipInfo 会员信息
|
||||||
|
VipInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
*model2.SysVip
|
||||||
|
}
|
||||||
|
// VipInstance 会员首页信息
|
||||||
|
VipInstance struct {
|
||||||
|
Data []*VipInfo `json:"data"`
|
||||||
|
Functions map[int]string `json:"functions"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Instance 首页信息
|
||||||
|
func (c *Vip) Instance() (*VipInstance, error) {
|
||||||
|
mSysVip := model.NewSysVip()
|
||||||
|
|
||||||
|
out := make([]*model2.SysVip, 0)
|
||||||
|
|
||||||
|
if err := model2.Scan(mSysVip.SysVip, &out); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
data := make([]*VipInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
data = append(data, &VipInfo{
|
||||||
|
ID: v.GetEncodeID(), SysVip: v,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &VipInstance{
|
||||||
|
Data: data,
|
||||||
|
Functions: mSysVip.GetFunctions(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewVip() VipHandle {
|
||||||
|
return func(session *session.Enterprise) *Vip {
|
||||||
|
return &Vip{session}
|
||||||
|
}
|
||||||
|
}
|
@ -45,7 +45,7 @@ type (
|
|||||||
// AchievementParams 成果参数信息
|
// AchievementParams 成果参数信息
|
||||||
AchievementParams struct {
|
AchievementParams struct {
|
||||||
ID uint64
|
ID uint64
|
||||||
Title, Image, File, Introduce, Source string
|
Title, Image, File, Introduce, Description string
|
||||||
Mode, Maturity, LeadStandard, CooperationMode int // 技术成熟度 领先标准 合作模式
|
Mode, Maturity, LeadStandard, CooperationMode int // 技术成熟度 领先标准 合作模式
|
||||||
Industrys, Customers, Keywords []string // 所属客户 关键词
|
Industrys, Customers, Keywords []string // 所属客户 关键词
|
||||||
IsSubmit int // 是否提交审核
|
IsSubmit int // 是否提交审核
|
||||||
@ -177,7 +177,7 @@ func (c *Achievement) Form(params *AchievementParams) error {
|
|||||||
mTechnologyAchievement.CooperationMode = config.TechnologyCooperationMode(params.CooperationMode)
|
mTechnologyAchievement.CooperationMode = config.TechnologyCooperationMode(params.CooperationMode)
|
||||||
mTechnologyAchievement.SetKeywordAttribute(params.Keywords)
|
mTechnologyAchievement.SetKeywordAttribute(params.Keywords)
|
||||||
mTechnologyAchievement.Introduce = params.Introduce
|
mTechnologyAchievement.Introduce = params.Introduce
|
||||||
mTechnologyAchievement.Source = params.Source
|
mTechnologyAchievement.Description = params.Description
|
||||||
|
|
||||||
if mTechnologyAchievement.ID > 0 {
|
if mTechnologyAchievement.ID > 0 {
|
||||||
mTechnologyAchievement.Status = model2.TechnologyStatusKindForExamining
|
mTechnologyAchievement.Status = model2.TechnologyStatusKindForExamining
|
||||||
|
68
app/api/enterprise/controller/user/vip.go
Normal file
68
app/api/enterprise/controller/user/vip.go
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/enterprise/model"
|
||||||
|
"SciencesServer/app/basic/controller"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/session"
|
||||||
|
"SciencesServer/lib"
|
||||||
|
"errors"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Vip struct {
|
||||||
|
*session.Enterprise
|
||||||
|
}
|
||||||
|
|
||||||
|
type VipHandle func(session *session.Enterprise) *Vip
|
||||||
|
|
||||||
|
// Open 开通会员
|
||||||
|
func (c *Vip) Open(id uint64) (*controller.ReturnPayment, error) {
|
||||||
|
mSysVip := model.NewSysVip()
|
||||||
|
mSysVip.ID = id
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mSysVip.SysVip, []string{"id", "level", "effect_time", "price", "is_disabled"})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if !isExist {
|
||||||
|
return nil, errors.New("操作错误,会员信息不存在或已删除")
|
||||||
|
} else if mSysVip.IsDeleted > 0 {
|
||||||
|
return nil, errors.New("操作错误,当前会员不允许开通")
|
||||||
|
}
|
||||||
|
// 查询用户会员信息
|
||||||
|
mUserInstance := model.NewUserInstance()
|
||||||
|
|
||||||
|
if _, err = model2.FirstField(mUserInstance.UserInstance, []string{"id", "vip", "vip_deadline"},
|
||||||
|
model2.NewWhere("uuid", c.UID)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// 会员状态有效期内,不可降级
|
||||||
|
if mUserInstance.VipStatus() {
|
||||||
|
mSysVip2 := model.NewSysVip()
|
||||||
|
mSysVip2.ID = mUserInstance.Vip
|
||||||
|
|
||||||
|
if isExist, err = model2.FirstField(mSysVip2.SysVip, []string{"id", "level"}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if isExist && mSysVip2.Level > mSysVip.Level {
|
||||||
|
return nil, errors.New("操作错误,会员有效期间内不可以降级")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mOrderInstance := model.NewOrderInstance()
|
||||||
|
mOrderInstance.UID = c.UID
|
||||||
|
mOrderInstance.OrderNo = lib.OrderNo()
|
||||||
|
mOrderInstance.Amount = mSysVip.Price
|
||||||
|
mOrderInstance.SetParamsAttribute(model2.OrderInstanceParamsKindForVIP, &model2.OrderInstanceParamsForVip{
|
||||||
|
ID: mSysVip.ID, EffectTime: mSysVip.EffectTime,
|
||||||
|
})
|
||||||
|
return &controller.ReturnPayment{
|
||||||
|
Auth: mOrderInstance.GetEncodeID(),
|
||||||
|
Timestamp: time.Now().Unix(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewVip() VipHandle {
|
||||||
|
return func(session *session.Enterprise) *Vip {
|
||||||
|
return &Vip{session}
|
||||||
|
}
|
||||||
|
}
|
11
app/api/enterprise/model/sys_vip.go
Normal file
11
app/api/enterprise/model/sys_vip.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "SciencesServer/app/common/model"
|
||||||
|
|
||||||
|
type SysVip struct {
|
||||||
|
*model.SysVip
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSysVip() *SysVip {
|
||||||
|
return &SysVip{model.NewSysVip()}
|
||||||
|
}
|
19
app/api/website/api/payment.go
Normal file
19
app/api/website/api/payment.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/website/controller/payment"
|
||||||
|
"SciencesServer/app/basic/api"
|
||||||
|
"SciencesServer/app/session"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Payment 支付管理
|
||||||
|
type Payment struct{}
|
||||||
|
|
||||||
|
func (*Payment) Launch(c *gin.Context) {
|
||||||
|
payment.NewInstance()(api.GetSession()(c).(*session.Enterprise)).Launch(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Payment) Callback(c *gin.Context) {
|
||||||
|
|
||||||
|
}
|
46
app/api/website/controller/payment/activity.go
Normal file
46
app/api/website/controller/payment/activity.go
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package payment
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/website/model"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Activity struct {
|
||||||
|
uid, activityID uint64
|
||||||
|
identity int
|
||||||
|
}
|
||||||
|
|
||||||
|
type ActivityCallback func(uid, activityID uint64, identity int) *Activity
|
||||||
|
|
||||||
|
func (c *Activity) grant(tx *gorm.DB) error {
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
mActivityJoin := model.NewActivityJoin()
|
||||||
|
|
||||||
|
err := model2.Count(mActivityJoin.ActivityJoin, &count, model2.NewWhere("uid", c.uid),
|
||||||
|
model2.NewWhere("activity_id", c.activityID),
|
||||||
|
model2.NewWhere("identity", c.identity),
|
||||||
|
model2.NewWhere("status", model2.ActivityJoinStatusForSuccess))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if count > 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
mActivityJoin.UID = c.uid
|
||||||
|
mActivityJoin.ActivityID = c.activityID
|
||||||
|
mActivityJoin.Identity = c.identity
|
||||||
|
mActivityJoin.Status = model2.ActivityJoinStatusForSuccess
|
||||||
|
return model2.Create(mActivityJoin.ActivityJoin, tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewActivity() ActivityCallback {
|
||||||
|
return func(uid, activityID uint64, identity int) *Activity {
|
||||||
|
return &Activity{
|
||||||
|
uid: uid,
|
||||||
|
activityID: activityID,
|
||||||
|
identity: identity,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
115
app/api/website/controller/payment/instance.go
Normal file
115
app/api/website/controller/payment/instance.go
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
package payment
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/website/model"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/session"
|
||||||
|
"SciencesServer/serve/orm"
|
||||||
|
"errors"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Instance 支付管理
|
||||||
|
type Instance struct {
|
||||||
|
*session.Enterprise
|
||||||
|
}
|
||||||
|
|
||||||
|
type IInstance interface {
|
||||||
|
grant(tx *gorm.DB) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type InstanceHandle func(session *session.Enterprise) *Instance
|
||||||
|
|
||||||
|
type InstanceGrant struct {
|
||||||
|
tx *gorm.DB
|
||||||
|
uid uint64
|
||||||
|
params *model2.OrderInstanceParams
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle 发放操作
|
||||||
|
func (c *InstanceGrant) handle() error {
|
||||||
|
var _handle IInstance
|
||||||
|
|
||||||
|
if c.params.Kind == model2.OrderInstanceParamsKindForActivity {
|
||||||
|
data := c.params.Data.(*model2.OrderInstanceParamsForActivity)
|
||||||
|
_handle = NewActivity()(c.uid, data.ID, data.Identity)
|
||||||
|
} else if c.params.Kind == model2.OrderInstanceParamsKindForVIP {
|
||||||
|
data := c.params.Data.(*model2.OrderInstanceParamsForVip)
|
||||||
|
_handle = NewVip()(c.uid, data.ID, data.EffectTime)
|
||||||
|
}
|
||||||
|
if _handle != nil {
|
||||||
|
return _handle.grant(c.tx)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Launch 支付发起
|
||||||
|
func (c *Instance) Launch(id uint64) (interface{}, error) {
|
||||||
|
mOrderInstance := model.NewOrderInstance()
|
||||||
|
mOrderInstance.ID = id
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mOrderInstance.OrderInstance, []string{"id", "order_no", "amount", "status"})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if !isExist {
|
||||||
|
return nil, errors.New("操作错误,订单信息不存在或已被删除")
|
||||||
|
} else if mOrderInstance.Status != model2.OrderInstanceStatusForInit {
|
||||||
|
return nil, errors.New("操作错误,当前订单状态不允许支付")
|
||||||
|
}
|
||||||
|
// 保存日志
|
||||||
|
mOrderLog := model.NewOrderLog()
|
||||||
|
mOrderLog.UID = c.UID
|
||||||
|
mOrderLog.OrderID = id
|
||||||
|
|
||||||
|
if err = model2.Create(mOrderLog.OrderLog); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// 返回第三方支付接口参数
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Callback 支付回调
|
||||||
|
func (c *Instance) Callback(orderNo string) error {
|
||||||
|
mOrderInstance := model.NewOrderInstance()
|
||||||
|
isExist, err := model2.FirstField(mOrderInstance.OrderInstance, []string{"id", "uid", "amount", "params", "status"},
|
||||||
|
model2.NewWhere("order_no", orderNo))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("订单信息不存在或已被删除")
|
||||||
|
} else if mOrderInstance.OrderInstance.Status != model2.OrderInstanceStatusForInit {
|
||||||
|
// 状态异常
|
||||||
|
return errors.New("状态异常,不允许支付")
|
||||||
|
}
|
||||||
|
now := time.Now()
|
||||||
|
|
||||||
|
// 更改订单状态为已支付
|
||||||
|
if err = model2.Updates(mOrderInstance.OrderInstance, map[string]interface{}{
|
||||||
|
"status": model2.OrderInstanceStatusForPaid, "updated_at": now,
|
||||||
|
}); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||||
|
// 发放操作
|
||||||
|
if err = (&InstanceGrant{
|
||||||
|
tx: tx, uid: mOrderInstance.UID, params: mOrderInstance.GetParamsAttribute(),
|
||||||
|
}).handle(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err = model2.Updates(mOrderInstance.OrderInstance, map[string]interface{}{
|
||||||
|
"status": model2.OrderInstanceStatusForComplete, "updated_at": now,
|
||||||
|
}, tx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewInstance() InstanceHandle {
|
||||||
|
return func(session *session.Enterprise) *Instance {
|
||||||
|
return &Instance{session}
|
||||||
|
}
|
||||||
|
}
|
49
app/api/website/controller/payment/vip.go
Normal file
49
app/api/website/controller/payment/vip.go
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package payment
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/website/model"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Vip 会员信息
|
||||||
|
type Vip struct {
|
||||||
|
uid, vipID uint64
|
||||||
|
effectTime int
|
||||||
|
}
|
||||||
|
|
||||||
|
type VipCallback func(uid, vipID uint64, effectTime int) *Vip
|
||||||
|
|
||||||
|
func (c *Vip) grant(tx *gorm.DB) error {
|
||||||
|
mUserInstance := model.NewUserInstance()
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mUserInstance.UserInstance, []string{"id", "vip", "vip_deadline"},
|
||||||
|
model2.NewWhere("uuid", c.uid))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if isExist {
|
||||||
|
if mUserInstance.VipStatus() {
|
||||||
|
mUserInstance.Vip = c.vipID
|
||||||
|
mUserInstance.VipDeadline = mUserInstance.VipDeadline.AddDate(0, c.effectTime, 0)
|
||||||
|
} else {
|
||||||
|
mUserInstance.Vip = c.vipID
|
||||||
|
mUserInstance.VipDeadline = time.Now().AddDate(0, c.effectTime, 0)
|
||||||
|
}
|
||||||
|
if err = model2.Updates(mUserInstance.UserInstance, map[string]interface{}{
|
||||||
|
"vip": mUserInstance.Vip, "vip_deadline": mUserInstance.VipDeadline, "updated_at": time.Now(),
|
||||||
|
}, tx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewVip() VipCallback {
|
||||||
|
return func(uid, vipID uint64, effectTime int) *Vip {
|
||||||
|
return &Vip{
|
||||||
|
uid: uid, vipID: vipID, effectTime: effectTime,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,9 @@ type (
|
|||||||
AchievementInfo struct {
|
AchievementInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
*model.TechnologyAchievementInfo
|
*model.TechnologyAchievementInfo
|
||||||
|
ModeTitle string `json:"mode_title"`
|
||||||
|
MaturityTitle string `json:"maturity_title"`
|
||||||
|
CooperationModeTitle string `json:"cooperation_mode_title"`
|
||||||
Customers []string `json:"customers"`
|
Customers []string `json:"customers"`
|
||||||
Industrys []string `json:"industrys"`
|
Industrys []string `json:"industrys"`
|
||||||
Keywords []string `json:"keywords"`
|
Keywords []string `json:"keywords"`
|
||||||
@ -63,6 +66,8 @@ func achievementSearch(page, pageSize int, keyword, industry string, params map[
|
|||||||
list = append(list, &AchievementInfo{
|
list = append(list, &AchievementInfo{
|
||||||
ID: v.GetEncodeID(), TechnologyAchievementInfo: v,
|
ID: v.GetEncodeID(), TechnologyAchievementInfo: v,
|
||||||
Customers: v.GetCustomerAttribute(),
|
Customers: v.GetCustomerAttribute(),
|
||||||
|
ModeTitle: v.GetModeTitle(), MaturityTitle: config.GetTechnologyMaturityTitle(v.Maturity),
|
||||||
|
CooperationModeTitle: config.GetTechnologyCooperationModeTitle(v.CooperationMode),
|
||||||
Industrys: _industrys, Keywords: v.GetKeywordAttribute(),
|
Industrys: _industrys, Keywords: v.GetKeywordAttribute(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,9 @@ func (c *SolutionCase) Instance(mode int) ([]*SolutionCaseInfo, error) {
|
|||||||
Image: (&model2.Image{Image: v.DetailImage}).Analysis(config.SystemConfig[config.SysImageDomain]),
|
Image: (&model2.Image{Image: v.DetailImage}).Analysis(config.SystemConfig[config.SysImageDomain]),
|
||||||
Description: v.DetailDescription,
|
Description: v.DetailDescription,
|
||||||
}
|
}
|
||||||
|
if v.DetailID <= 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
for _, val := range ret {
|
for _, val := range ret {
|
||||||
if v.ID == val.MarkID {
|
if v.ID == val.MarkID {
|
||||||
val.Children = append(val.Children, detail)
|
val.Children = append(val.Children, detail)
|
||||||
|
@ -24,6 +24,8 @@ func (c *Banner) Instance(key string) (*BannerInfo, error) {
|
|||||||
"key": key, "local": key,
|
"key": key, "local": key,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
} else if mSysBanner.ID <= 0 {
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
return &BannerInfo{
|
return &BannerInfo{
|
||||||
ID: mSysBanner.GetEncodeID(),
|
ID: mSysBanner.GetEncodeID(),
|
||||||
|
@ -23,11 +23,14 @@ type (
|
|||||||
AchievementInfo struct {
|
AchievementInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
|
ModeTitle string `json:"mode_title"`
|
||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
Industrys []string `json:"industrys"`
|
Industrys []string `json:"industrys"`
|
||||||
Customers []string `json:"customers"`
|
Customers []string `json:"customers"`
|
||||||
Maturity config2.TechnologyMaturity `json:"maturity"`
|
Maturity config2.TechnologyMaturity `json:"maturity"`
|
||||||
|
MaturityTitle string `json:"maturity_title"`
|
||||||
CooperationMode config2.TechnologyCooperationMode `json:"cooperation_mode"`
|
CooperationMode config2.TechnologyCooperationMode `json:"cooperation_mode"`
|
||||||
|
CooperationModeTitle string `json:"cooperation_mode_title"`
|
||||||
Keywords []string `json:"keywords"`
|
Keywords []string `json:"keywords"`
|
||||||
VisitCount int `json:"visit_count"`
|
VisitCount int `json:"visit_count"`
|
||||||
CollectCount int `json:"collect_count"`
|
CollectCount int `json:"collect_count"`
|
||||||
@ -65,11 +68,14 @@ func (c *Achievement) Instance(title, industry string, page, pageSize int) (*con
|
|||||||
list = append(list, &AchievementInfo{
|
list = append(list, &AchievementInfo{
|
||||||
ID: v.GetEncodeID(),
|
ID: v.GetEncodeID(),
|
||||||
Title: v.Title,
|
Title: v.Title,
|
||||||
|
ModeTitle: v.GetModeTitle(),
|
||||||
Image: v.Image.Analysis(config.SystemConfig[config.SysImageDomain]),
|
Image: v.Image.Analysis(config.SystemConfig[config.SysImageDomain]),
|
||||||
Industrys: v.GetIndustryAttribute(),
|
Industrys: v.GetIndustryAttribute(),
|
||||||
Customers: v.GetCustomerAttribute(),
|
Customers: v.GetCustomerAttribute(),
|
||||||
Maturity: v.Maturity,
|
Maturity: v.Maturity,
|
||||||
|
MaturityTitle: config2.GetTechnologyMaturityTitle(v.Maturity),
|
||||||
CooperationMode: v.CooperationMode,
|
CooperationMode: v.CooperationMode,
|
||||||
|
CooperationModeTitle: config2.GetTechnologyCooperationModeTitle(v.CooperationMode),
|
||||||
Keywords: v.GetKeywordAttribute(),
|
Keywords: v.GetKeywordAttribute(),
|
||||||
VisitCount: v.VisitCount,
|
VisitCount: v.VisitCount,
|
||||||
CollectCount: v.CollectCount,
|
CollectCount: v.CollectCount,
|
||||||
@ -86,7 +92,7 @@ func (c *Achievement) Detail(id uint64) (*AchievementDetailInfo, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if out.ID <= 0 {
|
} else if out == nil || out.ID <= 0 {
|
||||||
return nil, errors.New("操作错误,成果信息不存在或已被删除")
|
return nil, errors.New("操作错误,成果信息不存在或已被删除")
|
||||||
}
|
}
|
||||||
//var uid uint64 = 0
|
//var uid uint64 = 0
|
||||||
@ -107,11 +113,14 @@ func (c *Achievement) Detail(id uint64) (*AchievementDetailInfo, error) {
|
|||||||
AchievementInfo: AchievementInfo{
|
AchievementInfo: AchievementInfo{
|
||||||
ID: out.GetEncodeID(),
|
ID: out.GetEncodeID(),
|
||||||
Title: out.Title,
|
Title: out.Title,
|
||||||
|
ModeTitle: out.GetModeTitle(),
|
||||||
Image: out.Image.Analysis(config.SystemConfig[config.SysImageDomain]),
|
Image: out.Image.Analysis(config.SystemConfig[config.SysImageDomain]),
|
||||||
Industrys: out.GetIndustryAttribute(),
|
Industrys: out.GetIndustryAttribute(),
|
||||||
Customers: out.GetCustomerAttribute(),
|
Customers: out.GetCustomerAttribute(),
|
||||||
Maturity: out.Maturity,
|
Maturity: out.Maturity,
|
||||||
|
MaturityTitle: config2.GetTechnologyMaturityTitle(out.Maturity),
|
||||||
CooperationMode: out.CooperationMode,
|
CooperationMode: out.CooperationMode,
|
||||||
|
CooperationModeTitle: config2.GetTechnologyCooperationModeTitle(out.CooperationMode),
|
||||||
Keywords: out.GetKeywordAttribute(),
|
Keywords: out.GetKeywordAttribute(),
|
||||||
VisitCount: out.VisitCount,
|
VisitCount: out.VisitCount,
|
||||||
CollectCount: out.CollectCount,
|
CollectCount: out.CollectCount,
|
||||||
|
11
app/api/website/model/order_instance.go
Normal file
11
app/api/website/model/order_instance.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "SciencesServer/app/common/model"
|
||||||
|
|
||||||
|
type OrderInstance struct {
|
||||||
|
*model.OrderInstance
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewOrderInstance() *OrderInstance {
|
||||||
|
return &OrderInstance{model.NewOrderInstance()}
|
||||||
|
}
|
11
app/api/website/model/order_log.go
Normal file
11
app/api/website/model/order_log.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "SciencesServer/app/common/model"
|
||||||
|
|
||||||
|
type OrderLog struct {
|
||||||
|
*model.OrderLog
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewOrderLog() *OrderLog {
|
||||||
|
return &OrderLog{model.NewOrderLog()}
|
||||||
|
}
|
11
app/api/website/model/user_instance.go
Normal file
11
app/api/website/model/user_instance.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "SciencesServer/app/common/model"
|
||||||
|
|
||||||
|
type UserInstance struct {
|
||||||
|
*model.UserInstance
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserInstance() *UserInstance {
|
||||||
|
return &UserInstance{model.NewUserInstance()}
|
||||||
|
}
|
@ -35,7 +35,7 @@ func GetTenantID() ApiHandle {
|
|||||||
value := c.GetHeader(config.ContentForTenantID)
|
value := c.GetHeader(config.ContentForTenantID)
|
||||||
|
|
||||||
if value == "" {
|
if value == "" {
|
||||||
return uint64(0)
|
return uint64(1)
|
||||||
}
|
}
|
||||||
return utils.StringToUnit64(value)
|
return utils.StringToUnit64(value)
|
||||||
}
|
}
|
||||||
|
@ -5,3 +5,9 @@ type ReturnPages struct {
|
|||||||
Data interface{} `json:"data"`
|
Data interface{} `json:"data"`
|
||||||
Count int64 `json:"count"`
|
Count int64 `json:"count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReturnPayment 充值数据
|
||||||
|
type ReturnPayment struct {
|
||||||
|
Auth string `json:"auth"`
|
||||||
|
Timestamp int64 `json:"timestamp"`
|
||||||
|
}
|
||||||
|
@ -116,6 +116,7 @@ func (this *Instance) Handle() {
|
|||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}},
|
}},
|
||||||
|
&synchronized{iModel: model.NewSysVip()},
|
||||||
&synchronized{iModel: model.NewSysNavigation()}, &synchronized{iModel: model.NewSysAbout()},
|
&synchronized{iModel: model.NewSysNavigation()}, &synchronized{iModel: model.NewSysAbout()},
|
||||||
&synchronized{iModel: model.NewSysBanner()}, &synchronized{iModel: model.NewSysAgreement()},
|
&synchronized{iModel: model.NewSysBanner()}, &synchronized{iModel: model.NewSysAgreement()},
|
||||||
// 日志管理
|
// 日志管理
|
||||||
|
@ -2,6 +2,9 @@ package model
|
|||||||
|
|
||||||
import "encoding/json"
|
import "encoding/json"
|
||||||
|
|
||||||
|
type IOrderInstance interface {
|
||||||
|
}
|
||||||
|
|
||||||
// OrderInstance 订单数据模型
|
// OrderInstance 订单数据模型
|
||||||
type OrderInstance struct {
|
type OrderInstance struct {
|
||||||
Model
|
Model
|
||||||
@ -29,12 +32,22 @@ type OrderInstanceParamsKind int
|
|||||||
const (
|
const (
|
||||||
// OrderInstanceParamsKindForActivity 活动信息
|
// OrderInstanceParamsKindForActivity 活动信息
|
||||||
OrderInstanceParamsKindForActivity OrderInstanceParamsKind = iota + 1e2 + 1
|
OrderInstanceParamsKindForActivity OrderInstanceParamsKind = iota + 1e2 + 1
|
||||||
|
// OrderInstanceParamsKindForVIP 会员信息
|
||||||
|
OrderInstanceParamsKindForVIP
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
// OrderInstanceParamsForActivity 订单活动参数
|
// OrderInstanceParamsForActivity 订单活动参数
|
||||||
type OrderInstanceParamsForActivity struct {
|
OrderInstanceParamsForActivity struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
Identity int `json:"identity"`
|
||||||
}
|
}
|
||||||
|
// OrderInstanceParamsForVip 会员参数
|
||||||
|
OrderInstanceParamsForVip struct {
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
EffectTime int `json:"effect_time"` // 有效时长,月
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
// OrderInstanceStatus 订单状态
|
// OrderInstanceStatus 订单状态
|
||||||
type OrderInstanceStatus int
|
type OrderInstanceStatus int
|
||||||
@ -56,7 +69,7 @@ func (m *OrderInstance) TableName() string {
|
|||||||
return "order_instance"
|
return "order_instance"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *OrderInstance) SetParamsAttribute(kind OrderInstanceParamsKind, data interface{}) {
|
func (m *OrderInstance) SetParamsAttribute(kind OrderInstanceParamsKind, data IOrderInstance) {
|
||||||
value := &OrderInstanceParams{Kind: kind, Data: data}
|
value := &OrderInstanceParams{Kind: kind, Data: data}
|
||||||
_bytes, _ := json.Marshal(value)
|
_bytes, _ := json.Marshal(value)
|
||||||
m.Params = string(_bytes)
|
m.Params = string(_bytes)
|
||||||
|
@ -7,6 +7,7 @@ type ServiceSolutionCaseKind struct {
|
|||||||
Title string `gorm:"column:title;type:varchar(100);default:'';comment:标题" json:"title"`
|
Title string `gorm:"column:title;type:varchar(100);default:'';comment:标题" json:"title"`
|
||||||
Image
|
Image
|
||||||
Mode ServiceSolutionCaseMode `gorm:"column:mode;type:tinyint(3);default:0;comment:方案模式" json:"mode"`
|
Mode ServiceSolutionCaseMode `gorm:"column:mode;type:tinyint(3);default:0;comment:方案模式" json:"mode"`
|
||||||
|
Description string `gorm:"column:description;type:varchar(255);default:'';comment:方案描述" json:"description"`
|
||||||
Sort int `gorm:"column:sort;type:tinyint(3);default:0;comment:排序,数值越小,优先排序" json:"sort"`
|
Sort int `gorm:"column:sort;type:tinyint(3);default:0;comment:排序,数值越小,优先排序" json:"sort"`
|
||||||
ModelDeleted
|
ModelDeleted
|
||||||
ModelAt
|
ModelAt
|
||||||
|
54
app/common/model/sys_vip.go
Normal file
54
app/common/model/sys_vip.go
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// SysVip 会员配置数据模型
|
||||||
|
type SysVip struct {
|
||||||
|
Model
|
||||||
|
Level int `gorm:"column:level;tinyint(1);default:0;comment:会员等级" json:"level"`
|
||||||
|
Title string `gorm:"column:title;varchar(100);default:'';comment:会员名称" json:"title"`
|
||||||
|
Price float64 `gorm:"column:price;decimal(10,2);default:0;comment:价格" json:"price"`
|
||||||
|
EffectTime int `gorm:"column:effect_time;tinyint(3);default:0;comment:有效时长、月" json:"effect_time"`
|
||||||
|
Discount float64 `gorm:"column:discount;decimal(10,2);default:0;comment:折扣" json:"discount"`
|
||||||
|
Currency float64 `gorm:"column:currency;decimal(10,2);default:0;comment:赠送的创新币" json:"currency"`
|
||||||
|
Function int `gorm:"column:function;tinyint(3);default:0;comment:支持功能" json:"function"`
|
||||||
|
IsHidden SysVipStatus `gorm:"column:is_hidden;tinyint(1);default:0;comment:隐藏状态" json:"is_hidden"`
|
||||||
|
IsDisabled int `gorm:"column:is_disabled;tinyint(1);default:0;comment:禁用状态,不可充值" json:"is_disabled"`
|
||||||
|
ModelDeleted
|
||||||
|
ModelAt
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
// SysVipOpenFunctionForSearch 任意检索
|
||||||
|
SysVipOpenFunctionForSearch int = 1 << 0
|
||||||
|
// SysVipOpenFunctionForAchievementPush 创新科技资源自动匹配推送功能
|
||||||
|
SysVipOpenFunctionForAchievementPush int = 1 << 1
|
||||||
|
// SysVipOpenFunctionForHighCompanyDemand 上市公司及优质客户的企业需求优先推送
|
||||||
|
SysVipOpenFunctionForHighCompanyDemand int = 1 << 2
|
||||||
|
// SysVipOpenFunctionForOrdinaryCompanyDemand 普通企业的需求匹配推送
|
||||||
|
SysVipOpenFunctionForOrdinaryCompanyDemand int = 1 << 3
|
||||||
|
// SysVipOpenFunctionForMachImport 匹配结果文件导出
|
||||||
|
SysVipOpenFunctionForMachImport int = 1 << 4
|
||||||
|
// SysVipOpenFunctionForOverseasDemand 海外需求推荐
|
||||||
|
SysVipOpenFunctionForOverseasDemand int = 1 << 5
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysVipStatus 会员状态
|
||||||
|
type SysVipStatus int
|
||||||
|
|
||||||
|
func (m *SysVip) TableName() string {
|
||||||
|
return "sys_vip"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SysVip) GetFunctions() map[int]string {
|
||||||
|
return map[int]string{
|
||||||
|
SysVipOpenFunctionForSearch: "任意检索",
|
||||||
|
SysVipOpenFunctionForAchievementPush: "创新科技资源自动匹配推送功能",
|
||||||
|
SysVipOpenFunctionForHighCompanyDemand: "上市公司及优质客户的企业需求优先推送",
|
||||||
|
SysVipOpenFunctionForOrdinaryCompanyDemand: "普通企业的需求匹配推送",
|
||||||
|
SysVipOpenFunctionForMachImport: "匹配结果文件导出",
|
||||||
|
SysVipOpenFunctionForOverseasDemand: "海外需求推荐",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSysVip() *SysVip {
|
||||||
|
return &SysVip{}
|
||||||
|
}
|
@ -12,6 +12,7 @@ type TechnologyAchievement struct {
|
|||||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||||
Mode TechnologyAchievementMode `gorm:"column:mode;type:tinyint(1);default:1;comment:成果模式" json:"mode"`
|
Mode TechnologyAchievementMode `gorm:"column:mode;type:tinyint(1);default:1;comment:成果模式" json:"mode"`
|
||||||
Title string `gorm:"column:title;type:varchar(100);default:'';comment:成果名称" json:"title"`
|
Title string `gorm:"column:title;type:varchar(100);default:'';comment:成果名称" json:"title"`
|
||||||
|
Description string `gorm:"source:description;type:varchar(255);comment:成果描述" json:"description"`
|
||||||
Image
|
Image
|
||||||
File string `gorm:"column:file;type:varchar(255);default:'';comment:证明材料" json:"file"`
|
File string `gorm:"column:file;type:varchar(255);default:'';comment:证明材料" json:"file"`
|
||||||
Industry string `gorm:"column:industry;type:varchar(255);default:'';comment:所属领域;行业信息" json:"-"`
|
Industry string `gorm:"column:industry;type:varchar(255);default:'';comment:所属领域;行业信息" json:"-"`
|
||||||
@ -22,7 +23,6 @@ type TechnologyAchievement struct {
|
|||||||
Config string `gorm:"column:config;type:varchar(255);default:'';comment:配置信息" json:"config"`
|
Config string `gorm:"column:config;type:varchar(255);default:'';comment:配置信息" json:"config"`
|
||||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:'';comment:关键词" json:"-"`
|
Keyword string `gorm:"column:keyword;type:varchar(255);default:'';comment:关键词" json:"-"`
|
||||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||||
Source string `gorm:"source:introduce;type:text;comment:成果来源" json:"source"`
|
|
||||||
Shelf
|
Shelf
|
||||||
TechnologyStatus
|
TechnologyStatus
|
||||||
ModelDeleted
|
ModelDeleted
|
||||||
@ -50,6 +50,15 @@ func (m *TechnologyAchievement) TableName() string {
|
|||||||
return "technology_achievement"
|
return "technology_achievement"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *TechnologyAchievement) GetModeTitle() string {
|
||||||
|
if m.Mode == TechnologyAchievementModeForFree {
|
||||||
|
return "免费模式"
|
||||||
|
} else if m.Mode == TechnologyAchievementModeForCharge {
|
||||||
|
return "收费模式"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (m *TechnologyAchievement) GetConfigAttribute() *TechnologyAchievementConfig {
|
func (m *TechnologyAchievement) GetConfigAttribute() *TechnologyAchievementConfig {
|
||||||
out := new(TechnologyAchievementConfig)
|
out := new(TechnologyAchievementConfig)
|
||||||
_ = json.Unmarshal([]byte(m.Config), &out)
|
_ = json.Unmarshal([]byte(m.Config), &out)
|
||||||
|
@ -15,7 +15,7 @@ type UserInstance struct {
|
|||||||
Name string `gorm:"column:name;type:varchar(20);default:'';comment:真实姓名" json:"name"`
|
Name string `gorm:"column:name;type:varchar(20);default:'';comment:真实姓名" json:"name"`
|
||||||
Mobile string `gorm:"column:mobile;index:idx_user_instance_mobile;type:varchar(15);default:'';comment:联系方式" json:"mobile"`
|
Mobile string `gorm:"column:mobile;index:idx_user_instance_mobile;type:varchar(15);default:'';comment:联系方式" json:"mobile"`
|
||||||
Gender
|
Gender
|
||||||
Vip UserInstanceVipKind `gorm:"column:vip;type:tinyint(1);default:0;comment:会员状态/类型" json:"vip"`
|
Vip uint64 `gorm:"column:vip;type:int(11);default:0;comment:会员ID" json:"vip"`
|
||||||
VipDeadline time.Time `gorm:"column:vip_deadline;type:datetime;default:null;comment:会员过期时间" json:"vip_deadline"`
|
VipDeadline time.Time `gorm:"column:vip_deadline;type:datetime;default:null;comment:会员过期时间" json:"vip_deadline"`
|
||||||
Identity int `gorm:"column:identity;type:int(8);default:0;comment:身份信息" json:"-"`
|
Identity int `gorm:"column:identity;type:int(8);default:0;comment:身份信息" json:"-"`
|
||||||
Password string `gorm:"column:password;type:varchar(100);default:'';comment:密码" json:"-"`
|
Password string `gorm:"column:password;type:varchar(100);default:'';comment:密码" json:"-"`
|
||||||
@ -35,16 +35,6 @@ const (
|
|||||||
UserInstanceSourceForWechat
|
UserInstanceSourceForWechat
|
||||||
)
|
)
|
||||||
|
|
||||||
// UserInstanceVipKind 用户会员类型
|
|
||||||
type UserInstanceVipKind int
|
|
||||||
|
|
||||||
const (
|
|
||||||
// UserInstanceVipForOrdinary 普通VIP
|
|
||||||
UserInstanceVipForOrdinary UserInstanceVipKind = iota + 1
|
|
||||||
// UserInstanceVipForSenior 高级VIP
|
|
||||||
UserInstanceVipForSenior
|
|
||||||
)
|
|
||||||
|
|
||||||
func (m *UserInstance) TableName() string {
|
func (m *UserInstance) TableName() string {
|
||||||
return "user_instance"
|
return "user_instance"
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,13 @@ package main
|
|||||||
import (
|
import (
|
||||||
"SciencesServer/cmd/ctl/command/controller"
|
"SciencesServer/cmd/ctl/command/controller"
|
||||||
"SciencesServer/cmd/ctl/command/model"
|
"SciencesServer/cmd/ctl/command/model"
|
||||||
"SciencesServer/config"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "ctl",
|
Use: "ctl",
|
||||||
Long: "ctl is a command line tool for serve",
|
Long: "ctl is a command line tool for serve",
|
||||||
Version: *config.Version,
|
Version: "v1.0",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
13
lib/order.go
Normal file
13
lib/order.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package lib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OrderNo 订单号
|
||||||
|
func OrderNo() string {
|
||||||
|
now := time.Now()
|
||||||
|
return fmt.Sprintf("%s%d%05d", now.Format("20060102"), now.Unix(), rand.Intn(100000))
|
||||||
|
}
|
@ -140,6 +140,13 @@ func registerAPI(app *gin.Engine) {
|
|||||||
technologyV1.POST("/product", _api.Product)
|
technologyV1.POST("/product", _api.Product)
|
||||||
technologyV1.POST("/product/detail", _api.ProductDetail)
|
technologyV1.POST("/product/detail", _api.ProductDetail)
|
||||||
}
|
}
|
||||||
|
// Payment 支付管理
|
||||||
|
paymentV1 := v1.Group("/payment")
|
||||||
|
{
|
||||||
|
_api := new(api2.Payment)
|
||||||
|
paymentV1.POST("/launch", _api.Launch)
|
||||||
|
paymentV1.POST("/callback", _api.Callback)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// registerAdminAPI 注册API
|
// registerAdminAPI 注册API
|
||||||
@ -405,6 +412,13 @@ func registerAdminAPI(app *gin.Engine) {
|
|||||||
activity.POST("/apply/handle", _api.ApplyHandle)
|
activity.POST("/apply/handle", _api.ApplyHandle)
|
||||||
activity.POST("/apply/delete", _api.ApplyDelete)
|
activity.POST("/apply/delete", _api.ApplyDelete)
|
||||||
}
|
}
|
||||||
|
// Order 订单管理
|
||||||
|
order := v1.Group("/order")
|
||||||
|
{
|
||||||
|
_api := new(api1.Order)
|
||||||
|
order.POST("", _api.Instance)
|
||||||
|
order.POST("/detail", _api.Detail)
|
||||||
|
}
|
||||||
// Logs 日志管理
|
// Logs 日志管理
|
||||||
log := v1.Group("/log")
|
log := v1.Group("/log")
|
||||||
{
|
{
|
||||||
@ -424,9 +438,11 @@ func registerEnterpriseAPI(app *gin.Engine) {
|
|||||||
apiPrefix + "/v1/account/login",
|
apiPrefix + "/v1/account/login",
|
||||||
apiPrefix + "/v1/account/register",
|
apiPrefix + "/v1/account/register",
|
||||||
apiPrefix + "/v1/account/authorize",
|
apiPrefix + "/v1/account/authorize",
|
||||||
|
apiPrefix + "/v1/account/logout",
|
||||||
apiPrefix + "/v1/account/reset/password",
|
apiPrefix + "/v1/account/reset/password",
|
||||||
apiPrefix + "/v1/sms/captcha",
|
apiPrefix + "/v1/sms/captcha",
|
||||||
apiPrefix + "/v1/sms/captcha/validate",
|
apiPrefix + "/v1/sms/captcha/validate",
|
||||||
|
apiPrefix + "/v1/payment/callback",
|
||||||
}...)))
|
}...)))
|
||||||
|
|
||||||
v1.Use(NeedAuthIdentity())
|
v1.Use(NeedAuthIdentity())
|
||||||
@ -448,6 +464,7 @@ func registerEnterpriseAPI(app *gin.Engine) {
|
|||||||
smsV1.POST("/captcha", _api.Captcha)
|
smsV1.POST("/captcha", _api.Captcha)
|
||||||
smsV1.POST("/captcha/validate", _api.CaptchaValidate)
|
smsV1.POST("/captcha/validate", _api.CaptchaValidate)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Account 账号管理
|
// Account 账号管理
|
||||||
accountV1 := v1.Group("/account")
|
accountV1 := v1.Group("/account")
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ func TestNewInstanceUpdate(t *testing.T) {
|
|||||||
//client.Delete()
|
//client.Delete()
|
||||||
|
|
||||||
src := &Student{ID: 1, Name: "Henry", Age: 28}
|
src := &Student{ID: 1, Name: "Henry", Age: 28}
|
||||||
_, err := client.Update().Index("student").Id(fmt.Sprintf("%d", src.ID)).Doc(map[string]interface{}{
|
_, err := client.Update().Index("es_achievement_index").Id(fmt.Sprintf("%d", src.ID)).Doc(map[string]interface{}{
|
||||||
"age": 29,
|
"age": 29,
|
||||||
}).Do(context.Background())
|
}).Do(context.Background())
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
@ -74,7 +74,7 @@ func TestNewInstanceSearch(t *testing.T) {
|
|||||||
query := elastic.NewBoolQuery()
|
query := elastic.NewBoolQuery()
|
||||||
//query.Must(elastic.NewMatchQuery("age", "27"))
|
//query.Must(elastic.NewMatchQuery("age", "27"))
|
||||||
|
|
||||||
service := client.Search().Index("es_achievement_index")
|
service := client.Search().Index("es_manage_index_2")
|
||||||
|
|
||||||
result, err := service.Pretty(true).Query(query).Do(context.Background())
|
result, err := service.Pretty(true).Query(query).Do(context.Background())
|
||||||
|
|
||||||
@ -92,6 +92,15 @@ func TestNewInstanceSearch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewInstanceDelete(t *testing.T) {
|
||||||
|
client := _new()
|
||||||
|
//client.Delete()
|
||||||
|
|
||||||
|
_, err := client.Delete().Index("es_achievement_index").Id("5").Do(context.Background())
|
||||||
|
|
||||||
|
t.Log(err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestNewInstance2(t *testing.T) {
|
func TestNewInstance2(t *testing.T) {
|
||||||
client := _new()
|
client := _new()
|
||||||
|
|
||||||
@ -101,7 +110,7 @@ func TestNewInstance2(t *testing.T) {
|
|||||||
|
|
||||||
service := client.Search().
|
service := client.Search().
|
||||||
//Index("es_patent_index")
|
//Index("es_patent_index")
|
||||||
Index("es_manage_index_2")
|
Index("es_achievement_index")
|
||||||
|
|
||||||
result, err := service.From(0).Size(10).
|
result, err := service.From(0).Size(10).
|
||||||
//Explain(true).
|
//Explain(true).
|
||||||
|
@ -56,10 +56,14 @@ func HashCompare(src, compare []byte) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HASHIDEncode 混淆
|
// HASHIDEncode 混淆
|
||||||
func HASHIDEncode(src int) string {
|
func HASHIDEncode(src int, minLength ...int) string {
|
||||||
hd := hashids.NewData()
|
hd := hashids.NewData()
|
||||||
hd.Salt = salt
|
hd.Salt = salt
|
||||||
hd.MinLength = 12
|
hd.MinLength = 12
|
||||||
|
|
||||||
|
if len(minLength) > 0 {
|
||||||
|
hd.MinLength = minLength[0]
|
||||||
|
}
|
||||||
h := hashids.NewWithData(hd)
|
h := hashids.NewWithData(hd)
|
||||||
e, _ := h.Encode([]int{src})
|
e, _ := h.Encode([]int{src})
|
||||||
return e
|
return e
|
||||||
|
Reference in New Issue
Block a user