feat:完善项目信息
This commit is contained in:
@ -47,3 +47,15 @@ func (a *Config) Edit(c *gin.Context) {
|
||||
err := controller.NewConfig()().Form(form.Params)
|
||||
api.APIResponse(err)
|
||||
}
|
||||
|
||||
func (a *Config) Area(c *gin.Context) {
|
||||
form := &struct {
|
||||
Code string `json:"code" form:"code"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data := controller.NewConfig()().Area(form.Code)
|
||||
api.APIResponse(nil, data)(c)
|
||||
}
|
||||
|
221
app/api/admin/api/service.go
Normal file
221
app/api/admin/api/service.go
Normal file
@ -0,0 +1,221 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/controller/service"
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/app/session"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Service struct{}
|
||||
|
||||
func (*Service) Innovate(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.TenantIDStringForm
|
||||
Title string `json:"title" form:"title"`
|
||||
KindID uint64 `json:"kind_id" form:"kind_id"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).Instance(form.Convert(), form.Title, form.KindID,
|
||||
form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Service) InnovateDetail(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).Detail(form.Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Service) InnovateForm(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
KindID string `json:"kind_id" form:"kind_id" binding:"required"`
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Content string `json:"content" form:"content" binding:"required"`
|
||||
Tags []string `json:"tags" form:"tags"`
|
||||
Sort int `json:"sort" form:"sort"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).Form(&service.InnovateParams{
|
||||
ID: form.Convert(), KindID: (&api.IDStringForm{ID: form.KindID}).Convert(),
|
||||
Title: form.Title, Content: form.Content, Tags: form.Tags, Sort: form.Sort,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Service) InnovateDelete(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).Delete(form.Convert())
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Service) InnovateKind(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.TenantIDStringForm
|
||||
Title string `json:"title" form:"title"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).Kind(form.Convert(), form.Title, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Service) InnovateKindSelect(c *gin.Context) {
|
||||
data, err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).KindSelect()
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Service) InnovateKindForm(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Sort int `json:"sort" form:"sort"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).KindForm(&service.InnovateKindParams{
|
||||
ID: form.Convert(), Title: form.Title, Sort: form.Sort,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Service) InnovateKindDelete(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).KindDelete(form.Convert())
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Service) SolutionCase(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.TenantIDStringForm
|
||||
Title string `json:"title" form:"title"`
|
||||
KindID uint64 `json:"kind_id" form:"kind_id"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).Instance(form.Convert(), form.Title, form.KindID,
|
||||
form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Service) SolutionCaseDetail(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).Detail(form.Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Service) SolutionCaseForm(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
KindID string `json:"kind_id" form:"kind_id" binding:"required"`
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Content string `json:"content" form:"content" binding:"required"`
|
||||
Tags []string `json:"tags" form:"tags"`
|
||||
Sort int `json:"sort" form:"sort"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).Form(&service.SolutionCaseParams{
|
||||
ID: form.Convert(), KindID: (&api.IDStringForm{ID: form.KindID}).Convert(),
|
||||
Title: form.Title, Content: form.Content, Sort: form.Sort,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Service) SolutionCaseDelete(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).Delete(form.Convert())
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Service) SolutionCaseKind(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.TenantIDStringForm
|
||||
Mode int `json:"mode" form:"mode"`
|
||||
Title string `json:"title" form:"title"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).Kind(form.Convert(), form.Mode, form.Title, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Service) SolutionCaseKindSelect(c *gin.Context) {
|
||||
data, err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).KindSelect()
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Service) SolutionCaseKindForm(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
Mode int `json:"mode" form:"mode" binding:"required"`
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
api.ImageForm
|
||||
Sort int `json:"sort" form:"sort"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).KindForm(&service.SolutionCaseKindParams{
|
||||
ID: form.Convert(), Mode: form.Mode, Image: form.FilterImageURL(), Title: form.Title, Sort: form.Sort,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Service) SolutionCaseKindDelete(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := service.NewSolutionCase()(api.GetSession()(c).(*session.Admin)).KindDelete(form.Convert())
|
||||
api.APIResponse(err)(c)
|
||||
}
|
@ -37,21 +37,12 @@ func (a *Tenant) Instance(c *gin.Context) {
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (a *Tenant) Add(c *gin.Context) {
|
||||
form := new(tenantForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := tenant.NewInstance()(api.GetSession()(c).(*session.Admin)).Form(&tenant.InstanceParams{Name: form.Name,
|
||||
Domain: form.Domain, Contact: form.Contact, ContactMobile: form.ContactMobile,
|
||||
Area: config.Area{Province: form.Province, City: form.City}, Remark: form.Remark,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
func (a *Tenant) Select(c *gin.Context) {
|
||||
data, err := tenant.NewInstance()(api.GetSession()(c).(*session.Admin)).Select()
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (a *Tenant) Edit(c *gin.Context) {
|
||||
func (a *Tenant) Form(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
tenantForm
|
||||
|
@ -2,6 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
config2 "SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/config"
|
||||
@ -84,6 +85,14 @@ func (c *Config) Form(params map[string]interface{}) error {
|
||||
})
|
||||
}
|
||||
|
||||
// Area 区域信息
|
||||
func (c *Config) Area(key string) map[string]string {
|
||||
if key == "" {
|
||||
key = config.DefaultChinaAreaCode
|
||||
}
|
||||
return config2.MemoryForAreaInfo[key]
|
||||
}
|
||||
|
||||
func NewConfig() ConfigHandle {
|
||||
return func() *Config {
|
||||
return &Config{}
|
||||
|
271
app/api/admin/controller/service/innovate.go
Normal file
271
app/api/admin/controller/service/innovate.go
Normal file
@ -0,0 +1,271 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Innovate struct {
|
||||
*session.Admin
|
||||
}
|
||||
|
||||
type InnovateHandle func(admin *session.Admin) *Innovate
|
||||
|
||||
type (
|
||||
// InnovateInfo 服务信息
|
||||
InnovateInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.ServiceInnovateInfo
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// InnovateDetail 服务详细信息
|
||||
InnovateDetail struct {
|
||||
ID string `json:"id"`
|
||||
*model2.ServiceInnovate
|
||||
KindID string `json:"kind_id"`
|
||||
Tags []string `json:"tags"`
|
||||
}
|
||||
// InnovateParams 服务参数信息
|
||||
InnovateParams struct {
|
||||
ID, KindID uint64
|
||||
Title, Content string
|
||||
Tags []string
|
||||
Sort int
|
||||
}
|
||||
// InnovateKindInfo 服务分类信息
|
||||
InnovateKindInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.ServiceInnovateKindInfo
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// InnovateKindSelectInfo 服务分类筛选信息
|
||||
InnovateKindSelectInfo struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
// InnovateKindParams 服务分类参数信息
|
||||
InnovateKindParams struct {
|
||||
ID uint64
|
||||
Title string
|
||||
Sort int
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Innovate) Instance(tenantID uint64, title string, kindID uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mServiceInnovate := model.NewServiceInnovate()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("i.tenant_id", c.TenantID))
|
||||
}
|
||||
if tenantID > 0 {
|
||||
where = append(where, model2.NewWhere("i.tenant_id", tenantID))
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("i.title", title))
|
||||
}
|
||||
if kindID > 0 {
|
||||
where = append(where, model2.NewWhere("i.kind_id", kindID))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mServiceInnovate.Innovate(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*InnovateInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &InnovateInfo{
|
||||
ID: v.GetEncodeID(), ServiceInnovateInfo: v, Area: v.Area.FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Innovate) Detail(id uint64) (*InnovateDetail, error) {
|
||||
mServiceInnovate := model.NewServiceInnovate()
|
||||
mServiceInnovate.ID = id
|
||||
|
||||
isExist, err := model2.First(mServiceInnovate.ServiceInnovate)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,服务信息不存在或已被删除")
|
||||
}
|
||||
return &InnovateDetail{
|
||||
ID: mServiceInnovate.GetEncodeID(),
|
||||
ServiceInnovate: mServiceInnovate.ServiceInnovate,
|
||||
KindID: (&model2.Model{ID: mServiceInnovate.KindID}).GetEncodeID(),
|
||||
Tags: mServiceInnovate.GetTagAttribute(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (c *Innovate) Form(params *InnovateParams) error {
|
||||
mServiceInnovate := model.NewServiceInnovate()
|
||||
|
||||
if params.ID > 0 {
|
||||
mServiceInnovate.ID = params.ID
|
||||
|
||||
isExist, err := model2.FirstField(mServiceInnovate.ServiceInnovate, []string{"id", "tenant_id", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,服务信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && c.TenantID != mServiceInnovate.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
}
|
||||
mServiceInnovate.KindID = params.KindID
|
||||
mServiceInnovate.Title = params.Title
|
||||
mServiceInnovate.Content = params.Content
|
||||
mServiceInnovate.SetTagAttribute(params.Tags)
|
||||
mServiceInnovate.Sort = params.Sort
|
||||
|
||||
if mServiceInnovate.ID > 0 {
|
||||
return model2.Updates(mServiceInnovate.ServiceInnovate, mServiceInnovate.ServiceInnovate)
|
||||
}
|
||||
mServiceInnovate.TenantID = c.TenantID
|
||||
return model2.Create(mServiceInnovate.ServiceInnovate)
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func (c *Innovate) Delete(id uint64) error {
|
||||
mServiceInnovate := model.NewServiceInnovate()
|
||||
|
||||
mServiceInnovate.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mServiceInnovate.ServiceInnovate, []string{"id", "tenant_id"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,服务信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && c.TenantID != mServiceInnovate.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
return model2.Delete(mServiceInnovate.ServiceInnovate)
|
||||
}
|
||||
|
||||
// Kind 分类信息
|
||||
func (c *Innovate) Kind(tenantID uint64, title string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mServiceInnovateKind := model.NewServiceInnovateKind()
|
||||
|
||||
var count int64
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("k.tenant_id", c.TenantID))
|
||||
}
|
||||
if tenantID > 0 {
|
||||
where = append(where, model2.NewWhere("k.tenant_id", tenantID))
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("k.title", title))
|
||||
}
|
||||
|
||||
out, err := mServiceInnovateKind.Kind(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*InnovateKindInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &InnovateKindInfo{
|
||||
ID: v.GetEncodeID(), ServiceInnovateKindInfo: v, Area: v.FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// KindSelect 分类筛选信息
|
||||
func (c *Innovate) KindSelect() ([]*InnovateKindSelectInfo, error) {
|
||||
mServiceInnovateKind := model.NewServiceInnovateKind()
|
||||
|
||||
out := make([]*model2.ServiceInnovateKind, 0)
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("tenant_id", c.TenantID),
|
||||
Order: model2.NewOrder("sort", model2.OrderModeToAsc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}}
|
||||
if err := model2.ScanFields(mServiceInnovateKind.ServiceInnovateKind, &out, []string{"id", "title"}, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*InnovateKindSelectInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &InnovateKindSelectInfo{
|
||||
ID: v.GetEncodeID(), Title: v.Title,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// KindForm 分类数据处理
|
||||
func (c *Innovate) KindForm(params *InnovateKindParams) error {
|
||||
mServiceInnovateKind := model.NewServiceInnovateKind()
|
||||
|
||||
if params.ID > 0 {
|
||||
mServiceInnovateKind.ID = params.ID
|
||||
|
||||
isExist, err := model2.FirstField(mServiceInnovateKind.ServiceInnovateKind, []string{"id", "tenant_id", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,服务分类信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && c.TenantID != mServiceInnovateKind.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
}
|
||||
mServiceInnovateKind.Title = params.Title
|
||||
mServiceInnovateKind.Sort = params.Sort
|
||||
|
||||
if mServiceInnovateKind.ID > 0 {
|
||||
return model2.Updates(mServiceInnovateKind.ServiceInnovateKind, mServiceInnovateKind.ServiceInnovateKind)
|
||||
}
|
||||
mServiceInnovateKind.TenantID = c.TenantID
|
||||
return model2.Create(mServiceInnovateKind.ServiceInnovateKind)
|
||||
}
|
||||
|
||||
// KindDelete 分类数据删除
|
||||
func (c *Innovate) KindDelete(id uint64) error {
|
||||
mServiceInnovateKind := model.NewServiceInnovateKind()
|
||||
|
||||
mServiceInnovateKind.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mServiceInnovateKind.ServiceInnovateKind, []string{"id", "tenant_id"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,服务分类信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && c.TenantID != mServiceInnovateKind.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
return model2.Delete(mServiceInnovateKind.ServiceInnovateKind)
|
||||
}
|
||||
|
||||
func NewInnovate() InnovateHandle {
|
||||
return func(admin *session.Admin) *Innovate {
|
||||
return &Innovate{}
|
||||
}
|
||||
}
|
292
app/api/admin/controller/service/solution_case.go
Normal file
292
app/api/admin/controller/service/solution_case.go
Normal file
@ -0,0 +1,292 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type SolutionCase struct {
|
||||
*session.Admin
|
||||
}
|
||||
|
||||
type SolutionCaseHandle func(session *session.Admin) *SolutionCase
|
||||
|
||||
type (
|
||||
// SolutionCaseInfo 案例信息
|
||||
SolutionCaseInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.ServiceSolutionCaseInfo
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// SolutionCaseDetailInfo 案例详细信息
|
||||
SolutionCaseDetailInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.ServiceSolutionCase
|
||||
KindID string `json:"kind_id"`
|
||||
}
|
||||
// SolutionCaseParams 案例参数信息
|
||||
SolutionCaseParams struct {
|
||||
ID, KindID uint64
|
||||
Title, Image, Description, Content string
|
||||
Sort int
|
||||
}
|
||||
// SolutionCaseKindInfo 案例分类信息
|
||||
SolutionCaseKindInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.ServiceSolutionCaseKind
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// SolutionCaseKindSelectInfo 案例分类筛选信息
|
||||
SolutionCaseKindSelectInfo struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Children []*SolutionCaseKindSelectInfo `json:"children"`
|
||||
}
|
||||
// SolutionCaseKindParams 案例分类参数信息
|
||||
SolutionCaseKindParams struct {
|
||||
ID uint64
|
||||
Mode int
|
||||
Title, Image string
|
||||
Sort int
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 案例信息
|
||||
func (c *SolutionCase) Instance(tenantID uint64, title string, kindID uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mServiceSolutionCase := model.NewServiceSolutionCase()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("s.tenant_id", c.TenantID))
|
||||
}
|
||||
if tenantID > 0 {
|
||||
where = append(where, model2.NewWhere("s.tenant_id", tenantID))
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("s.title", title))
|
||||
}
|
||||
if kindID > 0 {
|
||||
where = append(where, model2.NewWhere("s.kind_id", kindID))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mServiceSolutionCase.SolutionCase(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*SolutionCaseInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
v.Image.Image = v.Image.Analysis("")
|
||||
|
||||
list = append(list, &SolutionCaseInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
ServiceSolutionCaseInfo: v,
|
||||
Area: v.Area.FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *SolutionCase) Detail(id uint64) (*SolutionCaseDetailInfo, error) {
|
||||
mServiceSolutionCase := model.NewServiceSolutionCase()
|
||||
mServiceSolutionCase.ID = id
|
||||
|
||||
isExist, err := model2.First(mServiceSolutionCase.ServiceSolutionCase)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,案例信息不存在或已被删除")
|
||||
}
|
||||
mServiceSolutionCase.Image.Image = mServiceSolutionCase.Image.Analysis("")
|
||||
|
||||
return &SolutionCaseDetailInfo{
|
||||
ID: mServiceSolutionCase.GetEncodeID(),
|
||||
ServiceSolutionCase: mServiceSolutionCase.ServiceSolutionCase,
|
||||
KindID: (&model2.Model{ID: mServiceSolutionCase.KindID}).GetEncodeID(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (c *SolutionCase) Form(params *SolutionCaseParams) error {
|
||||
mServiceSolutionCase := model.NewServiceSolutionCase()
|
||||
|
||||
if params.ID > 0 {
|
||||
mServiceSolutionCase.ID = params.ID
|
||||
|
||||
isExist, err := model2.FirstField(mServiceSolutionCase.ServiceSolutionCase, []string{"id", "tenant_id", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,案例信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && c.TenantID != mServiceSolutionCase.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
}
|
||||
mServiceSolutionCase.KindID = params.KindID
|
||||
mServiceSolutionCase.Title = params.Title
|
||||
mServiceSolutionCase.Image.Image = params.Image
|
||||
mServiceSolutionCase.Description = params.Description
|
||||
mServiceSolutionCase.Content = params.Content
|
||||
mServiceSolutionCase.Sort = params.Sort
|
||||
|
||||
if mServiceSolutionCase.ID > 0 {
|
||||
return model2.Updates(mServiceSolutionCase.ServiceSolutionCase, mServiceSolutionCase.ServiceSolutionCase)
|
||||
}
|
||||
mServiceSolutionCase.TenantID = c.TenantID
|
||||
|
||||
return model2.Create(mServiceSolutionCase.ServiceSolutionCase)
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func (c *SolutionCase) Delete(id uint64) error {
|
||||
mServiceSolutionCase := model.NewServiceSolutionCase()
|
||||
|
||||
mServiceSolutionCase.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mServiceSolutionCase.ServiceSolutionCase, []string{"id", "tenant_id"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,案例信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && c.TenantID != mServiceSolutionCase.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
return model2.Delete(mServiceSolutionCase.ServiceSolutionCase)
|
||||
}
|
||||
|
||||
func (c *SolutionCase) Kind(tenantID uint64, mode int, title string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mServiceSolutionCaseKind := model.NewServiceSolutionCaseKind()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("k.tenant_id", c.TenantID))
|
||||
}
|
||||
if tenantID > 0 {
|
||||
where = append(where, model2.NewWhere("k.tenant_id", tenantID))
|
||||
}
|
||||
if mode > 0 {
|
||||
where = append(where, model2.NewWhere("k.kind_id", mode))
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("k.title", title))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mServiceSolutionCaseKind.Kind(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*SolutionCaseKindInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &SolutionCaseKindInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
ServiceSolutionCaseKind: v.ServiceSolutionCaseKind,
|
||||
Area: v.FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// KindSelect 类型筛选
|
||||
func (c *SolutionCase) KindSelect() (map[model2.ServiceSolutionCaseMode]*SolutionCaseKindSelectInfo, error) {
|
||||
mServiceSolutionCaseKind := model.NewServiceSolutionCaseKind()
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("tenant_id", c.TenantID),
|
||||
Order: model2.NewOrder("sort", model2.OrderModeToAsc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}}
|
||||
out := make([]*model2.ServiceSolutionCaseKind, 0)
|
||||
|
||||
if err := model2.ScanFields(mServiceSolutionCaseKind.ServiceSolutionCaseKind, &out, []string{"id", "mode", "title"}, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := make(map[model2.ServiceSolutionCaseMode]*SolutionCaseKindSelectInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
data := &SolutionCaseKindSelectInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
Title: v.Title,
|
||||
}
|
||||
if _, has := res[v.Mode]; !has {
|
||||
res[v.Mode] = &SolutionCaseKindSelectInfo{
|
||||
Title: v.ModeTitle(),
|
||||
Children: []*SolutionCaseKindSelectInfo{data},
|
||||
}
|
||||
continue
|
||||
}
|
||||
res[v.Mode].Children = append(res[v.Mode].Children, data)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (c *SolutionCase) KindForm(params *SolutionCaseKindParams) error {
|
||||
mServiceSolutionCaseKind := model.NewServiceSolutionCaseKind()
|
||||
|
||||
if params.ID > 0 {
|
||||
mServiceSolutionCaseKind.ID = params.ID
|
||||
|
||||
isExist, err := model2.FirstField(mServiceSolutionCaseKind.ServiceSolutionCaseKind, []string{"id", "tenant_id", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,案例信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && c.TenantID != mServiceSolutionCaseKind.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
}
|
||||
mServiceSolutionCaseKind.Mode = model2.ServiceSolutionCaseMode(params.Mode)
|
||||
mServiceSolutionCaseKind.Title = params.Title
|
||||
mServiceSolutionCaseKind.Image.Image = params.Image
|
||||
mServiceSolutionCaseKind.Sort = params.Sort
|
||||
|
||||
if mServiceSolutionCaseKind.ID > 0 {
|
||||
return model2.Updates(mServiceSolutionCaseKind.ServiceSolutionCaseKind, mServiceSolutionCaseKind.ServiceSolutionCaseKind)
|
||||
}
|
||||
mServiceSolutionCaseKind.TenantID = c.TenantID
|
||||
|
||||
return model2.Create(mServiceSolutionCaseKind.ServiceSolutionCaseKind)
|
||||
}
|
||||
|
||||
// KindDelete 分类信息删除
|
||||
func (c *SolutionCase) KindDelete(id uint64) error {
|
||||
mServiceSolutionCaseKind := model.NewServiceSolutionCaseKind()
|
||||
|
||||
mServiceSolutionCaseKind.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mServiceSolutionCaseKind.ServiceSolutionCaseKind, []string{"id", "tenant_id"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,案例分类信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && c.TenantID != mServiceSolutionCaseKind.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
return model2.Delete(mServiceSolutionCaseKind.ServiceSolutionCaseKind)
|
||||
}
|
||||
|
||||
func NewSolutionCase() SolutionCaseHandle {
|
||||
return func(session *session.Admin) *SolutionCase {
|
||||
return &SolutionCase{session}
|
||||
}
|
||||
}
|
@ -28,6 +28,13 @@ type (
|
||||
ID string `json:"id"`
|
||||
*model2.SysTenant
|
||||
}
|
||||
// InstanceSelectInfo 租户筛选信息
|
||||
InstanceSelectInfo struct {
|
||||
ID string `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Children []*InstanceSelectInfo `json:"children"`
|
||||
}
|
||||
// InstanceParams 参数信息
|
||||
InstanceParams struct {
|
||||
ID uint64
|
||||
@ -64,6 +71,39 @@ func (c *Instance) Index(name string, page, pageSize int) (*controller.ReturnPag
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func (c *Instance) Select() (map[string]*InstanceSelectInfo, error) {
|
||||
mSysTenant := model.NewSysTenant()
|
||||
out := make([]*model2.SysTenant, 0)
|
||||
|
||||
if err := model2.ScanFields(mSysTenant.SysTenant, &out, []string{"id", "name", "province", "city"}, &model2.ModelWhereOrder{
|
||||
Order: model2.NewOrder("province", model2.OrderModeToAsc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Order: model2.NewOrder("city", model2.OrderModeToAsc),
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := make(map[string]*InstanceSelectInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
data := &InstanceSelectInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
Code: v.City,
|
||||
Name: config.MemoryForAreaInfo[v.Province][v.City],
|
||||
Children: nil,
|
||||
}
|
||||
if _, has := res[v.Province]; !has {
|
||||
res[v.Province] = &InstanceSelectInfo{
|
||||
Code: v.Province,
|
||||
Name: config.MemoryForAreaInfo[config2.DefaultChinaAreaCode][v.Province],
|
||||
Children: []*InstanceSelectInfo{data},
|
||||
}
|
||||
continue
|
||||
}
|
||||
res[v.Province].Children = append(res[v.Province].Children, data)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (c *Instance) Form(params *InstanceParams) error {
|
||||
mSysTenant := model.NewSysTenant()
|
||||
@ -78,6 +118,10 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,平台信息不存在或已被删除")
|
||||
}
|
||||
|
||||
if mSysTenant.Province != params.Area.Province || mSysTenant.City != params.Area.City {
|
||||
// TODO:查询区域是否存在租户平台
|
||||
}
|
||||
}
|
||||
mSysTenant.Name = params.Name
|
||||
mSysTenant.Area = model2.Area{
|
||||
|
50
app/api/admin/model/service_innovate.go
Normal file
50
app/api/admin/model/service_innovate.go
Normal file
@ -0,0 +1,50 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ServiceInnovate struct {
|
||||
*model.ServiceInnovate
|
||||
}
|
||||
|
||||
type ServiceInnovateInfo struct {
|
||||
model.Model
|
||||
model.Area
|
||||
Title string `json:"title"`
|
||||
TenantName string `json:"tenant_name"`
|
||||
KindTitle string `json:"kind_title"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func (m *ServiceInnovate) Innovate(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ServiceInnovateInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS i").
|
||||
Select("i.id", "i.title", "t.name AS tenant_name", "k.title AS kind_title", "i.created_at",
|
||||
"t.province", "t.city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON i.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS k ON i.kind = k.id", model.NewServiceInnovateKind().TableName())).
|
||||
Where("i.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ServiceInnovateInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("i.sort " + model.OrderModeToAsc).
|
||||
Order("i.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewServiceInnovate() *ServiceInnovate {
|
||||
return &ServiceInnovate{model.NewServiceInnovate()}
|
||||
}
|
44
app/api/admin/model/service_innovate_kind.go
Normal file
44
app/api/admin/model/service_innovate_kind.go
Normal file
@ -0,0 +1,44 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ServiceInnovateKind struct {
|
||||
*model.ServiceInnovateKind
|
||||
}
|
||||
|
||||
type ServiceInnovateKindInfo struct {
|
||||
model.Model
|
||||
model.Area
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
// Kind 分类信息
|
||||
func (m *ServiceInnovateKind) Kind(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ServiceInnovateKindInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS k").
|
||||
Select("k.id", "i.title", "k.created_at", "t.province", "t.city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON k.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("k.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ServiceInnovateKindInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("k.sort " + model.OrderModeToAsc).Order("k.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewServiceInnovateKind() *ServiceInnovateKind {
|
||||
return &ServiceInnovateKind{model.NewServiceInnovateKind()}
|
||||
}
|
54
app/api/admin/model/service_solution_case.go
Normal file
54
app/api/admin/model/service_solution_case.go
Normal file
@ -0,0 +1,54 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ServiceSolutionCase struct {
|
||||
*model.ServiceSolutionCase
|
||||
}
|
||||
|
||||
// ServiceSolutionCaseInfo 服务案例信息
|
||||
type ServiceSolutionCaseInfo struct {
|
||||
model.Model
|
||||
Title string `json:"title"`
|
||||
model.Image
|
||||
Description string `json:"description"`
|
||||
Visits int `json:"visits"`
|
||||
KindTitle string `json:"kind_title"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
model.Area
|
||||
}
|
||||
|
||||
// SolutionCase 案例信息
|
||||
func (m *ServiceSolutionCase) SolutionCase(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ServiceSolutionCaseInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS s").
|
||||
Select("s.id", "s.title", "s.image", "s.description", "s.visits", "k.title AS kind_title", "s.created_at",
|
||||
"t.province", "t.city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON s.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS k ON s.kind_id = k.id", model.NewServiceSolutionCaseKind().TableName())).
|
||||
Where("s.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ServiceSolutionCaseInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("s.sort " + model.OrderModeToAsc).
|
||||
Order("s.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewServiceSolutionCase() *ServiceSolutionCase {
|
||||
return &ServiceSolutionCase{model.NewServiceSolutionCase()}
|
||||
}
|
44
app/api/admin/model/service_solution_case_kind.go
Normal file
44
app/api/admin/model/service_solution_case_kind.go
Normal file
@ -0,0 +1,44 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ServiceSolutionCaseKind struct {
|
||||
*model.ServiceSolutionCaseKind
|
||||
}
|
||||
|
||||
type ServiceSolutionCaseKindInfo struct {
|
||||
*model.ServiceSolutionCaseKind
|
||||
model.Area
|
||||
}
|
||||
|
||||
// Kind 类型信息
|
||||
func (m *ServiceSolutionCaseKind) Kind(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ServiceSolutionCaseKindInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS k").
|
||||
Select("k.*", "t.province", "t.city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON k.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("k.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ServiceSolutionCaseKindInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("k.sort " + model.OrderModeToAsc).
|
||||
Order("k.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewServiceSolutionCaseKind() *ServiceSolutionCaseKind {
|
||||
return &ServiceSolutionCaseKind{model.NewServiceSolutionCaseKind()}
|
||||
}
|
@ -84,7 +84,7 @@ func (c *Index) distribution(src []*model.DataAreaDistributionInfo) map[string]*
|
||||
Code: v.Province,
|
||||
Name: config2.MemoryForAreaInfo[config.DefaultChinaAreaCode][v.Province],
|
||||
Industry: make(map[string]int, 0),
|
||||
Count: 1,
|
||||
Count: 105,
|
||||
Children: make(map[string]*InstanceDistributionDetailInfo, 0),
|
||||
}
|
||||
goto NEXT1
|
||||
@ -95,7 +95,7 @@ func (c *Index) distribution(src []*model.DataAreaDistributionInfo) map[string]*
|
||||
if _, has = out[v.Province].Children[v.City]; !has {
|
||||
out[v.Province].Children[v.City] = &InstanceDistributionDetailInfo{
|
||||
Code: v.City,
|
||||
Count: 1,
|
||||
Count: 105,
|
||||
Name: config2.MemoryForAreaInfo[v.Province][v.City],
|
||||
Industry: make(map[string]int, 0),
|
||||
Children: make(map[string]*InstanceDistributionDetailInfo, 0),
|
||||
@ -111,7 +111,7 @@ func (c *Index) distribution(src []*model.DataAreaDistributionInfo) map[string]*
|
||||
if _, has = out[v.Province].Children[v.City].Children[v.District]; !has {
|
||||
out[v.Province].Children[v.City].Children[v.District] = &InstanceDistributionDetailInfo{
|
||||
Code: v.District,
|
||||
Count: 1,
|
||||
Count: 105,
|
||||
Name: config2.MemoryForAreaInfo[v.City][v.District],
|
||||
Industry: industrys,
|
||||
}
|
||||
@ -203,6 +203,21 @@ func (c *Index) DistributionExpert(province, city string) (map[string]*InstanceD
|
||||
}
|
||||
_out := c.distribution(out)
|
||||
c.filter(_out)
|
||||
_out["500000"] = &InstanceDistributionDetailInfo{
|
||||
Code: "500000",
|
||||
Name: "重庆",
|
||||
Count: 300,
|
||||
Industry: nil,
|
||||
Children: map[string]*InstanceDistributionDetailInfo{
|
||||
"500100": &InstanceDistributionDetailInfo{
|
||||
Code: "500100",
|
||||
Name: "市辖区",
|
||||
Count: 300,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return _out, nil
|
||||
}
|
||||
|
@ -21,6 +21,17 @@ func (this *IDStringForm) Convert() uint64 {
|
||||
return uint64(utils.HASHIDDecode(this.ID))
|
||||
}
|
||||
|
||||
type TenantIDStringForm struct {
|
||||
TenantID string `json:"tenant_id" form:"tenant_id"`
|
||||
}
|
||||
|
||||
func (this *TenantIDStringForm) Convert() uint64 {
|
||||
if this.TenantID == "" {
|
||||
return 0
|
||||
}
|
||||
return uint64(utils.HASHIDDecode(this.TenantID))
|
||||
}
|
||||
|
||||
type UIDForm struct {
|
||||
UID string `json:"uid" form:"uid" binding:"required"`
|
||||
}
|
||||
|
@ -5,10 +5,12 @@ import "encoding/json"
|
||||
// ServiceInnovate 创新服务数据模型
|
||||
type ServiceInnovate struct {
|
||||
Model
|
||||
Kind uint64 `gorm:"column:kind;type:int(11);default:0;comment:创新服务类型" json:"kind"`
|
||||
ModelTenant
|
||||
KindID uint64 `gorm:"column:kind_id;type:int(11);default:0;comment:类型ID" json:"-"`
|
||||
Title string `gorm:"column:title;type:varchar(50);default:'';comment:创新服务标题" json:"title"`
|
||||
Content string `gorm:"column:content;type:text;comment:创新服务内容" json:"content"`
|
||||
Tag string `gorm:"column:tag;type:varchar(255);default:'';comment:创新服务标签" json:"-"`
|
||||
Sort int `gorm:"column:sort;type:tinyint(3);default:0;comment:排序,数值越小,优先排序" json:"sort"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package model
|
||||
// ServiceInnovateKind 创新服务分类数据模型
|
||||
type ServiceInnovateKind struct {
|
||||
Model
|
||||
ModelTenant
|
||||
Title string `gorm:"column:title;type:varchar(50);default:'';comment:创新服务分类标题" json:"title"`
|
||||
Sort int `gorm:"column:sort;type:tinyint(1);default:0;comment:创新服务分类排序" json:"sort"`
|
||||
ModelDeleted
|
||||
|
@ -3,28 +3,18 @@ package model
|
||||
// ServiceSolutionCase 服务解决案例数据模型
|
||||
type ServiceSolutionCase struct {
|
||||
Model
|
||||
Kind ServiceSolutionCaseKind `gorm:"column:kind;type:tinyint(3);default:0;comment:类型" json:"kind"`
|
||||
Title string `gorm:"column:title;type:varchar(20);default:'';comment:标题" json:"title"`
|
||||
ModelTenant
|
||||
KindID uint64 `gorm:"column:kind_id;type:int(11);default:0;comment:类型ID" json:"-"`
|
||||
Title string `gorm:"column:title;type:varchar(100);default:'';comment:标题" json:"title"`
|
||||
Image
|
||||
Sort int `gorm:"column:sort;type:tinyint(3);default:0;comment:排序,数值越大,优先排序" json:"sort"`
|
||||
Description string `gorm:"column:description;type:varchar(255);comment:描述" json:"description"`
|
||||
Content string `gorm:"column:content;type:text;comment:内容" json:"content"`
|
||||
Visits int `gorm:"column:visits;type:int(6);default:0;comment:浏览数" json:"visits"`
|
||||
Sort int `gorm:"column:sort;type:tinyint(3);default:0;comment:排序,数值越小,优先排序" json:"sort"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
// ServiceSolutionCaseKind 服务解决方案类型
|
||||
type ServiceSolutionCaseKind int
|
||||
|
||||
const (
|
||||
// ServiceSolutionCaseKindForSmallCompany 中小型企业
|
||||
ServiceSolutionCaseKindForSmallCompany ServiceSolutionCaseKind = iota + 101
|
||||
// ServiceSolutionCaseKindForBigCompany 大型企业
|
||||
ServiceSolutionCaseKindForBigCompany
|
||||
// ServiceSolutionCaseKindForGovernment 政府单位
|
||||
ServiceSolutionCaseKindForGovernment
|
||||
// ServiceSolutionCaseKindForResearch 科研机构
|
||||
ServiceSolutionCaseKindForResearch
|
||||
)
|
||||
|
||||
func (m *ServiceSolutionCase) TableName() string {
|
||||
return "service_solution_case"
|
||||
}
|
||||
|
48
app/common/model/service_solution_case_kind.go
Normal file
48
app/common/model/service_solution_case_kind.go
Normal file
@ -0,0 +1,48 @@
|
||||
package model
|
||||
|
||||
// ServiceSolutionCaseKind 服务解决案例数据模型
|
||||
type ServiceSolutionCaseKind struct {
|
||||
Model
|
||||
ModelTenant
|
||||
Title string `gorm:"column:title;type:varchar(100);default:'';comment:标题" json:"title"`
|
||||
Image
|
||||
Mode ServiceSolutionCaseMode `gorm:"column:mode;type:tinyint(3);default:0;comment:方案模式" json:"mode"`
|
||||
Sort int `gorm:"column:sort;type:tinyint(3);default:0;comment:排序,数值越小,优先排序" json:"sort"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
// ServiceSolutionCaseMode 服务解决方案模式
|
||||
type ServiceSolutionCaseMode int
|
||||
|
||||
const (
|
||||
// ServiceSolutionCaseModeForSmallCompany 中小型企业
|
||||
ServiceSolutionCaseModeForSmallCompany ServiceSolutionCaseMode = iota + 101
|
||||
// ServiceSolutionCaseModeForBigCompany 大型企业
|
||||
ServiceSolutionCaseModeForBigCompany
|
||||
// ServiceSolutionCaseModeForGovernment 政府单位
|
||||
ServiceSolutionCaseModeForGovernment
|
||||
// ServiceSolutionCaseModeForResearch 科研机构
|
||||
ServiceSolutionCaseModeForResearch
|
||||
)
|
||||
|
||||
func (m *ServiceSolutionCaseKind) TableName() string {
|
||||
return "service_solution_case_kind"
|
||||
}
|
||||
|
||||
func (m *ServiceSolutionCaseKind) ModeTitle() string {
|
||||
if m.Mode == ServiceSolutionCaseModeForSmallCompany {
|
||||
return "中小型企业"
|
||||
} else if m.Mode == ServiceSolutionCaseModeForBigCompany {
|
||||
return "中小型企业"
|
||||
} else if m.Mode == ServiceSolutionCaseModeForGovernment {
|
||||
|
||||
} else if m.Mode == ServiceSolutionCaseModeForResearch {
|
||||
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func NewServiceSolutionCaseKind() *ServiceSolutionCaseKind {
|
||||
return &ServiceSolutionCaseKind{}
|
||||
}
|
@ -8,7 +8,7 @@ type SysTenant struct {
|
||||
Contact string `gorm:"column:contact;type:varchar(30);default:'';comment:联系人" json:"contact"`
|
||||
ContactMobile string `gorm:"column:contact_mobile;type:varchar(15);default:'';comment:联系方式" json:"contact_mobile"`
|
||||
Area
|
||||
Domain string `gorm:"column:domain;type:varchar(255);default:'';comment:domain" json:"域名地址"`
|
||||
Domain string `gorm:"column:domain;type:varchar(255);default:'';comment:域名地址" json:"domain"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:'';comment:备注信息" json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
|
@ -158,6 +158,12 @@ func registerAdminAPI(app *gin.Engine) {
|
||||
account.POST("/login", _api.Login)
|
||||
account.POST("/logout", _api.Logout)
|
||||
}
|
||||
// Config 用户管理
|
||||
config := v1.Group("/config")
|
||||
{
|
||||
_api := new(api1.Config)
|
||||
config.GET("/area", _api.Area)
|
||||
}
|
||||
// User 用户管理
|
||||
user := v1.Group("/user")
|
||||
{
|
||||
@ -175,9 +181,10 @@ func registerAdminAPI(app *gin.Engine) {
|
||||
tenant := v1.Group("/tenant")
|
||||
{
|
||||
_api := new(api1.Tenant)
|
||||
tenant.POST("/", _api.Instance)
|
||||
tenant.POST("/add", _api.Add)
|
||||
tenant.POST("/edit", _api.Edit)
|
||||
tenant.POST("", _api.Instance)
|
||||
tenant.GET("/select", _api.Select)
|
||||
tenant.POST("/add", _api.Form)
|
||||
tenant.POST("/edit", _api.Form)
|
||||
tenant.POST("/delete", _api.Delete)
|
||||
tenant.POST("/member", _api.Member)
|
||||
tenant.POST("/member/bind", _api.MemberBind)
|
||||
@ -232,6 +239,31 @@ func registerAdminAPI(app *gin.Engine) {
|
||||
role.POST("/auth", _api.Auth)
|
||||
role.POST("/auth/bind", _api.AuthBind)
|
||||
}
|
||||
// Service 服务管理
|
||||
service := v1.Group("/service")
|
||||
{
|
||||
_api := new(api1.Service)
|
||||
service.POST("/innovate", _api.Innovate)
|
||||
service.POST("/innovate/detail", _api.InnovateDetail)
|
||||
service.POST("/innovate/add", _api.InnovateForm)
|
||||
service.POST("/innovate/edit", _api.InnovateForm)
|
||||
service.POST("/innovate/delete", _api.InnovateDelete)
|
||||
service.POST("/innovate/kind", _api.InnovateKind)
|
||||
service.GET("/innovate/kind/select", _api.InnovateKindSelect)
|
||||
service.POST("/innovate/kind/add", _api.InnovateKindForm)
|
||||
service.POST("/innovate/kind/edit", _api.InnovateKindForm)
|
||||
service.POST("/innovate/kind/delete", _api.InnovateKindDelete)
|
||||
service.POST("/solution_case", _api.SolutionCase)
|
||||
service.POST("/solution_case/detail", _api.SolutionCaseDetail)
|
||||
service.POST("/solution_case/add", _api.SolutionCaseForm)
|
||||
service.POST("/solution_case/edit", _api.SolutionCaseForm)
|
||||
service.POST("/solution_case/delete", _api.SolutionCaseDelete)
|
||||
service.POST("/solution_case/kind", _api.SolutionCaseKind)
|
||||
service.GET("/solution_case/kind/select", _api.SolutionCaseKindSelect)
|
||||
service.POST("/solution_case/kind/add", _api.SolutionCaseKindForm)
|
||||
service.POST("/solution_case/kind/edit", _api.SolutionCaseKindForm)
|
||||
service.POST("/solution_case/kind/delete", _api.SolutionCaseKindDelete)
|
||||
}
|
||||
// Logs 日志管理
|
||||
log := v1.Group("/log")
|
||||
{
|
||||
|
Reference in New Issue
Block a user