熊哥提交
This commit is contained in:
@ -3,6 +3,8 @@ package api
|
||||
import (
|
||||
"SciencesServer/app/api/website/controller"
|
||||
"SciencesServer/app/basic/api"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@ -17,6 +19,6 @@ func (*Config) Index(c *gin.Context) {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := controller.NewConfig()(nil).Instance(form.Kind, form.Key)
|
||||
data, err := controller.NewConfig()(nil).Instance(form.Kind, strings.Split(form.Key, ","))
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
@ -26,8 +26,9 @@ type (
|
||||
ActivityInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.ActivityInstanceInfo
|
||||
IsJoin bool `json:"is_join"`
|
||||
Status int `json:"status"` // 状态(1:未开始,2:进行中,3:已结束)
|
||||
Amount float64 `json:"amount"`
|
||||
IsJoin bool `json:"is_join"`
|
||||
Status int `json:"status"` // 状态(1:未开始,2:进行中,3:已结束)
|
||||
}
|
||||
// ActivityDetail 详细信息
|
||||
ActivityDetail struct {
|
||||
@ -76,7 +77,7 @@ func (c *Activity) Instance(title, industry string, status, page, pageSize int)
|
||||
v.Image.Image = v.Image.Analysis(config.SystemConfig[config.SysImageDomain])
|
||||
|
||||
data := &ActivityInfo{
|
||||
ID: v.GetEncodeID(), ActivityInstanceInfo: v, IsJoin: v.JoinID > 0, Status: 2,
|
||||
ID: v.GetEncodeID(), Amount: v.Amount, ActivityInstanceInfo: v, IsJoin: v.JoinID > 0, Status: 2,
|
||||
}
|
||||
if now.Before(v.BeginAt) {
|
||||
data.Status = 1
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Config struct{ *session.Enterprise }
|
||||
@ -19,22 +18,36 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Config) Instance(kind int, key string) (*ConfigInfo, error) {
|
||||
func (c *Config) Instance(kind int, key []string) (map[string]*ConfigInfo, error) {
|
||||
mSysConfig := model.NewSysConfig()
|
||||
|
||||
where := []*model2.ModelWhere{model2.NewWhere("`key`", key)}
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereIn("`key`", key),
|
||||
Order: nil,
|
||||
}}
|
||||
|
||||
if kind > 0 {
|
||||
where = append(where, model2.NewWhere("kind", kind))
|
||||
where = append(where, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("kind", kind),
|
||||
Order: nil,
|
||||
})
|
||||
}
|
||||
isExist, err := model2.FirstField(mSysConfig.SysConfig, []string{"id", "name", "`value`"}, where...)
|
||||
out := make([]*model2.SysConfig, 0)
|
||||
|
||||
err := model2.ScanFields(mSysConfig.SysConfig, &out, []string{"id", "`key`", "name", "`value`"}, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,数据不存在或已被删除")
|
||||
}
|
||||
return &ConfigInfo{Name: mSysConfig.Name, Value: mSysConfig.Value}, nil
|
||||
list := make(map[string]*ConfigInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list[v.Key] = &ConfigInfo{
|
||||
Name: v.Name,
|
||||
Value: v.Value,
|
||||
}
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func NewConfig() ConfigHandle {
|
||||
|
@ -17,8 +17,9 @@ type (
|
||||
model.Model
|
||||
model.Image
|
||||
*model.ActivityInstanceBasic
|
||||
JoinID uint64 `json:"-"`
|
||||
JoinCount int `json:"join_count"`
|
||||
Amount float64 `json:"amount"`
|
||||
JoinID uint64 `json:"-"`
|
||||
JoinCount int `json:"join_count"`
|
||||
}
|
||||
// ActivityInstanceDetail 活动详细信息
|
||||
ActivityInstanceDetail struct {
|
||||
@ -33,7 +34,7 @@ func (m *ActivityInstance) Activity(uid uint64, identity, page, pageSize int, co
|
||||
mActivityJoin := model.NewActivityJoin()
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.id", "a.title", "a.image", "a.begin_at", "a.finish_at", "a.join_deadline",
|
||||
Select("a.id", "a.title", "a.image", "a.begin_at", "a.amount", "a.finish_at", "a.join_deadline",
|
||||
"IFNULL(u.id, 0) AS join_id", "j.count AS join_count").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s u ON a.id = u.activity_id AND u.uid = %d AND u.identity = %d AND u.status = %d AND u.is_deleted = %d",
|
||||
mActivityJoin.TableName(), uid, identity, model.ActivityJoinStatusForSuccess, model.DeleteStatusForNot)).
|
||||
|
Reference in New Issue
Block a user