| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 | 
							- 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},
 
- 	})
 
- }
 
 
  |