feat: manage merchant members
This commit is contained in:
@@ -438,6 +438,42 @@ func (h *MerchantHandler) AddCurrentMerchantMember(c *gin.Context) {
|
||||
response.OK(c, member)
|
||||
}
|
||||
|
||||
type updateMemberReq struct {
|
||||
Role string `json:"role" binding:"required"`
|
||||
Status int `json:"status"`
|
||||
IsDefault bool `json:"is_default"`
|
||||
}
|
||||
|
||||
func (h *MerchantHandler) UpdateCurrentMerchantMember(c *gin.Context) {
|
||||
memberID, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
var req updateMemberReq
|
||||
if memberID == 0 || c.ShouldBindJSON(&req) != nil {
|
||||
response.BadRequest(c, "参数错误:角色必填")
|
||||
return
|
||||
}
|
||||
member, err := h.merchantSvc.UpdateMember(middleware.GetMerchantID(c), uint(memberID), service.UpdateMemberInput{
|
||||
Role: req.Role, Status: req.Status, IsDefault: req.IsDefault,
|
||||
}, middleware.GetUserID(c))
|
||||
if err != nil {
|
||||
response.BadRequest(c, err.Error())
|
||||
return
|
||||
}
|
||||
response.OK(c, member)
|
||||
}
|
||||
|
||||
func (h *MerchantHandler) RemoveCurrentMerchantMember(c *gin.Context) {
|
||||
memberID, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
if memberID == 0 {
|
||||
response.BadRequest(c, "参数错误")
|
||||
return
|
||||
}
|
||||
if err := h.merchantSvc.RemoveMember(middleware.GetMerchantID(c), uint(memberID), middleware.GetUserID(c)); err != nil {
|
||||
response.BadRequest(c, err.Error())
|
||||
return
|
||||
}
|
||||
response.OK(c, nil)
|
||||
}
|
||||
|
||||
func (h *MerchantHandler) ListRoles(c *gin.Context) {
|
||||
roles, err := h.merchantSvc.ListRoles(middleware.GetMerchantID(c))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user