package cn.lili.controller.lmk; import cn.lili.base.Result; import cn.lili.modules.lmk.domain.form.MemberBindStoreForm; import cn.lili.modules.lmk.domain.form.MemberNickNameForm; import cn.lili.modules.lmk.domain.form.VideoCommentForm; import cn.lili.modules.member.service.MemberService; import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.Api; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.io.BufferedReader; import java.io.IOException; import java.nio.charset.StandardCharsets; /** * lmk-shop-java * * @author : zxl * @date : 2025-07-31 15:42 **/ @RequiredArgsConstructor @Api(value = "小程序端会员信息处理补充", tags = "小程序端会员信息处理补充") @RestController @RequestMapping("/buyer/lmk/member") public class MemberController { private final MemberService memberService; // Jackson 实例(用于手动解析 JSON) private final ObjectMapper objectMapper = new ObjectMapper(); @PutMapping("/updateNickName") public Result updateMemberNickName(HttpServletRequest request)throws IOException { BufferedReader reader = request.getReader(); StringBuilder jsonStr = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { jsonStr.append(line); } String requestBody = jsonStr.toString(); System.out.println("后端接收的 JSON 字符串:" + requestBody); MemberNickNameForm form = objectMapper.readValue( requestBody.getBytes(StandardCharsets.UTF_8), // 转为 UTF-8 字节数组 MemberNickNameForm.class // 目标实体类 ); return memberService.updateMemberNickName(form); } @PutMapping("/bindMemberAndStore") public Result bindMemberAndStore(@RequestBody MemberBindStoreForm form){ return memberService.bindMemberAndStore(form); } }