package com.bofeng.wx.controller;

import com.baomidou.mybatisplus.toolkit.IdWorker;
import com.bofeng.Consts;
import com.bofeng.JwtHelper;
import com.bofeng.dao.UserOpenMapper;
import com.bofeng.entity.*;
import com.bofeng.service.*;
import com.google.common.collect.Maps;
import com.yvan.Model;
import com.yvan.ModelOps;
import com.yvan.mvc.JsonBody;
import com.yvan.mvc.Pd;
import com.yvan.platform.JsonWapper;
import com.yvan.platform.YvanUtil;
import lombok.val;
import lombok.var;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.PreDestroy;
import java.util.List;
import java.util.Map;

@RestController
public class HomeController {

  @Autowired
  private HomeService homeService;

  @Autowired
  private QzTaskService qzTaskService;

  @Autowired
  private QzTaskReplyService qzTaskReplyService;

  @GetMapping("/home/home.html")
  public ModelAndView home(ModelMap model) {
    //UserOpen userOpen = homeService.getUserOpen();
    model.put("user", new JsonWapper("{\"www\": \"er\"}"));
    return new ModelAndView("/home/home.ftl", model);
  }

  //家庭求助
  @GetMapping("/home/home/addFimaly")
  public ModelOps family(@Pd(name="taskTitle")String taskTitle,
                         @Pd(name = "taskTarget")String taskTarget,
                         @Pd(name = "remark")String remark) {
    return ModelOps.newSuccess(qzTaskService.addHelp(taskTitle,taskTarget,remark));
  }

  //我的在求助的展示
  @GetMapping("/home/home/queryQzTask")
  public Model<List<QzTask>> queryQzTask(){
    return Model.newSuccess(qzTaskService.queryQzTask());
  }

  //小区求助的查看
  @GetMapping("/home/home/taskQuery")
  public Model<List<QzTaskReply>> taskQuery(){
    return Model.newSuccess(qzTaskReplyService.taskQuery());
  }
}
