refactor🎨: 缩减函数名称
This commit is contained in:
1 parent
c96d9c35a7
commit
9a2c0729f6
22 files changed
+111
-126
No files matched your search
+13
-19
@@ -18,7 +18,7 @@ type SysPost struct {
|
||||
api.Api
|
||||
}
|
||||
|
||||
// GetSysPostList
|
||||
// GetPage
|
||||
// @Summary 岗位列表数据
|
||||
// @Description 获取JSON
|
||||
// @Tags 岗位
|
||||
@@ -29,7 +29,7 @@ type SysPost struct {
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/post [get]
|
||||
// @Security Bearer
|
||||
func (e SysPost) GetSysPostList(c *gin.Context) {
|
||||
func (e SysPost) GetPage(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostSearch{}
|
||||
err := e.MakeContext(c).
|
||||
@@ -55,7 +55,7 @@ func (e SysPost) GetSysPostList(c *gin.Context) {
|
||||
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
// GetSysPost
|
||||
// Get
|
||||
// @Summary 获取岗位信息
|
||||
// @Description 获取JSON
|
||||
// @Tags 岗位
|
||||
@@ -63,7 +63,7 @@ func (e SysPost) GetSysPostList(c *gin.Context) {
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/post/{postId} [get]
|
||||
// @Security Bearer
|
||||
func (e SysPost) GetSysPost(c *gin.Context) {
|
||||
func (e SysPost) Get(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostById{}
|
||||
err := e.MakeContext(c).
|
||||
@@ -80,14 +80,14 @@ func (e SysPost) GetSysPost(c *gin.Context) {
|
||||
|
||||
err = s.GetSysPost(&req, &object)
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(500, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(object, "查看成功")
|
||||
}
|
||||
|
||||
// InsertSysPost
|
||||
// Insert
|
||||
// @Summary 添加岗位
|
||||
// @Description 获取JSON
|
||||
// @Tags 岗位
|
||||
@@ -98,7 +98,7 @@ func (e SysPost) GetSysPost(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/post [post]
|
||||
// @Security Bearer
|
||||
func (e SysPost) InsertSysPost(c *gin.Context) {
|
||||
func (e SysPost) Insert(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostControl{}
|
||||
err := e.MakeContext(c).
|
||||
@@ -111,21 +111,16 @@ func (e SysPost) InsertSysPost(c *gin.Context) {
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 设置创建人
|
||||
req.SetCreateBy(user.GetUserId(c))
|
||||
|
||||
err = s.InsertSysPost(&req)
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(http.StatusInternalServerError, err, "创建失败")
|
||||
e.Error(500, err, "创建失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(req.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
// UpdateSysPost
|
||||
// Update
|
||||
// @Summary 修改岗位
|
||||
// @Description 获取JSON
|
||||
// @Tags 岗位
|
||||
@@ -136,7 +131,7 @@ func (e SysPost) InsertSysPost(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/post/ [put]
|
||||
// @Security Bearer
|
||||
func (e SysPost) UpdateSysPost(c *gin.Context) {
|
||||
func (e SysPost) Update(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostControl{}
|
||||
err := e.MakeContext(c).
|
||||
@@ -160,7 +155,7 @@ func (e SysPost) UpdateSysPost(c *gin.Context) {
|
||||
e.OK(req.GetId(), "更新成功")
|
||||
}
|
||||
|
||||
// DeleteSysPost
|
||||
// Delete
|
||||
// @Summary 删除岗位
|
||||
// @Description 删除数据
|
||||
// @Tags 岗位
|
||||
@@ -168,7 +163,7 @@ func (e SysPost) UpdateSysPost(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 500 {string} string "{"code": 500, "message": "删除失败"}"
|
||||
// @Router /api/v1/post/{postId} [delete]
|
||||
func (e SysPost) DeleteSysPost(c *gin.Context) {
|
||||
func (e SysPost) Delete(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostById{}
|
||||
err := e.MakeContext(c).
|
||||
@@ -182,11 +177,10 @@ func (e SysPost) DeleteSysPost(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
req.SetUpdateBy(user.GetUserId(c))
|
||||
|
||||
err = s.RemoveSysPost(&req)
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
return
|
||||
}
|
||||
e.OK(req.GetId(), "删除成功")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user