package com.bofeng.wx.controller;

import com.bofeng.entity.ShShopMat;
import com.bofeng.service.ShShopMatService;
import com.bofeng.service.ShShopService;
import com.yvan.Model;
import com.yvan.ModelOps;
import com.yvan.mvc.Pd;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ShopMatController {

//    @Autowired
//    private HomeService homeService;
//
//    @Autowired
//    private QzTaskService qzTaskService;
//
//    @Autowired
//    private QzTaskReplyService qzTaskReplyService;

    @Autowired
    private ShShopService shShopService;
    @Autowired
    private ShShopMatService shShopMatService;


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


    //商品的新增
    @PostMapping("/shop/mat/addShShopMat")
    public ModelOps addShShopMat(@Pd(name = "userId") Long userId, @Pd(name = "matName") String matName, @Pd(name = "matNum") Integer matNum) throws Exception {
        return ModelOps.newSuccess(shShopMatService.addShShopMat(userId, matName, matNum));
    }

    //商品的置顶2、下架0修改
    @PostMapping("/shop/mat/editShShopMatStatus")
    public ModelOps editShShopMatStatus(@Pd(name = "matId") Long matId, @Pd(name = "status") Integer status) throws Exception {
        return ModelOps.newSuccess(shShopMatService.editShShopMatStatus(matId, status));
    }

    //    //我的商品
    @GetMapping("/shop/mat/queryMyShShopMat")
    public Model<List<ShShopMat>> queryMyShShopMat(@Pd(name = "userId"/*, required = false*/) Long userId) throws Exception {
        return Model.newSuccess(shShopMatService.queryMyShShopMat(userId));
    }


//    //家庭求助
//    @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(@Pd(name = "taskStatus", required = false) Integer taskStatus) {
//        return Model.newSuccess(qzTaskService.queryQzTask(taskStatus));
//    }
//
//    //小区求助的查看
//    @GetMapping("/home/home/taskQuery")
//    public Model<List<QzTaskReply>> taskQuery(@Pd(name = "taskId") Long taskId) {
//        return Model.newSuccess(qzTaskReplyService.taskQuery(taskId));
//    }
//
//    @GetMapping("/home/home_new.html")
//    public ModelAndView hmoe_new(ModelMap model) {
//        model.put("user", new JsonWapper("{\"www\": \"er\"}"));
//        return new ModelAndView("/home/home_new.ftl", model);
//    }
}
