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)
|
||||
}
|
@ -201,8 +201,9 @@ func (*Service) SolutionCaseKindForm(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
api.TenantIDStringForm
|
||||
Mode int `json:"mode" form:"mode" binding:"required"`
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Mode int `json:"mode" form:"mode" binding:"required"`
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Description string `json:"description" form:"description" binding:"required"`
|
||||
api.ImageForm
|
||||
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{
|
||||
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)
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ func (c *Company) Form(params *BasicParams, other *config.IdentityForCompany) er
|
||||
if params.ID > 0 {
|
||||
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 {
|
||||
return err
|
||||
|
@ -5,10 +5,12 @@ import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
config2 "SciencesServer/config"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -136,7 +138,7 @@ func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) erro
|
||||
if params.ID > 0 {
|
||||
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 {
|
||||
return err
|
||||
@ -158,6 +160,7 @@ func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) erro
|
||||
}
|
||||
}
|
||||
mManageExpert.TenantID = c.TenantID
|
||||
mManageExpert.Name = params.Name
|
||||
mManageExpert.ResearchID = other.ConvertResearch()
|
||||
mManageExpert.LaboratoryID = other.ConvertLaboratory()
|
||||
mManageExpert.Image.Image = params.Image
|
||||
@ -179,11 +182,26 @@ func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) erro
|
||||
if c.TenantID <= 0 {
|
||||
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 {
|
||||
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.ExamineStatus = model2.ExamineStatusForAgree
|
||||
mManageExpert.ExamineRemark = "主动创建,无需审核"
|
||||
@ -194,7 +212,13 @@ func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) erro
|
||||
} else if isExist {
|
||||
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 专利信息
|
||||
|
@ -119,7 +119,7 @@ func (c *Laboratory) Form(params *BasicParams, other *config.IdentityForLaborato
|
||||
|
||||
if params.ID > 0 {
|
||||
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 {
|
||||
return err
|
||||
|
@ -128,7 +128,7 @@ func (c *Research) Form(params *BasicParams, other *config.IdentityForResearch)
|
||||
|
||||
if params.ID > 0 {
|
||||
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 {
|
||||
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}
|
||||
}
|
||||
}
|
@ -50,10 +50,10 @@ type (
|
||||
}
|
||||
// SolutionCaseKindParams 案例分类参数信息
|
||||
SolutionCaseKindParams struct {
|
||||
ID, TenantID uint64
|
||||
Mode int
|
||||
Title, Image string
|
||||
Sort int
|
||||
ID, TenantID uint64
|
||||
Mode int
|
||||
Title, Image, Description string
|
||||
Sort int
|
||||
}
|
||||
)
|
||||
|
||||
@ -260,7 +260,8 @@ func (c *SolutionCase) KindForm(params *SolutionCaseKindParams) error {
|
||||
if params.ID > 0 {
|
||||
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 {
|
||||
return err
|
||||
@ -274,6 +275,7 @@ func (c *SolutionCase) KindForm(params *SolutionCaseKindParams) error {
|
||||
mServiceSolutionCaseKind.Mode = model2.ServiceSolutionCaseMode(params.Mode)
|
||||
mServiceSolutionCaseKind.Title = params.Title
|
||||
mServiceSolutionCaseKind.Image.Image = params.Image
|
||||
mServiceSolutionCaseKind.Description = params.Description
|
||||
mServiceSolutionCaseKind.Sort = params.Sort
|
||||
|
||||
if mServiceSolutionCaseKind.ID > 0 {
|
||||
|
@ -8,13 +8,8 @@ import (
|
||||
func TestNewBanner(t *testing.T) {
|
||||
banner := new(Banner)
|
||||
out := []string{
|
||||
"首页banner",
|
||||
"登录注册",
|
||||
"首页>1>首页",
|
||||
"解决方案>中小型企业",
|
||||
"解决方案>大型企业",
|
||||
"找专家>专家列表",
|
||||
"找专家>专家列表1",
|
||||
"找专家>专家列表>专家详情",
|
||||
}
|
||||
_out := banner.filter(out, ">")
|
||||
t.Log(_out)
|
||||
|
@ -248,7 +248,7 @@ func (c *Patent) Filter(applyName, inventor string) (*PatentFilterInfo, error) {
|
||||
|
||||
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{
|
||||
Where: model2.NewWhere("name", inventor),
|
||||
}, &model2.ModelWhereOrder{
|
||||
@ -288,7 +288,7 @@ func (c *Patent) Delete(id 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"})
|
||||
|
||||
if err != nil {
|
||||
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()}
|
||||
}
|
Reference in New Issue
Block a user