优化商户管理, 增加商户名重置密码等等
This commit is contained in:
@@ -741,6 +741,56 @@ func (h *MerchantHandler) AddPlatformMerchantMember(c *gin.Context) {
|
||||
response.OK(c, member)
|
||||
}
|
||||
|
||||
// AdminGetMerchantAccount 平台管理员查看指定商户的负责人登录账号。
|
||||
func (h *MerchantHandler) AdminGetMerchantAccount(c *gin.Context) {
|
||||
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
if id == 0 {
|
||||
response.BadRequest(c, "商户 ID 无效")
|
||||
return
|
||||
}
|
||||
accounts, err := h.merchantSvc.ListOwnerAccounts(uint(id))
|
||||
if err != nil {
|
||||
response.ServerError(c, err.Error())
|
||||
return
|
||||
}
|
||||
response.OK(c, accounts)
|
||||
}
|
||||
|
||||
type adminUpdateMerchantAccountReq struct {
|
||||
UserID uint `json:"user_id" binding:"required"`
|
||||
Username string `json:"username" binding:"required,min=3,max=64"`
|
||||
Nickname string `json:"nickname" binding:"max=64"`
|
||||
Password string `json:"password" binding:"omitempty,min=6,max=128"`
|
||||
Status *int `json:"status"`
|
||||
}
|
||||
|
||||
// AdminUpdateMerchantAccount 平台管理员维护指定商户的负责人登录账号:
|
||||
// 修改用户名/昵称、重置密码、启用停用;密码留空表示不重置。
|
||||
func (h *MerchantHandler) AdminUpdateMerchantAccount(c *gin.Context) {
|
||||
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
var req adminUpdateMerchantAccountReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
response.BadRequest(c, "参数错误:用户名必填(3-64 位),密码至少 6 位")
|
||||
return
|
||||
}
|
||||
if id == 0 {
|
||||
response.BadRequest(c, "商户 ID 无效")
|
||||
return
|
||||
}
|
||||
account, err := h.merchantSvc.UpdateMerchantOwnerAccount(uint(id), service.UpdateMerchantOwnerAccountInput{
|
||||
UserID: req.UserID,
|
||||
Username: req.Username,
|
||||
Nickname: req.Nickname,
|
||||
Password: req.Password,
|
||||
Status: req.Status,
|
||||
}, middleware.GetUserID(c))
|
||||
if err != nil {
|
||||
response.BadRequest(c, err.Error())
|
||||
return
|
||||
}
|
||||
response.OK(c, account)
|
||||
}
|
||||
|
||||
func pageParams(c *gin.Context) (int, int) {
|
||||
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
|
||||
size, _ := strconv.Atoi(c.DefaultQuery("size", "20"))
|
||||
|
||||
Reference in New Issue
Block a user