refactor🎨: 岗位删除修改为data传值方式
This commit is contained in:
1 parent
37fe63126c
commit
636294b6f5
4 files changed
+12
-13
No files matched your search
@@ -162,13 +162,13 @@ func (e SysPost) Update(c *gin.Context) {
|
|||||||
// @Param id path int true "id"
|
// @Param id path int true "id"
|
||||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||||
// @Success 500 {string} string "{"code": 500, "message": "删除失败"}"
|
// @Success 500 {string} string "{"code": 500, "message": "删除失败"}"
|
||||||
// @Router /api/v1/post/{postId} [delete]
|
// @Router /api/v1/post [delete]
|
||||||
func (e SysPost) Delete(c *gin.Context) {
|
func (e SysPost) Delete(c *gin.Context) {
|
||||||
s := service.SysPost{}
|
s := service.SysPost{}
|
||||||
req := dto.SysPostById{}
|
req := dto.SysPostById{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req, binding.JSON, nil).
|
Bind(&req, binding.JSON).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
Errors
|
Errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -20,6 +20,6 @@ func registerSyPostRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddlew
|
|||||||
r.GET("/:id", api.Get)
|
r.GET("/:id", api.Get)
|
||||||
r.POST("", api.Insert)
|
r.POST("", api.Insert)
|
||||||
r.PUT("/:id", api.Update)
|
r.PUT("/:id", api.Update)
|
||||||
r.DELETE("/:id", api.Delete)
|
r.DELETE("", api.Delete)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,12 +24,12 @@ func (m *SysPostSearch) GetNeedSearch() interface{} {
|
|||||||
|
|
||||||
// SysPostControl 增、改使用的结构体
|
// SysPostControl 增、改使用的结构体
|
||||||
type SysPostControl struct {
|
type SysPostControl struct {
|
||||||
PostId int `uri:"id" comment:"id"` // id
|
PostId int `uri:"id" comment:"id"`
|
||||||
PostName string `form:"postName" comment:"名称"` // 名称
|
PostName string `form:"postName" comment:"名称"`
|
||||||
PostCode string `form:"postCode" comment:"编码"` // 编码
|
PostCode string `form:"postCode" comment:"编码"`
|
||||||
Sort int `form:"sort" comment:"排序"` // 排序
|
Sort int `form:"sort" comment:"排序"`
|
||||||
Status int `form:"status" comment:"状态"` // 状态
|
Status int `form:"status" comment:"状态"`
|
||||||
Remark string `form:"remark" comment:"备注"` // 备注
|
Remark string `form:"remark" comment:"备注"`
|
||||||
common.ControlBy
|
common.ControlBy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,12 +55,11 @@ func (e *SysPost) GetSysPost(d *dto.SysPostById, model *models.SysPost) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// InsertSysPost 创建SysPost对象
|
// InsertSysPost 创建SysPost对象
|
||||||
func (e *SysPost) InsertSysPost(model *dto.SysPostControl) error {
|
func (e *SysPost) InsertSysPost(c *dto.SysPostControl) error {
|
||||||
var err error
|
var err error
|
||||||
var data models.SysPost
|
var data models.SysPost
|
||||||
|
c.Generate(&data)
|
||||||
err = e.Orm.Model(&data).
|
err = e.Orm.Create(&data).Error
|
||||||
Create(model).Error
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Log.Errorf("db error:%s", err)
|
e.Log.Errorf("db error:%s", err)
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in new issue
Block a user