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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user