feat:完善用户项目模块数据模型

This commit is contained in:
henry
2021-11-29 14:55:53 +08:00
parent fb5a3d910b
commit 998b78fb23
7 changed files with 304 additions and 1 deletions

View File

@ -111,6 +111,17 @@ type (
Introduce string `json:"introduce" form:"introduce"`
IsSubmit int `json:"is_submit" form:"is_submit"`
}
// projectForm 项目参数
projectForm struct {
Title string `json:"title" form:"title" binding:"required"`
Kind string `json:"kind" form:"kind" binding:"required"`
Role int `json:"role" form:"v" binding:"required"`
BeginAt string `json:"begin_at" form:"begin_at" binding:"required"`
FinishAt string `json:"finish_at" form:"finish_at" binding:"required"`
Amount float64 `json:"amount" form:"amount" binding:"required"`
Source string `json:"source" form:"source" binding:"required"`
Director string `json:"director" form:"director" binding:"required"`
}
)
func (a *instanceForm) FilterProveImages() string {
@ -613,3 +624,75 @@ func (*Technology) ProductDelete(c *gin.Context) {
Delete(form.Convert())
api.APIResponse(err)(c)
}
func (a *Technology) Project(c *gin.Context) {
form := &struct {
Title string `json:"title" form:"title"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
List(form.Title, form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}
func (a *Technology) ProjectAdd(c *gin.Context) {
form := new(projectForm)
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
Form(&technology2.ProjectParams{
Title: form.Title, Kind: form.Kind, Source: form.Source, Director: form.Director,
BeginAt: form.BeginAt, FinishAt: form.FinishAt, Amount: form.Amount, Role: form.Role,
})
api.APIResponse(err)(c)
}
func (a *Technology) ProjectEdit(c *gin.Context) {
form := &struct {
api.IDStringForm
projectForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
Form(&technology2.ProjectParams{ID: form.Convert(),
Title: form.Title, Kind: form.Kind, Source: form.Source, Director: form.Director,
BeginAt: form.BeginAt, FinishAt: form.FinishAt, Amount: form.Amount, Role: form.Role,
})
api.APIResponse(err)(c)
}
func (*Technology) ProjectShelf(c *gin.Context) {
form := &struct {
api.IDStringForm
Status int `json:"status" form:"status" binding:"required"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
Shelf(form.Convert(), form.Status)
api.APIResponse(err)(c)
}
func (a *Technology) ProjectDelete(c *gin.Context) {
form := new(api.IDStringForm)
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
Delete(form.Convert())
api.APIResponse(err)(c)
}