This commit is contained in:
2026-10-26 22:42:29 +08:00
parent 6f13816bcf
commit 554f6737cf
9 changed files with 331 additions and 47 deletions
@@ -117,6 +117,19 @@ func (s *Service) Delete(ctx context.Context, id uint64) error {
return s.repo.Delete(ctx, id)
}
// StatusReq 更新小程序状态请求。状态仅允许 0(禁用)或 1(启用)。
type StatusReq struct {
Status int8 `json:"status" binding:"required,oneof=0 1"`
}
// UpdateStatus 按 ID 更新小程序状态(0 禁用、1 启用),返回更新后的小程序。
func (s *Service) UpdateStatus(ctx context.Context, id uint64, status int8) (*model.MiniProgram, error) {
if err := s.repo.Update(ctx, id, map[string]interface{}{"status": status}); err != nil {
return nil, err
}
return s.repo.GetByID(ctx, id)
}
// validateExt 校验扩展字段为合法 JSON(允许为空字符串)。
func validateExt(s string) error {
if s == "" {