package com.bjtdba.userCenter.controller;

import com.bjtdba.userCenter.service.UserLogoutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("api/userCenterService")
public class UserLogoutAPIController {

    @Autowired
    private UserLogoutService userLogoutService;

    /**
     * 注销
     * @param phone
     * @return
     */
    @PostMapping("/userLogout")
    public Object userLogout(String phone){
        Map<String, Object> obj = new HashMap<String, Object>();
        Map<String, Object> resobj = new HashMap<String, Object>();
        obj= (Map<String, Object>) userLogoutService.userLogout(phone);
//        System.out.println(obj.get("status"));
        if(obj.get("status").toString().trim().equals("200")){
            resobj.put("errno",200);
            resobj.put("errmsg",  obj.get("message"));
//            System.out.println(obj.get("message"));
        }
        if(obj.get("status").toString().trim().equals("-1")){
            resobj.put("errno",-1);
            resobj.put("errmsg",  obj.get("message"));
//            System.out.println(obj.get("message"));
        }

        return resobj;
    }
}
