186 lines
5.0 KiB
Go
186 lines
5.0 KiB
Go
package api
|
|
|
|
import (
|
|
"SciencesServer/app/api/admin/controller/manage"
|
|
"SciencesServer/app/basic/api"
|
|
"SciencesServer/app/basic/config"
|
|
"SciencesServer/app/session"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type Manage struct{}
|
|
|
|
type (
|
|
// manageForm 参数信息
|
|
manageForm struct {
|
|
api.IDStringForm
|
|
api.TenantIDStringForm
|
|
api.ImageForm
|
|
Name string `json:"name" form:"name" binding:"required"`
|
|
Code string `json:"code" form:"code" binding:"required"`
|
|
Mobile string `json:"mobile" form:"mobile" binding:"required"`
|
|
config.Area
|
|
Industrys []string `json:"industrys" form:"industrys"`
|
|
Keywords []string `json:"keywords" form:"keywords"`
|
|
Introduce string `json:"introduce" form:"introduce"`
|
|
}
|
|
// manageExamineForm 审核处理
|
|
manageExamineForm struct {
|
|
api.IDStringForm
|
|
Identity int
|
|
Status int `json:"status" form:"status" binding:"required"`
|
|
}
|
|
)
|
|
|
|
func (c *manageForm) bind() *manage.BasicParams {
|
|
return &manage.BasicParams{ID: c.IDStringForm.Convert(), TenantID: c.TenantIDStringForm.Convert(),
|
|
Name: c.Name, Image: c.FilterImageURL(), Code: c.Code, Mobile: c.Mobile,
|
|
Introduce: c.Introduce, Area: c.Area, Industrys: c.Industrys, Keywords: c.Keywords,
|
|
}
|
|
}
|
|
|
|
// handle 审核处理
|
|
func (a *manageExamineForm) handle(session *session.Admin, params map[string]interface{}) error {
|
|
return manage.NewExamine()(session).Launch(a.Convert(), a.Identity, a.Status, params)
|
|
}
|
|
|
|
func (*Manage) Company(c *gin.Context) {
|
|
form := &struct {
|
|
api.TenantIDStringForm
|
|
Name string `json:"name" form:"name"`
|
|
ExamineStatus int `json:"examine_status" form:"examine_status"`
|
|
api.PageForm
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := manage.NewCompany()(api.GetSession()(c).(*session.Admin)).Instance(form.Convert(), form.Name,
|
|
form.ExamineStatus, form.Page, form.PageSize)
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*Manage) CompanyDetail(c *gin.Context) {
|
|
form := new(api.IDStringForm)
|
|
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := manage.NewCompany()(api.GetSession()(c).(*session.Admin)).Detail(form.Convert())
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*Manage) CompanyExamine(c *gin.Context) {
|
|
form := &struct {
|
|
manageExamineForm
|
|
Kind int `json:"kind" form:"kind" binding:"required"`
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
form.Identity = config.TenantUserIdentityForCompany
|
|
err := form.handle(api.GetSession()(c).(*session.Admin), map[string]interface{}{"kind": form.Kind})
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
func (*Manage) Expert(c *gin.Context) {
|
|
form := &struct {
|
|
api.TenantIDStringForm
|
|
Name string `json:"name" form:"name"`
|
|
ExamineStatus int `json:"examine_status" form:"examine_status"`
|
|
api.PageForm
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := manage.NewExpert()(api.GetSession()(c).(*session.Admin)).Instance(form.Convert(), form.Name, form.ExamineStatus, form.Page, form.PageSize)
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*Manage) ExpertDetail(c *gin.Context) {
|
|
form := new(api.IDStringForm)
|
|
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := manage.NewExpert()(api.GetSession()(c).(*session.Admin)).Detail(form.Convert())
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*Manage) ExpertForm(c *gin.Context) {
|
|
form := &struct {
|
|
manageForm
|
|
config.IdentityForExpert
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := manage.NewExpert()(api.GetSession()(c).(*session.Admin)).Form(form.bind(), &form.IdentityForExpert)
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
func (*Manage) ExpertExamine(c *gin.Context) {
|
|
form := new(manageExamineForm)
|
|
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
form.Identity = config.TenantUserIdentityForExpert
|
|
err := form.handle(api.GetSession()(c).(*session.Admin), nil)
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
func (*Manage) Laboratory(c *gin.Context) {
|
|
|
|
}
|
|
|
|
func (*Manage) LaboratoryExamine(c *gin.Context) {
|
|
form := new(manageExamineForm)
|
|
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
form.Identity = config.TenantUserIdentityForLaboratory
|
|
err := form.handle(api.GetSession()(c).(*session.Admin), nil)
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
func (*Manage) Research(c *gin.Context) {
|
|
|
|
}
|
|
|
|
func (*Manage) ResearchExamine(c *gin.Context) {
|
|
form := new(manageExamineForm)
|
|
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
form.Identity = config.TenantUserIdentityForResearch
|
|
err := form.handle(api.GetSession()(c).(*session.Admin), nil)
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
func (*Manage) Agent(c *gin.Context) {
|
|
|
|
}
|
|
|
|
func (*Manage) AgentExamine(c *gin.Context) {
|
|
form := new(manageExamineForm)
|
|
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
form.Identity = config.TenantUserIdentityForAgent
|
|
err := form.handle(api.GetSession()(c).(*session.Admin), nil)
|
|
api.APIResponse(err)(c)
|
|
}
|