| | |
| | | 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 |
| | |
| | | public class MemberController { |
| | | |
| | | private final MemberService memberService; |
| | | |
| | | // Jackson 实例(用于手动解析 JSON) |
| | | private final ObjectMapper objectMapper = new ObjectMapper(); |
| | | @PutMapping("/updateNickName") |
| | | public Result updateMemberNickName(@RequestBody MemberNickNameForm form){ |
| | | 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); |
| | | } |
| | | |