feat:完善项目信息
This commit is contained in:
@ -18,7 +18,7 @@ func (a *Config) Index(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
data, err := controller.NewConfig()().Config(form.Kind, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (a *Config) Add(c *gin.Context) {
|
||||
@ -33,7 +33,7 @@ func (a *Config) Add(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
err := controller.NewConfig()().Add(form.Kind, form.Name, form.Key, form.Value)
|
||||
api.APIResponse(err)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (a *Config) Edit(c *gin.Context) {
|
||||
@ -45,5 +45,5 @@ func (a *Config) Edit(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
err := controller.NewConfig()().Form(form.Params)
|
||||
api.APIResponse(err)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
@ -25,8 +25,7 @@ func (*Sys) IndustryForm(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
err := sys.NewIndustry()(api.GetSession()(c).(*session.Admin)).Form(&sys.IndustryParams{
|
||||
ID: form.IDStringForm.Convert(), PatentID: (&api.IDStringForm{ID: form.ParentID}).Convert(),
|
||||
Name: form.Name,
|
||||
ID: form.IDStringForm.Convert(), PatentID: (&api.IDStringForm{ID: form.ParentID}).Convert(), Name: form.Name,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
@ -58,11 +57,11 @@ func (*Sys) NavigationForm(c *gin.Context) {
|
||||
api.IDStringForm
|
||||
api.TenantIDStringForm
|
||||
ParentID string `json:"parent_id" form:"parent_id"`
|
||||
Title string `json:"title" form:"title"`
|
||||
Link string `json:"link" form:"link"`
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Link string `json:"link" form:"link" binding:"required"`
|
||||
IsTarget int `json:"is_target" form:"is_target"`
|
||||
Sort int `json:"sort" form:"sort"`
|
||||
Status int `json:"status" form:"status"`
|
||||
Status int `json:"status" form:"status" binding:"required"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -24,14 +25,15 @@ type (
|
||||
InstanceInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.ActivityInstanceInfo
|
||||
Area string `json:"area"`
|
||||
Industrys []string `json:"industrys"`
|
||||
Area string `json:"area"`
|
||||
Industry string `json:"industry"`
|
||||
}
|
||||
// InstanceDetailInfo 活动详细信息
|
||||
InstanceDetailInfo struct {
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
*model2.ActivityInstance
|
||||
Industrys []string `json:"industrys"`
|
||||
}
|
||||
// InstanceParams 活动参数信息
|
||||
InstanceParams struct {
|
||||
@ -86,11 +88,16 @@ func (c *Instance) Index(tenantID uint64, title, contact, contactMobile string,
|
||||
list := make([]*InstanceInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
_industry := make([]string, 0)
|
||||
|
||||
for _, v := range v.GetIndustryAttribute() {
|
||||
_industry = append(_industry, config.GetIndustryInfo(v, "-"))
|
||||
}
|
||||
list = append(list, &InstanceInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
ActivityInstanceInfo: v,
|
||||
Area: v.FormatBasic(),
|
||||
Industrys: v.GetIndustryAttribute(),
|
||||
Industry: strings.Join(_industry, ";"),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
@ -112,6 +119,7 @@ func (c *Instance) Detail(id uint64) (*InstanceDetailInfo, error) {
|
||||
ID: mActivityInstance.GetEncodeID(),
|
||||
TenantID: mActivityInstance.GetEncodeTenantID(),
|
||||
ActivityInstance: mActivityInstance.ActivityInstance,
|
||||
Industrys: mActivityInstance.GetIndustryAttribute(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -135,6 +143,7 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
}
|
||||
mActivityInstance.Title = params.Title
|
||||
mActivityInstance.Contact = params.Contact
|
||||
mActivityInstance.ContactMobile = params.ContactMobile
|
||||
mActivityInstance.BeginAt = utils.DateTimeToTime(params.BeginAt)
|
||||
mActivityInstance.FinishAt = utils.DateTimeToTime(params.FinishAt)
|
||||
mActivityInstance.JoinDeadline = utils.DateTimeToTime(params.JoinDeadline)
|
||||
@ -148,6 +157,7 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
mActivityInstance.NotifyCrowd = params.NotifyCrowd
|
||||
mActivityInstance.IsHome = params.IsHome
|
||||
mActivityInstance.Sort = params.Sort
|
||||
mActivityInstance.Content = params.Content
|
||||
mActivityInstance.Status = model2.ActivityInstanceStatus(params.Status)
|
||||
|
||||
if mActivityInstance.ID > 0 {
|
||||
|
@ -46,10 +46,10 @@ func (c *Industry) tree(src []*model2.SysIndustry, parentID uint64) []*IndustryI
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Industry) Instance() ([]*IndustryInfo, error) {
|
||||
mSysIndustry := new(model.SysIndustry)
|
||||
mSysIndustry := model.NewSysIndustry()
|
||||
out := make([]*model2.SysIndustry, 0)
|
||||
|
||||
if err := model2.ScanFields(mSysIndustry.SysIndustry, out, []string{"id", "parent_id", "name"}); err != nil {
|
||||
if err := model2.ScanFields(mSysIndustry.SysIndustry, &out, []string{"id", "parent_id", "name"}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.tree(out, 0), nil
|
||||
|
@ -19,7 +19,7 @@ type ActivityInstanceInfo struct {
|
||||
// Activity 活动信息
|
||||
func (m *ActivityInstance) Activity(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ActivityInstanceInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.id", "a.tenant_id", "a.image", "a.title", "a.contact", "a.contact_mobile", "a.begin_at",
|
||||
Select("a.id", "a.tenant_id", "a.image", "a.title", "a.contact", "a.industry", "a.contact_mobile", "a.begin_at",
|
||||
"a.finish_at", "a.join_deadline", "a.amount", "a.max_number", "a.status", "a.created_at", "j.count AS join_count",
|
||||
"t.province", "t.city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT activity_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d AND status = %d GROUP BY activity_id) AS j ON a.id = j.activity_id",
|
||||
|
@ -24,7 +24,12 @@ func GetIndustryInfo(industry, mark string) string {
|
||||
out := make([]string, 0)
|
||||
|
||||
for _, v := range obj {
|
||||
out = append(out, MemoryForIndustryInfo[v])
|
||||
data, has := MemoryForIndustryInfo[v]
|
||||
|
||||
if !has {
|
||||
data = "未知"
|
||||
}
|
||||
out = append(out, data)
|
||||
}
|
||||
return strings.Join(out, "-")
|
||||
}
|
||||
|
@ -1,23 +1,9 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMemory(t *testing.T) {
|
||||
MemoryForIndustryInfo["01"] = &MemoryForIndustry{
|
||||
Name: "01",
|
||||
Children: map[string]*MemoryForIndustry{
|
||||
"001": &MemoryForIndustry{
|
||||
Name: "001",
|
||||
Children: nil,
|
||||
},
|
||||
"002": &MemoryForIndustry{
|
||||
Name: "002",
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
t.Logf(utils.AnyToJSON(MemoryForIndustryInfo))
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ type SysConfig struct {
|
||||
Model
|
||||
Kind SysConfigKind `gorm:"column:kind;type:tinyint(3);default:0;comment:类型" json:"kind"`
|
||||
Name string `gorm:"column:name;type:varchar(30);default:'';comment:名称" json:"name"`
|
||||
Key string `gorm:"column:key;type:varchar(30);default:'';comment:标识" json:"key"`
|
||||
Value string `gorm:"column:value;type:varchar(255);default:'';comment:内容" json:"value"`
|
||||
Key string `gorm:"column:key;type:varchar(100);default:'';comment:标识" json:"key"`
|
||||
Value string `gorm:"column:value;type:text;comment:内容" json:"value"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
@ -17,6 +17,10 @@ type SysConfigKind int
|
||||
const (
|
||||
// SysConfigKindForBasic 基本配置
|
||||
SysConfigKindForBasic SysConfigKind = iota + 1
|
||||
// SysConfigKindForWebsite 网站配置
|
||||
SysConfigKindForWebsite
|
||||
// SysConfigKindForUpload 上传配置
|
||||
SysConfigKindForUpload
|
||||
// SysConfigKindForWeChat 微信配置
|
||||
SysConfigKindForWeChat
|
||||
// SysConfigKindForAliPay 支付宝配置
|
||||
|
@ -177,10 +177,10 @@ func registerAdminAPI(app *gin.Engine) {
|
||||
_api := new(api1.Sys)
|
||||
// 导航信息
|
||||
sys.GET("/industry", _api.Industry)
|
||||
sys.GET("/industry/add", _api.NavigationForm)
|
||||
sys.GET("/industry/edit", _api.NavigationForm)
|
||||
sys.GET("/industry/delete", _api.NavigationDelete)
|
||||
sys.GET("/navigation", _api.Navigation)
|
||||
sys.POST("/industry/add", _api.NavigationForm)
|
||||
sys.POST("/industry/edit", _api.NavigationForm)
|
||||
sys.POST("/industry/delete", _api.NavigationDelete)
|
||||
sys.POST("/navigation", _api.Navigation)
|
||||
sys.POST("/navigation/add", _api.NavigationForm)
|
||||
sys.POST("/navigation/edit", _api.NavigationForm)
|
||||
sys.POST("/navigation/delete", _api.NavigationDelete)
|
||||
|
Reference in New Issue
Block a user