package com.yingpaipay.business.controller.applet;

import com.yingpaipay.business.domain.bo.AppletMyInfoEditAvatarBo;
import com.yingpaipay.business.domain.bo.AppletMyInfoEditGenderBo;
import com.yingpaipay.business.domain.bo.AppletMyInfoEditNicknameBo;
import com.yingpaipay.business.domain.bo.AppletMyInfoEditPasswordBo;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
import org.dromara.system.service.ISysUserService;
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;

@RestController
@RequestMapping("/applet/my/info")
@RequiredArgsConstructor
public class AppletMyInfoController extends BaseController {

    private final ISysUserService userService;

    @PutMapping("/edit/nickname")
    public R<Void> editNickname(@RequestBody AppletMyInfoEditNicknameBo bo) {
        return toAjax(userService.updateNickname(bo.getNickname()));
    }

    @PutMapping("/edit/gender")
    public R<Void> editGender(@RequestBody AppletMyInfoEditGenderBo bo) {
        return toAjax(userService.updateGender(bo.getGender()));
    }

    @PutMapping("/edit/avatar")
    public R<Void> editAvatar(@RequestBody AppletMyInfoEditAvatarBo bo) {
        return toAjax(userService.updateAvatar(bo.getAvatar()));
    }

    @PutMapping("/edit/password")
    public R<Void> editPassword(@RequestBody AppletMyInfoEditPasswordBo bo) {
        return toAjax(userService.updatePassword(bo.getOldPassword(), bo.getNewPassword()));
    }

}
