package ink.wgink.module.wechat.controller.app.miniapp;

import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.wechat.pojo.vos.miniapp.MiniAppUpdateInfoVO;
import ink.wgink.module.wechat.service.miniapp.IMiniappUserService;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: UserMiniAppController
 * @Description: 小程序用户
 * @Author: wanggeng
 * @Date: 2021/8/2 4:47 下午
 * @Version: 1.0
 */
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "小程序用户")
@RestController
@RequestMapping(ISystemConstant.APP_PREFIX + "/miniapp/user")
public class MiniappUserAppController {

    @Autowired
    private IMiniappUserService miniAppUserService;

    @ApiOperation(value = "更新信息", notes = "由用户主动授权更新微信头像、昵称")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", paramType = "header")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @PutMapping("update-info")
    @CheckRequestBodyAnnotation
    public SuccessResult updateInfo(@RequestHeader("token") String token,
                                    @RequestBody MiniAppUpdateInfoVO miniAppUpdateInfoVO) throws Exception {
        miniAppUserService.updateInfo(token, miniAppUpdateInfoVO);
        return new SuccessResult();
    }

}
