package com.xmomen.module.wx.controller;

import com.xmomen.module.base.entity.CdMember;
import com.xmomen.module.base.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author tanxinzheng
 * @version 1.0.0
 * @date 2017-3-29 0:27:52
 */
@RestController
@RequestMapping(value = "/wx/member")
public class WxMemberController {

    // 自动注入WxMemberService
    @Autowired
    // 成员服务
    MemberService memberSercvice;


    /**
     * 更新客户手机号
     *
     * @param memberId member主键
     * @param mobile   新手机号码
     */
    // 根据id更新会员地址
    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
    public void updateMemberAddress(@PathVariable("id") Integer memberId,
                                    @RequestParam("mobile") String mobile) {
        // 调用memberSercvice的updateMobile方法，更新会员的mobile
        memberSercvice.updateMobile(memberId, mobile);
    }

    /**
     * 查询单个客户
     *
     * @param id 主键
     * @return CdMember   客户领域对象
    // 根据id获取会员信息
     */
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
        // 调用memberSercvice的getOneMemberModel方法，根据id获取会员信息
    public CdMember getMemberById(@PathVariable(value = "id") String id) {
        return memberSercvice.getOneMemberModel(id);
    }

}
