12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package system
- import (
- "kpt-pasture/http/middleware"
- "net/http"
- "strconv"
- operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
- "gitee.com/xuyiping_admin/pkg/valid"
- pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- "gitee.com/xuyiping_admin/pkg/apierr"
- "gitee.com/xuyiping_admin/pkg/ginutil"
- "github.com/gin-gonic/gin"
- )
- func DeptList(c *gin.Context) {
- var req pasturePb.SearchDeptRequest
- if err := ginutil.BindProto(c, &req); err != nil {
- apierr.AbortBadRequest(c, http.StatusBadRequest, err)
- return
- }
- pagination := &pasturePb.PaginationModel{
- Page: int32(c.GetInt(middleware.Page)),
- PageSize: int32(c.GetInt(middleware.PageSize)),
- PageOffset: int32(c.GetInt(middleware.PageOffset)),
- }
- res, err := middleware.Dependency(c).StoreEventHub.OpsService.SearchSystemDeptList(c, &req, pagination)
- if err != nil {
- apierr.ClassifiedAbort(c, err)
- return
- }
- ginutil.JSONResp(c, res)
- }
- func DepIsShow(c *gin.Context) {
- IDStr := c.Param("id")
- Id, _ := strconv.Atoi(IDStr)
- if err := valid.Validate(Id, valid.Required, valid.Min(1)); err != nil {
- apierr.ClassifiedAbort(c, err)
- return
- }
- if err := middleware.Dependency(c).StoreEventHub.OpsService.SystemDepDelete(c, int64(Id)); err != nil {
- apierr.ClassifiedAbort(c, err)
- return
- }
- ginutil.JSONResp(c, &operationPb.CommonOK{
- Code: http.StatusOK,
- Msg: "ok",
- Data: &operationPb.Success{Success: true},
- })
- }
- func DepCreateOrUpdate(c *gin.Context) {
- var req pasturePb.SearchDeptRequest
- if err := ginutil.BindProto(c, &req); err != nil {
- apierr.ClassifiedAbort(c, err)
- return
- }
- if err := middleware.Dependency(c).StoreEventHub.OpsService.SystemDeptCreateOrUpdate(c, &req); err != nil {
- apierr.ClassifiedAbort(c, err)
- return
- }
- ginutil.JSONResp(c, &operationPb.CommonOK{
- Code: http.StatusOK,
- Msg: "ok",
- Data: &operationPb.Success{Success: true},
- })
- }
- func DeptTree(c *gin.Context) {
- var req pasturePb.SearchDeptRequest
- if err := ginutil.BindProto(c, &req); err != nil {
- apierr.ClassifiedAbort(c, err)
- return
- }
- res, err := middleware.Dependency(c).StoreEventHub.OpsService.SystemDeptTree(c, &req)
- if err != nil {
- apierr.ClassifiedAbort(c, err)
- return
- }
- ginutil.JSONResp(c, res)
- }
|