feat:完善项目信息
This commit is contained in:
@ -1 +1,151 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/controller/activity"
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/session"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Activity struct{}
|
||||
|
||||
func (*Activity) Instance(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.TenantIDStringForm
|
||||
Title string `json:"title" form:"title"`
|
||||
Contact string `json:"contact" form:"contact"`
|
||||
ContactMobile string `json:"contact_mobile" form:"contact_mobile"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := activity.NewInstance()(api.GetSession()(c).(*session.Admin)).Index(form.Convert(), form.Title,
|
||||
form.Contact, form.ContactMobile, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Activity) Detail(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := activity.NewInstance()(api.GetSession()(c).(*session.Admin)).Detail(form.Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Activity) Form(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
ApplyID string `json:"apply_id" form:"apply_id"`
|
||||
api.TenantIDStringForm
|
||||
api.ImageForm
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Content string `json:"content" form:"content" binding:"required"`
|
||||
Contact string `json:"contact" form:"contact" binding:"required"`
|
||||
ContactMobile string `json:"contact_mobile" form:"contact_mobile"`
|
||||
BeginAt string `json:"begin_at" form:"begin_at" binding:"required"`
|
||||
FinishAt string `json:"finish_at" form:"finish_at" binding:"required"`
|
||||
JoinDeadline string `json:"join_deadline" form:"join_deadline" binding:"required"`
|
||||
config.Area
|
||||
Industrys []string `json:"industrys" form:"industrys"`
|
||||
Amount float64 `json:"amount" form:"amount"`
|
||||
MaxNumber int `json:"max_number" form:"max_number"`
|
||||
NotifyCrowd int `json:"notify_crowd" form:"notify_crowd"`
|
||||
IsHome int `json:"is_home" form:"is_home"`
|
||||
Sort int `json:"sort" form:"sort"`
|
||||
Status int `json:"status" form:"status"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := activity.NewInstance()(api.GetSession()(c).(*session.Admin)).Form(&activity.InstanceParams{
|
||||
ID: form.IDStringForm.Convert(), ApplyID: (&api.IDStringForm{ID: form.ApplyID}).Convert(),
|
||||
TenantID: form.TenantIDStringForm.Convert(), Title: form.Title, Contact: form.Contact, ContactMobile: form.ContactMobile,
|
||||
Image: form.FilterImageURL(), Content: form.Content, BeginAt: form.BeginAt, FinishAt: form.FinishAt,
|
||||
JoinDeadline: form.JoinDeadline, Area: form.Area, Industrys: form.Industrys, Amount: form.Amount,
|
||||
MaxNumber: form.MaxNumber, NotifyCrowd: form.NotifyCrowd, IsHome: form.IsHome, Sort: form.Sort, Status: form.Status,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Activity) Delete(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := activity.NewInstance()(api.GetSession()(c).(*session.Admin)).Delete(form.Convert())
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Activity) Joins(c *gin.Context) {
|
||||
form := &struct {
|
||||
ActivityID string `json:"activity_id" form:"activity_id" binding:"required"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := activity.NewInstance()(api.GetSession()(c).(*session.Admin)).Joins(
|
||||
(&api.IDStringForm{ID: form.ActivityID}).Convert(), form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Activity) Apply(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.TenantIDStringForm
|
||||
Title string `json:"title" form:"title"`
|
||||
Contact string `json:"contact" form:"contact"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := activity.NewApply()(api.GetSession()(c).(*session.Admin)).Instance(form.Convert(), form.Title,
|
||||
form.Contact, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Activity) ApplyDetail(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := activity.NewApply()(api.GetSession()(c).(*session.Admin)).Detail(form.Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Activity) ApplyHandle(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := activity.NewApply()(api.GetSession()(c).(*session.Admin)).Handle(form.Convert(), form.Remark)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Activity) ApplyDelete(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := activity.NewApply()(api.GetSession()(c).(*session.Admin)).Detail(form.Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
@ -47,15 +47,3 @@ 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)
|
||||
}
|
||||
|
@ -13,15 +13,15 @@ func (*Service) Innovate(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.TenantIDStringForm
|
||||
Title string `json:"title" form:"title"`
|
||||
KindID uint64 `json:"kind_id" form:"kind_id"`
|
||||
KindID string `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)
|
||||
data, err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).Instance(form.Convert(), form.Title,
|
||||
(&api.IDStringForm{ID: form.KindID}).Convert(), form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
@ -40,11 +40,12 @@ func (*Service) InnovateForm(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
api.TenantIDStringForm
|
||||
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"`
|
||||
KindID string `json:"kind_id" form:"kind_id" binding:"required"`
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Description string `json:"description" form:"description"`
|
||||
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)
|
||||
@ -52,8 +53,8 @@ func (*Service) InnovateForm(c *gin.Context) {
|
||||
}
|
||||
err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).Form(&service.InnovateParams{
|
||||
ID: form.IDStringForm.Convert(), TenantID: form.TenantIDStringForm.Convert(),
|
||||
KindID: (&api.IDStringForm{ID: form.KindID}).Convert(),
|
||||
Title: form.Title, Content: form.Content, Tags: form.Tags, Sort: form.Sort,
|
||||
KindID: (&api.IDStringForm{ID: form.KindID}).Convert(), Title: form.Title, Description: form.Description,
|
||||
Content: form.Content, Tags: form.Tags, Sort: form.Sort,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
145
app/api/admin/controller/activity/apply.go
Normal file
145
app/api/admin/controller/activity/apply.go
Normal file
@ -0,0 +1,145 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/serve/orm"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Apply struct {
|
||||
*session.Admin
|
||||
}
|
||||
|
||||
type ApplyHandle func(session *session.Admin) *Apply
|
||||
|
||||
type (
|
||||
// ApplyInfo 申请信息
|
||||
ApplyInfo struct {
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
*model.ActivityApplyInfo
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// ApplyDetailInfo 申请详细信息
|
||||
ApplyDetailInfo struct {
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
*model.ActivityApplyInfo
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 申请信息
|
||||
func (c *Apply) Instance(tenantID uint64, title, contact string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mActivityApply := model.NewActivityApply()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("a.tenant_id", c.TenantID))
|
||||
}
|
||||
if tenantID > 0 {
|
||||
where = append(where, model2.NewWhere("a.tenant_id", tenantID))
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("a.title", title))
|
||||
}
|
||||
if contact != "" {
|
||||
where = append(where, model2.NewWhereLike("a.contact", title))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mActivityApply.Apply(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := make([]*ApplyInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &ApplyInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
TenantID: v.GetEncodeTenantID(),
|
||||
ActivityApplyInfo: v,
|
||||
Area: v.FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Apply) Detail(id uint64) (*ApplyDetailInfo, error) {
|
||||
mActivityApply := model.NewActivityApply()
|
||||
out, err := mActivityApply.Detail(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ApplyDetailInfo{
|
||||
ID: out.GetEncodeID(),
|
||||
TenantID: out.GetEncodeTenantID(),
|
||||
ActivityApplyInfo: out,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Handle 处理操作
|
||||
func (c *Apply) Handle(id uint64, remark string) error {
|
||||
mActivityApply := model.NewActivityApply()
|
||||
mActivityApply.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mActivityApply.ActivityApply, []string{"id", "tenant_id", "status"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,活动申请信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && mActivityApply.TenantID != c.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
if mActivityApply.Status != model2.ActivityApplyStatusForProcessing {
|
||||
return errors.New("操作错误,活动申请信息状态发生变化,不可处理")
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
mActivityApply.Status = model2.ActivityApplyStatusForProcessed
|
||||
|
||||
if err = model2.Updates(mActivityApply.ActivityApply, map[string]interface{}{
|
||||
"status": model2.ActivityApplyStatusForProcessed, "updated_at": time.Now(),
|
||||
}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
mActivityApplyLog := model.NewActivityApplyLog()
|
||||
mActivityApplyLog.ApplyID = mActivityApply.ID
|
||||
mActivityApplyLog.Remark = remark
|
||||
return model2.Create(mActivityApplyLog.ActivityApplyLog, tx)
|
||||
})
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func (c *Apply) Delete(id uint64) error {
|
||||
mActivityApply := model.NewActivityApply()
|
||||
mActivityApply.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mActivityApply.ActivityApply, []string{"id", "tenant_id", "status"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,活动申请信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && mActivityApply.TenantID != c.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
return model2.Delete(mActivityApply.ActivityApply)
|
||||
}
|
||||
|
||||
func NewApply() ApplyHandle {
|
||||
return func(session *session.Admin) *Apply {
|
||||
return &Apply{session}
|
||||
}
|
||||
}
|
@ -2,10 +2,15 @@ package activity
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Instance struct {
|
||||
@ -19,7 +24,8 @@ type (
|
||||
InstanceInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.ActivityInstanceInfo
|
||||
Area string `json:"area"`
|
||||
Area string `json:"area"`
|
||||
Industrys []string `json:"industrys"`
|
||||
}
|
||||
// InstanceDetailInfo 活动详细信息
|
||||
InstanceDetailInfo struct {
|
||||
@ -27,9 +33,30 @@ type (
|
||||
TenantID string `json:"tenant_id"`
|
||||
*model2.ActivityInstance
|
||||
}
|
||||
// InstanceParams 活动参数信息
|
||||
InstanceParams struct {
|
||||
ID, ApplyID, TenantID uint64
|
||||
Title, Contact, ContactMobile, Image, Content string
|
||||
BeginAt, FinishAt, JoinDeadline string
|
||||
config.Area
|
||||
Industrys []string
|
||||
Amount float64
|
||||
MaxNumber, NotifyCrowd, IsHome, Sort, Status int
|
||||
}
|
||||
// InstanceJoinInfo 活动报名信息
|
||||
InstanceJoinInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.ActivityJoinInfo
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Instance) Index(tenantID uint64, title string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
// notify 执行通知
|
||||
func (c *Instance) notify() {
|
||||
|
||||
}
|
||||
|
||||
// Index 活动信息
|
||||
func (c *Instance) Index(tenantID uint64, title, contact, contactMobile string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mActivityInstance := model.NewActivityInstance()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
@ -43,6 +70,12 @@ func (c *Instance) Index(tenantID uint64, title string, page, pageSize int) (*co
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("a.title", title))
|
||||
}
|
||||
if contact != "" {
|
||||
where = append(where, model2.NewWhereLike("a.contact", title))
|
||||
}
|
||||
if contactMobile != "" {
|
||||
where = append(where, model2.NewWhereLike("a.contact_mobile", title))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mActivityInstance.Activity(page, pageSize, &count, where...)
|
||||
@ -57,6 +90,7 @@ func (c *Instance) Index(tenantID uint64, title string, page, pageSize int) (*co
|
||||
ID: v.GetEncodeID(),
|
||||
ActivityInstanceInfo: v,
|
||||
Area: v.FormatBasic(),
|
||||
Industrys: v.GetIndustryAttribute(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
@ -81,10 +115,90 @@ func (c *Instance) Detail(id uint64) (*InstanceDetailInfo, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Instance) Form() {
|
||||
// Form 数据操作
|
||||
func (c *Instance) Form(params *InstanceParams) error {
|
||||
mActivityInstance := model.NewActivityInstance()
|
||||
|
||||
if params.ID > 0 {
|
||||
mActivityInstance.ID = params.ID
|
||||
|
||||
isExist, err := model2.FirstField(mActivityInstance.ActivityInstance, []string{"id", "tenant_id", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,活动信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && mActivityInstance.TenantID != c.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
}
|
||||
mActivityInstance.Title = params.Title
|
||||
mActivityInstance.Contact = params.Contact
|
||||
mActivityInstance.BeginAt = utils.DateTimeToTime(params.BeginAt)
|
||||
mActivityInstance.FinishAt = utils.DateTimeToTime(params.FinishAt)
|
||||
mActivityInstance.JoinDeadline = utils.DateTimeToTime(params.JoinDeadline)
|
||||
mActivityInstance.Area = model2.Area{
|
||||
Province: params.Province, City: params.City, District: params.District, Address: params.Address,
|
||||
}
|
||||
mActivityInstance.Image.Image = params.Image
|
||||
mActivityInstance.SetIndustryAttribute(params.Industrys)
|
||||
mActivityInstance.Amount = params.Amount
|
||||
mActivityInstance.MaxNumber = params.MaxNumber
|
||||
mActivityInstance.NotifyCrowd = params.NotifyCrowd
|
||||
mActivityInstance.IsHome = params.IsHome
|
||||
mActivityInstance.Sort = params.Sort
|
||||
mActivityInstance.Status = model2.ActivityInstanceStatus(params.Status)
|
||||
|
||||
if mActivityInstance.ID > 0 {
|
||||
if c.TenantID <= 0 {
|
||||
mActivityInstance.TenantID = params.TenantID
|
||||
}
|
||||
return model2.Updates(mActivityInstance.ActivityInstance, mActivityInstance.ActivityInstance)
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
mActivityInstance.TenantID = params.TenantID
|
||||
|
||||
if c.TenantID > 0 {
|
||||
mActivityInstance.TenantID = c.TenantID
|
||||
}
|
||||
err := model2.Create(mActivityInstance.ActivityInstance)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if params.ApplyID > 0 {
|
||||
mActivityApply := model.NewActivityApply()
|
||||
mActivityApply.ID = params.ApplyID
|
||||
|
||||
isExist := false
|
||||
|
||||
if isExist, err = model2.FirstField(mActivityApply.ActivityApply, []string{"id", "tenant_id", "status"}); err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,活动申请信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && mActivityApply.TenantID != c.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
if mActivityApply.Status != model2.ActivityApplyStatusForProcessing {
|
||||
return errors.New("操作错误,活动申请信息状态发生变化,不可处理")
|
||||
}
|
||||
if err = model2.Updates(mActivityApply.ActivityApply, map[string]interface{}{
|
||||
"status": model2.ActivityApplyStatusForProcessed, "updated_at": time.Now(),
|
||||
}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
mActivityApplyLog := model.NewActivityApplyLog()
|
||||
mActivityApplyLog.ApplyID = mActivityApply.ID
|
||||
mActivityApplyLog.Remark = "创建活动"
|
||||
return model2.Create(mActivityApplyLog.ActivityApplyLog, tx)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func (c *Instance) Delete(id uint64) error {
|
||||
mActivityInstance := model.NewActivityInstance()
|
||||
mActivityInstance.ID = id
|
||||
@ -102,6 +216,26 @@ func (c *Instance) Delete(id uint64) error {
|
||||
return model2.Delete(mActivityInstance.ActivityInstance)
|
||||
}
|
||||
|
||||
func (c *Instance) Joins(activityID uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mActivityJoin := model.NewActivityJoin()
|
||||
var count int64
|
||||
|
||||
out, err := mActivityJoin.Join(page, pageSize, &count, model2.NewWhere("j.activity_id", activityID))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*InstanceJoinInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &InstanceJoinInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
ActivityJoinInfo: v,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(session *session.Admin) *Instance {
|
||||
return &Instance{session}
|
||||
|
@ -23,17 +23,18 @@ type (
|
||||
}
|
||||
// InnovateDetail 服务详细信息
|
||||
InnovateDetail struct {
|
||||
ID string `json:"id"`
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
*model2.ServiceInnovate
|
||||
KindID string `json:"kind_id"`
|
||||
Tags []string `json:"tags"`
|
||||
}
|
||||
// InnovateParams 服务参数信息
|
||||
InnovateParams struct {
|
||||
ID, TenantID, KindID uint64
|
||||
Title, Content string
|
||||
Tags []string
|
||||
Sort int
|
||||
ID, TenantID, KindID uint64
|
||||
Title, Description, Content string
|
||||
Tags []string
|
||||
Sort int
|
||||
}
|
||||
// InnovateKindInfo 服务分类信息
|
||||
InnovateKindInfo struct {
|
||||
@ -71,7 +72,7 @@ func (c *Innovate) Instance(tenantID uint64, title string, kindID uint64, page,
|
||||
where = append(where, model2.NewWhereLike("i.title", title))
|
||||
}
|
||||
if kindID > 0 {
|
||||
where = append(where, model2.NewWhere("i.kind_id", kindID))
|
||||
where = append(where, model2.NewWhere("k.id", kindID))
|
||||
}
|
||||
var count int64
|
||||
|
||||
@ -104,6 +105,7 @@ func (c *Innovate) Detail(id uint64) (*InnovateDetail, error) {
|
||||
}
|
||||
return &InnovateDetail{
|
||||
ID: mServiceInnovate.GetEncodeID(),
|
||||
TenantID: mServiceInnovate.GetEncodeTenantID(),
|
||||
ServiceInnovate: mServiceInnovate.ServiceInnovate,
|
||||
KindID: (&model2.Model{ID: mServiceInnovate.KindID}).GetEncodeID(),
|
||||
Tags: mServiceInnovate.GetTagAttribute(),
|
||||
@ -130,6 +132,7 @@ func (c *Innovate) Form(params *InnovateParams) error {
|
||||
}
|
||||
mServiceInnovate.KindID = params.KindID
|
||||
mServiceInnovate.Title = params.Title
|
||||
mServiceInnovate.Description = params.Description
|
||||
mServiceInnovate.Content = params.Content
|
||||
mServiceInnovate.SetTagAttribute(params.Tags)
|
||||
mServiceInnovate.Sort = params.Sort
|
||||
|
@ -20,7 +20,8 @@ type MessageHandle func(session *session.Admin) *Message
|
||||
type MessageInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.ServiceMessageInfo
|
||||
Area string `json:"area"`
|
||||
Area string `json:"area"`
|
||||
AreaDomain string `json:"area_domain"`
|
||||
}
|
||||
|
||||
// Instance 列表信息
|
||||
@ -58,6 +59,7 @@ func (c *Message) Instance(tenantID uint64, name string, status int, content str
|
||||
ID: v.GetEncodeID(),
|
||||
ServiceMessageInfo: v,
|
||||
Area: v.FormatBasic(),
|
||||
AreaDomain: v.Domain,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, err
|
||||
@ -91,7 +93,7 @@ func (c *Message) Handle(id uint64, content string) error {
|
||||
mServiceMessageLog.MessageID = id
|
||||
mServiceMessageLog.Content = content
|
||||
|
||||
if err = model2.Create(mServiceMessage.ServiceMessage, tx); err != nil {
|
||||
if err = model2.Create(mServiceMessageLog.ServiceMessageLog, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -188,7 +188,7 @@ func (c *SolutionCase) Kind(tenantID uint64, mode int, title string, page, pageS
|
||||
where = append(where, model2.NewWhere("k.tenant_id", tenantID))
|
||||
}
|
||||
if mode > 0 {
|
||||
where = append(where, model2.NewWhere("k.kind_id", mode))
|
||||
where = append(where, model2.NewWhere("k.mode", mode))
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("k.title", title))
|
||||
|
72
app/api/admin/model/activity_apply.go
Normal file
72
app/api/admin/model/activity_apply.go
Normal file
@ -0,0 +1,72 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ActivityApply struct {
|
||||
*model.ActivityApply
|
||||
}
|
||||
|
||||
type (
|
||||
// ActivityApplyInfo 详细信息
|
||||
ActivityApplyInfo struct {
|
||||
*model.ActivityApply
|
||||
Username string `json:"username"`
|
||||
model.Area
|
||||
HandleUsername string `json:"handle_name"`
|
||||
HandleRemark string `json:"handle_remark"`
|
||||
HandleCreatedAt time.Time `json:"handle_created_at"`
|
||||
}
|
||||
)
|
||||
|
||||
// Apply 申请信息
|
||||
func (m *ActivityApply) Apply(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ActivityApplyInfo, 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",
|
||||
"a.finish_at", "a.amount", "a.max_number", "a.status", "a.created_at",
|
||||
"t.province", "t.city", "l.name AS handle_name", "l.remark AS handle_remark", "l.created_at AS handle_created_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON a.uid = u.uuid", model.NewUserInstance().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON i.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT a.apply_id, MAX(a.id) AS id, MAX(a.created_at) AS created_at, MAX(a.remark) AS remark "+
|
||||
"MAX(u.`name`) AS name FROM %s AS a LEFT JOIN %s ON a.uid = u.uuid WHERE a.is_deleted = %d GROUP BY a.apply_id) AS l ON a.id = l.apply_id",
|
||||
model.NewActivityApplyLog().TableName(), model.NewSysUser().TableName(), model.DeleteStatusForNot)).
|
||||
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ActivityApplyInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("a.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (m *ActivityApply) Detail(id uint64) (*ActivityApplyInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.*", "u.name AS username").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON a.uid = u.uuid", model.NewUserInstance().TableName())).
|
||||
Where("a.id = ?", id)
|
||||
|
||||
out := new(ActivityApplyInfo)
|
||||
|
||||
err := db.Scan(out).Error
|
||||
|
||||
return out, err
|
||||
|
||||
}
|
||||
|
||||
func NewActivityApply() *ActivityApply {
|
||||
return &ActivityApply{model.NewActivityApply()}
|
||||
}
|
11
app/api/admin/model/activity_apply_log.go
Normal file
11
app/api/admin/model/activity_apply_log.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ActivityApplyLog struct {
|
||||
*model.ActivityApplyLog
|
||||
}
|
||||
|
||||
func NewActivityApplyLog() *ActivityApplyLog {
|
||||
return &ActivityApplyLog{model.NewActivityApplyLog()}
|
||||
}
|
@ -19,8 +19,9 @@ 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.mode", "a.image", "a.title", "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").
|
||||
Select("a.id", "a.tenant_id", "a.image", "a.title", "a.contact", "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_delete = %d AND status = %d GROUP BY activity_id) AS j ON a.id = j.activity_id",
|
||||
model.NewActivityJoin().TableName(), model.DeleteStatusForNot, model.ActivityJoinStatusForSuccess)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON i.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
|
@ -1,11 +1,45 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ActivityJoin struct {
|
||||
*model.ActivityJoin
|
||||
}
|
||||
|
||||
type ActivityJoinInfo struct {
|
||||
model.Model
|
||||
Name string `json:"name"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func (m *ActivityJoin) Join(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ActivityJoinInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS j").
|
||||
Select("j.id", "u.name", "j.created_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON j.uid = u.uuid", model.NewUserInstance().TableName())).
|
||||
Where("j.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("j.status = ?", model.ActivityJoinStatusForSuccess)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ActivityJoinInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("j.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewActivityJoin() *ActivityJoin {
|
||||
return &ActivityJoin{model.NewActivityJoin()}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ func (m *ServiceInnovate) Innovate(page, pageSize int, count *int64, where ...*m
|
||||
Select("i.id", "i.title", "t.name AS tenant_name", "k.title AS kind_title", "i.sort", "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())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS k ON i.kind_id = k.id", model.NewServiceInnovateKind().TableName())).
|
||||
Where("i.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
|
@ -14,6 +14,7 @@ type ServiceMessage struct {
|
||||
type ServiceMessageInfo struct {
|
||||
*model.ServiceMessage
|
||||
model.Area
|
||||
Domain string `json:"-"`
|
||||
HandleContent string `json:"handle_content"`
|
||||
HandleCreatedAt time.Time `json:"handle_created_at"`
|
||||
}
|
||||
@ -21,11 +22,12 @@ type ServiceMessageInfo struct {
|
||||
func (m *ServiceMessage) Message(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ServiceMessageInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS m").
|
||||
Select("m.*", "l.content AS handle_content", "l.created_at AS handle_created_at",
|
||||
"t.province", "t.city").
|
||||
"t.province", "t.city", "t.domain").
|
||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT MAX(id) AS id, message_id, MAX(created_at) AS created_at, MAX(content) AS content "+
|
||||
"FROM %s WHERE is_deleted = %d GROUP BY message_id) AS l ON m.id = l.message_id",
|
||||
model.NewServiceMessageLog().TableName(), model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON m.tenant_id = t.id", model.NewSysTenant().TableName()))
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON m.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("m.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
|
@ -29,7 +29,7 @@ func (m *SysAuth) TenantAuth(tenantID uint64) ([]*SysAuthScene, error) {
|
||||
out := make([]*SysAuthScene, 0)
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.id", "a.parent_id", "a.kind", "a.name", "r_a.id AS scene_id").
|
||||
Select("a.id", "a.parent_id", "a.kind", "a.name", "t_a.id AS scene_id").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t_a ON t_a.auth_id = a.id AND t_a.tenant_id = %d AND t_a.is_deleted = %d",
|
||||
model.NewSysTenantAuth().TableName(), tenantID, model.DeleteStatusForNot)).
|
||||
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
@ -1,48 +1,3 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/controller/config"
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Config struct{}
|
||||
|
||||
func (a *Config) Identity(c *gin.Context) {
|
||||
data := config.NewConfig().Identity()
|
||||
api.APISuccess(data)(c)
|
||||
}
|
||||
|
||||
func (a *Config) Transaction(c *gin.Context) {
|
||||
data := config.NewConfig().Transaction()
|
||||
api.APISuccess(data)(c)
|
||||
}
|
||||
|
||||
func (a *Config) Industry(c *gin.Context) {
|
||||
form := &struct {
|
||||
ParentID string `json:"parent_id" form:"parent_id"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data := config.NewConfig().Industry(utils.StringToUnit64(form.ParentID))
|
||||
api.APISuccess(data)(c)
|
||||
}
|
||||
|
||||
func (a *Config) Research(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
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 := config.NewConfig().Area(form.Code)
|
||||
api.APIResponse(nil, data)(c)
|
||||
}
|
||||
|
@ -63,9 +63,7 @@ func (c *Apply) List(title string, page, pageSize int) (*controller.ReturnPages,
|
||||
// Launch 发起操作
|
||||
func (c *Apply) Launch(params *ApplyLaunchParams) error {
|
||||
mActivityApply := model.NewActivityApply()
|
||||
mActivityApply.Local.Local = c.local
|
||||
mActivityApply.IdentityUID = c.IdentityUID
|
||||
mActivityApply.Mode = model2.ActivityInstanceMode(params.Mode)
|
||||
mActivityApply.UID = c.UID
|
||||
mActivityApply.Title = params.Title
|
||||
mActivityApply.Amount = params.Amount
|
||||
mActivityApply.Content = params.Content
|
||||
@ -87,9 +85,9 @@ func (c *Apply) Revoke(id uint64) error {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,活动信息不存在或已被删除")
|
||||
} else if mActivityApply.Status != model2.ActivityApplyStatusForExamining {
|
||||
} else if mActivityApply.Status != model2.ActivityApplyStatusForProcessing {
|
||||
return errors.New("操作错误,当前活动状态易发生变化,不可撤销")
|
||||
} else if mActivityApply.IdentityUID != c.IdentityUID {
|
||||
} else if mActivityApply.UID != c.UID {
|
||||
return errors.New("无权限操作")
|
||||
}
|
||||
return model2.Updates(mActivityApply.ActivityApply, map[string]interface{}{
|
||||
@ -108,7 +106,7 @@ func (c *Apply) Delete(id uint64) error {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,活动信息不存在或已被删除")
|
||||
} else if mActivityApply.IdentityUID != c.IdentityUID {
|
||||
} else if mActivityApply.UID != c.IdentityUID {
|
||||
return errors.New("无权限操作")
|
||||
}
|
||||
return model2.Delete(mActivityApply.ActivityApply)
|
||||
|
@ -1,80 +1 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
config2 "SciencesServer/config"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Config struct{}
|
||||
|
||||
type (
|
||||
// IndustryInfo 所属领域信息
|
||||
IndustryInfo struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
)
|
||||
|
||||
// Basic 基础配置信息
|
||||
func (c *Config) Basic() {
|
||||
|
||||
}
|
||||
|
||||
// Config 配置信息
|
||||
func (c *Config) Config() map[string]interface{} {
|
||||
return config2.SystemConfig
|
||||
}
|
||||
|
||||
// Identity 身份信息
|
||||
func (c *Config) Identity() map[int]string {
|
||||
return config.TenantUserIdentityData
|
||||
}
|
||||
|
||||
// Transaction 交易信息
|
||||
func (c *Config) Transaction() map[int]string {
|
||||
return config.TechnologyTransactionData
|
||||
}
|
||||
|
||||
// Industry 行业信息
|
||||
func (c *Config) Industry(parentID uint64) []*IndustryInfo {
|
||||
mSysIndustry := model.NewSysIndustry()
|
||||
out := make([]*model2.SysIndustry, 0)
|
||||
|
||||
err := model2.ScanFields(mSysIndustry.SysIndustry, &out, []string{"id", "name"}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("parent_id", parentID),
|
||||
})
|
||||
|
||||
list := make([]*IndustryInfo, 0)
|
||||
|
||||
if err != nil {
|
||||
return list
|
||||
}
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &IndustryInfo{
|
||||
ID: fmt.Sprintf("%d", v.ID),
|
||||
Name: v.Name,
|
||||
})
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
// Research 研究领域信息
|
||||
func (c *Config) Research() {
|
||||
|
||||
}
|
||||
|
||||
// Area 区域信息
|
||||
func (c *Config) Area(key string) map[string]string {
|
||||
if key == "" {
|
||||
key = config2.DefaultChinaAreaCode
|
||||
}
|
||||
return config.MemoryForAreaInfo[key]
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
return &Config{}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ func (c *Activity) Join(id uint64) error {
|
||||
if count > 0 {
|
||||
return errors.New("操作错误,不可重复报名")
|
||||
}
|
||||
if mActivityInstance.Mode == model2.ActivityInstanceModeForOrdinary {
|
||||
if mActivityInstance.Amount <= 0 {
|
||||
service.Publish(config.EventForActivityJoinProduce, c.IdentityUID, c.UID)
|
||||
}
|
||||
return nil
|
||||
|
@ -52,7 +52,7 @@ func Bind(req interface{}) ApiHandle {
|
||||
}
|
||||
if err != nil {
|
||||
logger.ErrorF("Request URL【%s】Params Bind Error:%v", c.Request.URL, err)
|
||||
return errors.New("参数异常/缺失")
|
||||
return errors.New("参数异常/缺失【" + err.Error() + "】")
|
||||
}
|
||||
c.Set("params", utils.AnyToJSON(req))
|
||||
return nil
|
||||
|
47
app/basic/api/config.go
Normal file
47
app/basic/api/config.go
Normal file
@ -0,0 +1,47 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/controller"
|
||||
"SciencesServer/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Config struct{}
|
||||
|
||||
func (*Config) Identity(c *gin.Context) {
|
||||
data := controller.NewConfig().Identity()
|
||||
APISuccess(data)(c)
|
||||
}
|
||||
|
||||
func (a *Config) Transaction(c *gin.Context) {
|
||||
data := controller.NewConfig().Transaction()
|
||||
APISuccess(data)(c)
|
||||
}
|
||||
|
||||
func (a *Config) Industry(c *gin.Context) {
|
||||
form := &struct {
|
||||
ParentID string `json:"parent_id" form:"parent_id"`
|
||||
}{}
|
||||
if err := Bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data := controller.NewConfig().Industry(utils.StringToUnit64(form.ParentID))
|
||||
APISuccess(data)(c)
|
||||
}
|
||||
|
||||
func (a *Config) Research(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func (a *Config) Area(c *gin.Context) {
|
||||
form := &struct {
|
||||
Code string `json:"code" form:"code"`
|
||||
}{}
|
||||
if err := Bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data := controller.NewConfig().Area(form.Code)
|
||||
APIResponse(nil, data)(c)
|
||||
}
|
73
app/basic/controller/config.go
Normal file
73
app/basic/controller/config.go
Normal file
@ -0,0 +1,73 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
config2 "SciencesServer/config"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Config struct{}
|
||||
|
||||
type (
|
||||
// IndustryInfo 所属领域信息
|
||||
IndustryInfo struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
)
|
||||
|
||||
// Basic 基础配置信息
|
||||
func (c *Config) Basic() {
|
||||
|
||||
}
|
||||
|
||||
// Config 配置信息
|
||||
func (c *Config) Config() map[string]interface{} {
|
||||
return config2.SystemConfig
|
||||
}
|
||||
|
||||
// Identity 身份信息
|
||||
func (c *Config) Identity() map[int]string {
|
||||
return config.TenantUserIdentityData
|
||||
}
|
||||
|
||||
// Transaction 交易信息
|
||||
func (c *Config) Transaction() map[int]string {
|
||||
return config.TechnologyTransactionData
|
||||
}
|
||||
|
||||
// Industry 行业信息
|
||||
func (c *Config) Industry(parentID uint64) []*IndustryInfo {
|
||||
out := make([]*model2.SysIndustry, 0)
|
||||
|
||||
err := model2.ScanFields(model2.NewSysIndustry(), &out, []string{"id", "name"}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("parent_id", parentID),
|
||||
})
|
||||
|
||||
list := make([]*IndustryInfo, 0)
|
||||
|
||||
if err != nil {
|
||||
return list
|
||||
}
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &IndustryInfo{
|
||||
ID: fmt.Sprintf("%d", v.ID),
|
||||
Name: v.Name,
|
||||
})
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
// Area 区域信息
|
||||
func (c *Config) Area(key string) map[string]string {
|
||||
if key == "" {
|
||||
key = config2.DefaultChinaAreaCode
|
||||
}
|
||||
return config.MemoryForAreaInfo[key]
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
return &Config{}
|
||||
}
|
@ -45,7 +45,7 @@ func (this *Instance) Handle() {
|
||||
}
|
||||
}
|
||||
function(
|
||||
&synchronized{iModel: model.NewSysTenant()}, &synchronized{iModel: model.NewSysTenantMenu()},
|
||||
&synchronized{iModel: model.NewSysTenant()}, &synchronized{iModel: model.NewSysTenantMenu()}, &synchronized{iModel: model.NewSysTenantAuth()},
|
||||
&synchronized{iModel: model.NewSysConfig()},
|
||||
&synchronized{iModel: model.NewSysMenu()}, &synchronized{iModel: model.NewSysAuth()},
|
||||
&synchronized{iModel: model.NewSysUser(), iValues: func() interface{} {
|
||||
@ -144,7 +144,7 @@ func (this *Instance) Handle() {
|
||||
&synchronized{iModel: model.NewServiceInnovate()}, &synchronized{iModel: model.NewServiceInnovateKind()},
|
||||
// 活动管理
|
||||
&synchronized{iModel: model.NewActivityInstance()}, &synchronized{iModel: model.NewActivityApply()},
|
||||
&synchronized{iModel: model.NewActivityExamine()}, &synchronized{iModel: model.NewActivityJoin()},
|
||||
&synchronized{iModel: model.NewActivityApplyLog()}, &synchronized{iModel: model.NewActivityJoin()},
|
||||
)
|
||||
fmt.Printf("========================\n=== 数据完成迁移,成功【%d】,失败【%d】 ===\n========================\n",
|
||||
successCount, failureCount)
|
||||
|
@ -3,15 +3,18 @@ package model
|
||||
// ActivityApply 活动申请数据模型
|
||||
type ActivityApply struct {
|
||||
Model
|
||||
Local
|
||||
IdentityUID uint64 `gorm:"column:identity_uid;type:int;default:0;comment:用户身份表uuid" json:"-"`
|
||||
Image
|
||||
Mode ActivityInstanceMode `gorm:"column:mode;type:tinyint(1);default:1;comment:活动模式" json:"mode"`
|
||||
ModelTenant
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
ActivityInstanceBasic
|
||||
Amount float64 `gorm:"column:amount;type:decimal(10,2);default:0;comment:活动收费金额" json:"amount"`
|
||||
Content string `gorm:"column:content;type:text;comment:活动详情" json:"content"`
|
||||
MaxNumber int `gorm:"column:max_number;type:int(6);default:0;comment:报名限制人数,0不做限制" json:"max_number"`
|
||||
Status ActivityApplyStatus `gorm:"column:status;type:tinyint(1);default:0;comment:审核状态" json:"status"`
|
||||
Contact string `gorm:"column:contact;type:varchar(20);default:'';comment:联系人" json:"contact"`
|
||||
ContactMobile string `gorm:"column:contact_mobile;type:varchar(15);default:'';comment:联系方式" json:"contact_mobile"`
|
||||
Image
|
||||
Amount float64 `gorm:"column:amount;type:decimal(10,2);default:0;comment:活动收费金额" json:"amount"`
|
||||
Content string `gorm:"column:content;type:text;comment:活动详情" json:"content"`
|
||||
MaxNumber int `gorm:"column:max_number;type:int(6);default:0;comment:报名限制人数,0不做限制" json:"max_number"`
|
||||
Address string `gorm:"column:address;type:varchar(255);default:'';comment:活动地址" json:"address"`
|
||||
NotifyCrowd int `gorm:"column:notify_crowd;type:tinyint(3);default:0;comment:通知人群" json:"notify_crowd"`
|
||||
Status ActivityApplyStatus `gorm:"column:status;type:tinyint(1);default:0;comment:审核状态" json:"status"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
@ -22,10 +25,10 @@ type ActivityApplyStatus int
|
||||
const (
|
||||
// ActivityApplyStatusForRevoke 撤销
|
||||
ActivityApplyStatusForRevoke ActivityApplyStatus = iota - 1
|
||||
// ActivityApplyStatusForExamining 审核中
|
||||
ActivityApplyStatusForExamining
|
||||
// ActivityApplyStatusForPass 审核通过
|
||||
ActivityApplyStatusForPass
|
||||
// ActivityApplyStatusForProcessing 处理中
|
||||
ActivityApplyStatusForProcessing
|
||||
// ActivityApplyStatusForProcessed 处理结束
|
||||
ActivityApplyStatusForProcessed
|
||||
)
|
||||
|
||||
func (m *ActivityApply) TableName() string {
|
||||
|
19
app/common/model/activity_apply_log.go
Normal file
19
app/common/model/activity_apply_log.go
Normal file
@ -0,0 +1,19 @@
|
||||
package model
|
||||
|
||||
// ActivityApplyLog 活动申请日志数据模型
|
||||
type ActivityApplyLog struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
ApplyID uint64 `gorm:"column:apply_id;type:int(11);default:0;comment:活动ID" json:"apply_id"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:'';comment:备注信息" json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *ActivityApplyLog) TableName() string {
|
||||
return "activity_apply_log"
|
||||
}
|
||||
|
||||
func NewActivityApplyLog() *ActivityApplyLog {
|
||||
return &ActivityApplyLog{}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package model
|
||||
|
||||
// ActivityExamine 活动审核数据模型
|
||||
type ActivityExamine struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
ActivityID uint64 `gorm:"column:activity_id;type:int(11);default:0;comment:活动ID" json:"activity_id"`
|
||||
Examine
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *ActivityExamine) TableName() string {
|
||||
return "activity_examine"
|
||||
}
|
||||
|
||||
func NewActivityExamine() *ActivityExamine {
|
||||
return &ActivityExamine{}
|
||||
}
|
@ -1,18 +1,27 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ActivityInstance 活动数据模型
|
||||
type ActivityInstance struct {
|
||||
Model
|
||||
ModelTenant
|
||||
Mode ActivityInstanceMode `gorm:"column:mode;type:tinyint(1);default:1;comment:活动模式" json:"mode"`
|
||||
Image
|
||||
ActivityInstanceBasic
|
||||
Amount float64 `gorm:"column:amount;type:decimal(10,2);default:0;comment:活动收费金额" json:"amount"`
|
||||
Content string `gorm:"column:content;type:text;comment:活动详情" json:"content"`
|
||||
MaxNumber int `gorm:"column:max_number;type:int(6);default:0;comment:报名限制人数,0不做限制" json:"max_number"`
|
||||
Status ActivityInstanceStatus `gorm:"column:status;type:tinyint(1);default:1;comment:活动状态(1:显示,2:隐藏)" json:"status"`
|
||||
Contact string `gorm:"column:contact;type:varchar(20);default:'';comment:联系人" json:"contact"`
|
||||
ContactMobile string `gorm:"column:contact_mobile;type:varchar(15);default:'';comment:联系方式" json:"contact_mobile"`
|
||||
Image
|
||||
Area
|
||||
Industry string `gorm:"column:industry;type:varchar(255);comment:所属领域;行业信息" json:"-"`
|
||||
Amount float64 `gorm:"column:amount;type:decimal(10,2);default:0;comment:活动收费金额" json:"amount"`
|
||||
Content string `gorm:"column:content;type:text;comment:活动详情" json:"content"`
|
||||
MaxNumber int `gorm:"column:max_number;type:int(6);default:0;comment:报名限制人数,0不做限制" json:"max_number"`
|
||||
NotifyCrowd int `gorm:"column:notify_crowd;type:tinyint(3);default:0;comment:通知人群" json:"notify_crowd"`
|
||||
IsHome int `gorm:"column:is_home;type:tinyint(1);default:0;comment:首页展示(0:不展示,1:展示)" json:"is_home"`
|
||||
Sort int `gorm:"column:sort;type:tinyint(3);default:0;comment:排序,数值越小,优先排序" json:"sort"`
|
||||
Status ActivityInstanceStatus `gorm:"column:status;type:tinyint(1);default:1;comment:活动状态(1:显示,2:隐藏)" json:"status"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
@ -25,17 +34,6 @@ type ActivityInstanceBasic struct {
|
||||
JoinDeadline time.Time `gorm:"column:join_deadline;type:datetime;not null;comment:报名截止时间" json:"join_deadline"`
|
||||
}
|
||||
|
||||
// ActivityInstanceMode 活动类型
|
||||
type ActivityInstanceMode int
|
||||
|
||||
const (
|
||||
// ActivityInstanceModeForOrdinary 普通活动
|
||||
ActivityInstanceModeForOrdinary ActivityInstanceMode = iota + 1
|
||||
// ActivityInstanceModeForCharge 收费活动
|
||||
ActivityInstanceModeForCharge
|
||||
)
|
||||
|
||||
// ActivityInstanceStatus 活动状态
|
||||
type ActivityInstanceStatus int
|
||||
|
||||
const (
|
||||
@ -58,6 +56,17 @@ func (m *ActivityInstanceBasic) IsCanJoin() bool {
|
||||
return m.JoinDeadline.After(time.Now())
|
||||
}
|
||||
|
||||
func (m *ActivityInstance) SetIndustryAttribute(value []string) {
|
||||
_bytes, _ := json.Marshal(value)
|
||||
m.Industry = string(_bytes)
|
||||
}
|
||||
|
||||
func (m *ActivityInstance) GetIndustryAttribute() []string {
|
||||
out := make([]string, 0)
|
||||
_ = json.Unmarshal([]byte(m.Industry), &out)
|
||||
return out
|
||||
}
|
||||
|
||||
func NewActivityInstance() *ActivityInstance {
|
||||
return &ActivityInstance{}
|
||||
}
|
||||
|
@ -2,9 +2,10 @@ package model
|
||||
|
||||
type ActivityJoin struct {
|
||||
Model
|
||||
IdentityUID uint64 `gorm:"column:identity_uid;type:int;default:0;comment:用户身份表uuid" json:"-"`
|
||||
ActivityID uint64 `gorm:"column:activity_id;type:int(11);default:0;comment:活动ID" json:"activity_id"`
|
||||
Status ActivityJoinStatus `gorm:"column:status;type:tinyint(1);default:1;comment:报名状态(-1:取消,1:报名成功)" json:"status"`
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Identity int `gorm:"column:identity;type:tinyint(3);default:0;comment:身份信息" json:"-"`
|
||||
ActivityID uint64 `gorm:"column:activity_id;type:int(11);default:0;comment:活动ID" json:"activity_id"`
|
||||
Status ActivityJoinStatus `gorm:"column:status;type:tinyint(1);default:1;comment:报名状态(-1:取消,1:报名成功)" json:"status"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
@ -6,11 +6,12 @@ import "encoding/json"
|
||||
type ServiceInnovate struct {
|
||||
Model
|
||||
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"`
|
||||
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"`
|
||||
Description string `gorm:"column:description;type:varchar(255);default:'';comment:创新服务描述" json:"description"`
|
||||
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
|
||||
}
|
||||
|
@ -16,13 +16,13 @@ type ServiceSolutionCaseKind struct {
|
||||
type ServiceSolutionCaseMode int
|
||||
|
||||
const (
|
||||
// ServiceSolutionCaseModeForSmallCompany 中小型企业
|
||||
// ServiceSolutionCaseModeForSmallCompany 中小企业服务
|
||||
ServiceSolutionCaseModeForSmallCompany ServiceSolutionCaseMode = iota + 101
|
||||
// ServiceSolutionCaseModeForBigCompany 大型企业
|
||||
// ServiceSolutionCaseModeForBigCompany 大型企业服务
|
||||
ServiceSolutionCaseModeForBigCompany
|
||||
// ServiceSolutionCaseModeForGovernment 政府单位
|
||||
// ServiceSolutionCaseModeForGovernment 政府企业服务
|
||||
ServiceSolutionCaseModeForGovernment
|
||||
// ServiceSolutionCaseModeForResearch 科研机构
|
||||
// ServiceSolutionCaseModeForResearch 科研院所服务
|
||||
ServiceSolutionCaseModeForResearch
|
||||
)
|
||||
|
||||
@ -32,13 +32,13 @@ func (m *ServiceSolutionCaseKind) TableName() string {
|
||||
|
||||
func (m *ServiceSolutionCaseKind) ModeTitle() string {
|
||||
if m.Mode == ServiceSolutionCaseModeForSmallCompany {
|
||||
return "中小型企业"
|
||||
return "中小企业服务"
|
||||
} else if m.Mode == ServiceSolutionCaseModeForBigCompany {
|
||||
return "大型企业"
|
||||
return "大型企业服务"
|
||||
} else if m.Mode == ServiceSolutionCaseModeForGovernment {
|
||||
return "政府单位"
|
||||
return "政府企业服务"
|
||||
} else if m.Mode == ServiceSolutionCaseModeForResearch {
|
||||
return "科研机构"
|
||||
return "科研院所服务"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ type SysMenu struct {
|
||||
Model
|
||||
SysMenuBasic
|
||||
Auth string `gorm:"column:auth;type:varchar(100);default:'';comment:权限/路由" json:"auth"`
|
||||
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"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:'';comment:菜单备注" json:"remark"`
|
||||
Status SysMenuStatus `gorm:"column:status;type:tinyint(1);default:1;comment:状态" json:"status"`
|
||||
ModelDeleted
|
||||
|
@ -6,9 +6,9 @@ type ActivityJoin struct{}
|
||||
|
||||
func (*ActivityJoin) Handle(arg ...interface{}) {
|
||||
_ = model.Create(&model.ActivityJoin{
|
||||
IdentityUID: arg[0].(uint64),
|
||||
ActivityID: arg[1].(uint64),
|
||||
Status: model.ActivityJoinStatusForSuccess,
|
||||
//IdentityUID: arg[0].(uint64),
|
||||
ActivityID: arg[1].(uint64),
|
||||
Status: model.ActivityJoinStatusForSuccess,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -159,11 +159,13 @@ func registerAdminAPI(app *gin.Engine) {
|
||||
account.POST("/login", _api.Login)
|
||||
account.POST("/logout", _api.Logout)
|
||||
}
|
||||
// Config 用户管理
|
||||
config := v1.Group("/config")
|
||||
// Config 配置管理
|
||||
_config := v1.Group("/config")
|
||||
{
|
||||
_api := new(api1.Config)
|
||||
config.GET("/area", _api.Area)
|
||||
_api := new(api.Config)
|
||||
_config.GET("/area", _api.Area)
|
||||
_config.GET("/identity", _api.Identity)
|
||||
_config.GET("/industry", _api.Industry)
|
||||
}
|
||||
// User 用户管理
|
||||
user := v1.Group("/user")
|
||||
@ -268,6 +270,21 @@ func registerAdminAPI(app *gin.Engine) {
|
||||
service.POST("/message/handle", _api.MessageHandle)
|
||||
service.POST("/message/delete", _api.MessageDelete)
|
||||
}
|
||||
// Activity 活动管理
|
||||
activity := v1.Group("/activity")
|
||||
{
|
||||
_api := new(api1.Activity)
|
||||
activity.POST("", _api.Instance)
|
||||
activity.POST("/detail", _api.Detail)
|
||||
activity.POST("/add", _api.Form)
|
||||
activity.POST("/edit", _api.Form)
|
||||
activity.POST("/delete", _api.Delete)
|
||||
activity.POST("/joins", _api.Joins)
|
||||
activity.POST("/apply", _api.Apply)
|
||||
activity.POST("/apply/detail", _api.ApplyDetail)
|
||||
activity.POST("/apply/handle", _api.ApplyHandle)
|
||||
activity.POST("/apply/delete", _api.ApplyDelete)
|
||||
}
|
||||
// Logs 日志管理
|
||||
log := v1.Group("/log")
|
||||
{
|
||||
@ -294,7 +311,7 @@ func registerEnterpriseAPI(app *gin.Engine) {
|
||||
// Config 配置管理
|
||||
configV1 := v1.Group("/config")
|
||||
{
|
||||
_api := new(api3.Config)
|
||||
_api := new(api.Config)
|
||||
configV1.GET("/area", _api.Area)
|
||||
configV1.GET("/identity", _api.Identity)
|
||||
configV1.GET("/industry", _api.Industry)
|
||||
|
Reference in New Issue
Block a user