// Path: examples/oauth2/src/main/java/com/github/hippoom/wechat/mp/examples/oauth2/http/WeChatUserRestController.java
// @Slf4j
// @RestController
// @RequiredArgsConstructor
// public class WeChatUserRestController {
// 
//     @NonNull
//     private final WeChatUserProfileResourceAssembler userResourceAssembler;
// 
//     @NonNull
//     private final WxMpUserService wxMpUserService;
// 
//     @SneakyThrows
//     @RequestMapping(value = "/rel/wechat/user/profile/me", method = GET)
//     public WeChatUserProfileResource me(@CurrentWeChatMpUser OpenId openId) {
//         WxMpUser userProfile = wxMpUserService.userInfo(openId.getValue());
//         return userResourceAssembler.toResource(userProfile);
//     }
// 
// 
// }
// 
// Path: examples/oauth2/src/main/java/com/github/hippoom/wechat/mp/examples/oauth2/http/resource/WeChatUserProfileResource.java
// @Data
// @EqualsAndHashCode(callSuper = false)
// public class WeChatUserProfileResource extends ResourceSupport {
// 
//     private String nickname;
//     private String avatar;
// }
// 
// Path: wechat-mp-autoconfigure/src/main/java/com/github/hippoom/wechat/oauth/OpenId.java
// @Value
// public class OpenId {
// 
//     private String value;
// 
//     private OpenId(String value) {
//         this.value = value;
//     }
// 
//     public static OpenId valueOf(String value) {
//         return new OpenId(value);
//     }
// }


import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import com.github.hippoom.wechat.mp.examples.oauth2.http.WeChatUserRestController;
import com.github.hippoom.wechat.mp.examples.oauth2.http.resource.WeChatUserProfileResource;
import com.github.hippoom.wechat.oauth.OpenId;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
import org.springframework.stereotype.Component;
package com.github.hippoom.wechat.mp.examples.oauth2.http.assembler;



@Component
public class WeChatUserProfileResourceAssembler extends
    ResourceAssemblerSupport<WxMpUser, WeChatUserProfileResource> {


    public WeChatUserProfileResourceAssembler() {
        super(WeChatUserRestController.class, WeChatUserProfileResource.class);
    }

    @Override
    public WeChatUserProfileResource toResource(WxMpUser entity) {
        WeChatUserProfileResource resource = new WeChatUserProfileResource();
        resource.setAvatar(entity.getHeadImgUrl());
        resource.setNickname(entity.getNickname());
        resource
            .add(
// Path: examples/oauth2/src/main/java/com/github/hippoom/wechat/mp/examples/oauth2/http/WeChatUserRestController.java
// @Slf4j
// @RestController
// @RequiredArgsConstructor
// public class WeChatUserRestController {
// 
//     @NonNull
//     private final WeChatUserProfileResourceAssembler userResourceAssembler;
// 
//     @NonNull
//     private final WxMpUserService wxMpUserService;
// 
//     @SneakyThrows
//     @RequestMapping(value = "/rel/wechat/user/profile/me", method = GET)
//     public WeChatUserProfileResource me(@CurrentWeChatMpUser OpenId openId) {
//         WxMpUser userProfile = wxMpUserService.userInfo(openId.getValue());
//         return userResourceAssembler.toResource(userProfile);
//     }
// 
// 
// }
// 
// Path: examples/oauth2/src/main/java/com/github/hippoom/wechat/mp/examples/oauth2/http/resource/WeChatUserProfileResource.java
// @Data
// @EqualsAndHashCode(callSuper = false)
// public class WeChatUserProfileResource extends ResourceSupport {
// 
//     private String nickname;
//     private String avatar;
// }
// 
// Path: wechat-mp-autoconfigure/src/main/java/com/github/hippoom/wechat/oauth/OpenId.java
// @Value
// public class OpenId {
// 
//     private String value;
// 
//     private OpenId(String value) {
//         this.value = value;
//     }
// 
//     public static OpenId valueOf(String value) {
//         return new OpenId(value);
//     }
// }


// Path: examples/oauth2/src/main/java/com/github/hippoom/wechat/mp/examples/oauth2/http/assembler/WeChatUserProfileResourceAssembler.java
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import com.github.hippoom.wechat.mp.examples.oauth2.http.WeChatUserRestController;
import com.github.hippoom.wechat.mp.examples.oauth2.http.resource.WeChatUserProfileResource;
import com.github.hippoom.wechat.oauth.OpenId;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
import org.springframework.stereotype.Component;

package com.github.hippoom.wechat.mp.examples.oauth2.http.assembler;



@Component
public class WeChatUserProfileResourceAssembler extends
    ResourceAssemblerSupport<WxMpUser, WeChatUserProfileResource> {


    public WeChatUserProfileResourceAssembler() {
        super(WeChatUserRestController.class, WeChatUserProfileResource.class);
    }

    @Override
    public WeChatUserProfileResource toResource(WxMpUser entity) {
        WeChatUserProfileResource resource = new WeChatUserProfileResource();
        resource.setAvatar(entity.getHeadImgUrl());
        resource.setNickname(entity.getNickname());
        resource
            .add(
                linkTo(methodOn(WeChatUserRestController.class)