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