package com.cxyxiaomo.epp.miniprogram.visitor.controller;

import com.cxyxiaomo.epp.common.response.Res;
import com.cxyxiaomo.epp.miniprogram.visitor.service.VisitorService;
import com.cxyxiaomo.epp.common.pojo.Visitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("visitor")
public class VisitorController {

    @Autowired
    private VisitorService visitorService;

    @ResponseBody
    @RequestMapping("/visitorApply")
    public String visitorApply(Visitor visitor) {
//        visitor.setCreate_time(new Date().toString());
        return visitorService.visitorApply(visitor);
    }

    @ResponseBody
    @RequestMapping("/visitorChangeState")
    public String visitorChangeState(Integer id, Integer state) {
        return visitorService.visitorChangeState(id, state);
    }

    @ResponseBody
    @RequestMapping("/showMyVisitor")
    public String showMyVisitor(String phone) {
        return visitorService.showMyVisitor(phone);
    }

    @ResponseBody
    @RequestMapping("/showVisitorList")
    public Res showVisitorList() {
        return Res.success(visitorService.showVisitorList());
    }
}
