-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from suyuan32/feat-post
Feat: post management
- Loading branch information
Showing
73 changed files
with
8,951 additions
and
2,932 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import "base.api" | ||
|
||
type ( | ||
// The response data of post information | 职位信息 | ||
PostInfo { | ||
BaseInfo | ||
|
||
// Name translation | 名称翻译 | ||
Trans string `json:"trans"` | ||
|
||
// Status | ||
Status uint32 `json:"status"` | ||
|
||
// Sort | ||
Sort uint32 `json:"sort"` | ||
|
||
// Name | ||
Name string `json:"name"` | ||
|
||
// Code | ||
Code string `json:"code"` | ||
|
||
// Remark | ||
Remark string `json:"remark"` | ||
} | ||
|
||
// Create or update post information request | 创建或更新职位信息 | ||
CreateOrUpdatePostReq { | ||
// ID | ||
// Required: true | ||
Id uint64 `json:"id"` | ||
|
||
// Status | ||
Status uint32 `json:"status"` | ||
|
||
// Sort | ||
Sort uint32 `json:"sort"` | ||
|
||
// Name | ||
Name string `json:"name"` | ||
|
||
// Code | ||
Code string `json:"code"` | ||
|
||
// Remark | ||
Remark string `json:"remark"` | ||
} | ||
|
||
// The response data of post list | 职位列表数据 | ||
PostListResp { | ||
BaseDataInfo | ||
|
||
// Post list data | 职位 列表数据 | ||
Data PostListInfo `json:"data"` | ||
} | ||
|
||
// Post list data | 职位 列表数据 | ||
PostListInfo { | ||
BaseListInfo | ||
|
||
// The API list data | 职位 列表数据 | ||
Data []PostInfo `json:"data"` | ||
} | ||
|
||
// Get post list request params | 职位列表请求参数 | ||
PostListReq { | ||
PageInfo | ||
|
||
// Name | ||
Name string `json:"name,optional"` | ||
} | ||
) | ||
|
||
@server( | ||
jwt: Auth | ||
group: post | ||
middleware: Authority | ||
) | ||
|
||
service core { | ||
// Create or update post information | 创建或更新职位 | ||
@handler createOrUpdatePost | ||
post /post/create_or_update (CreateOrUpdatePostReq) returns (BaseMsgResp) | ||
|
||
// Delete post information | 删除职位信息 | ||
@handler deletePost | ||
post /post/delete (IDReq) returns (BaseMsgResp) | ||
|
||
// Get post list | 获取职位列表 | ||
@handler getPostList | ||
post /post/list (PostListReq) returns (PostListResp) | ||
|
||
// Delete post information | 删除职位信息 | ||
@handler batchDeletePost | ||
post /post/batch_delete (IDsReq) returns (BaseMsgResp) | ||
|
||
// Set post's status | 更新职位状态 | ||
@handler updatePostStatus | ||
post /post/status (StatusCodeReq) returns (BaseMsgResp) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package post | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/zeromicro/go-zero/rest/httpx" | ||
|
||
"github.com/suyuan32/simple-admin-core/api/internal/logic/post" | ||
"github.com/suyuan32/simple-admin-core/api/internal/svc" | ||
"github.com/suyuan32/simple-admin-core/api/internal/types" | ||
) | ||
|
||
// swagger:route post /post/batch_delete post BatchDeletePost | ||
// | ||
// Delete post information | 删除职位信息 | ||
// | ||
// Delete post information | 删除职位信息 | ||
// | ||
// Parameters: | ||
// + name: body | ||
// require: true | ||
// in: body | ||
// type: IDsReq | ||
// | ||
// Responses: | ||
// 200: BaseMsgResp | ||
|
||
func BatchDeletePostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.IDsReq | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := post.NewBatchDeletePostLogic(r, svcCtx) | ||
resp, err := l.BatchDeletePost(&req) | ||
if err != nil { | ||
err = svcCtx.Trans.TransError(r.Header.Get("Accept-Language"), err) | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
api/internal/handler/post/create_or_update_post_handler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package post | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/zeromicro/go-zero/rest/httpx" | ||
|
||
"github.com/suyuan32/simple-admin-core/api/internal/logic/post" | ||
"github.com/suyuan32/simple-admin-core/api/internal/svc" | ||
"github.com/suyuan32/simple-admin-core/api/internal/types" | ||
) | ||
|
||
// swagger:route post /post/create_or_update post CreateOrUpdatePost | ||
// | ||
// Create or update post information | 创建或更新职位 | ||
// | ||
// Create or update post information | 创建或更新职位 | ||
// | ||
// Parameters: | ||
// + name: body | ||
// require: true | ||
// in: body | ||
// type: CreateOrUpdatePostReq | ||
// | ||
// Responses: | ||
// 200: BaseMsgResp | ||
|
||
func CreateOrUpdatePostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.CreateOrUpdatePostReq | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := post.NewCreateOrUpdatePostLogic(r, svcCtx) | ||
resp, err := l.CreateOrUpdatePost(&req) | ||
if err != nil { | ||
err = svcCtx.Trans.TransError(r.Header.Get("Accept-Language"), err) | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package post | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/zeromicro/go-zero/rest/httpx" | ||
|
||
"github.com/suyuan32/simple-admin-core/api/internal/logic/post" | ||
"github.com/suyuan32/simple-admin-core/api/internal/svc" | ||
"github.com/suyuan32/simple-admin-core/api/internal/types" | ||
) | ||
|
||
// swagger:route post /post/delete post DeletePost | ||
// | ||
// Delete post information | 删除职位信息 | ||
// | ||
// Delete post information | 删除职位信息 | ||
// | ||
// Parameters: | ||
// + name: body | ||
// require: true | ||
// in: body | ||
// type: IDReq | ||
// | ||
// Responses: | ||
// 200: BaseMsgResp | ||
|
||
func DeletePostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.IDReq | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := post.NewDeletePostLogic(r, svcCtx) | ||
resp, err := l.DeletePost(&req) | ||
if err != nil { | ||
err = svcCtx.Trans.TransError(r.Header.Get("Accept-Language"), err) | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package post | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/zeromicro/go-zero/rest/httpx" | ||
|
||
"github.com/suyuan32/simple-admin-core/api/internal/logic/post" | ||
"github.com/suyuan32/simple-admin-core/api/internal/svc" | ||
"github.com/suyuan32/simple-admin-core/api/internal/types" | ||
) | ||
|
||
// swagger:route post /post/list post GetPostList | ||
// | ||
// Get post list | 获取职位列表 | ||
// | ||
// Get post list | 获取职位列表 | ||
// | ||
// Parameters: | ||
// + name: body | ||
// require: true | ||
// in: body | ||
// type: PostListReq | ||
// | ||
// Responses: | ||
// 200: PostListResp | ||
|
||
func GetPostListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.PostListReq | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := post.NewGetPostListLogic(r, svcCtx) | ||
resp, err := l.GetPostList(&req) | ||
if err != nil { | ||
err = svcCtx.Trans.TransError(r.Header.Get("Accept-Language"), err) | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package post | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/zeromicro/go-zero/rest/httpx" | ||
|
||
"github.com/suyuan32/simple-admin-core/api/internal/logic/post" | ||
"github.com/suyuan32/simple-admin-core/api/internal/svc" | ||
"github.com/suyuan32/simple-admin-core/api/internal/types" | ||
) | ||
|
||
// swagger:route post /post/status post UpdatePostStatus | ||
// | ||
// Set post's status | 更新职位状态 | ||
// | ||
// Set post's status | 更新职位状态 | ||
// | ||
// Parameters: | ||
// + name: body | ||
// require: true | ||
// in: body | ||
// type: StatusCodeReq | ||
// | ||
// Responses: | ||
// 200: BaseMsgResp | ||
|
||
func UpdatePostStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.StatusCodeReq | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := post.NewUpdatePostStatusLogic(r, svcCtx) | ||
resp, err := l.UpdatePostStatus(&req) | ||
if err != nil { | ||
err = svcCtx.Trans.TransError(r.Header.Get("Accept-Language"), err) | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
Oops, something went wrong.