package com.yc.wms.controller;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.yc.wms.service.Kucunrizhi;
import com.yc.wms.until.QueryPageUtil;
import com.yc.wms.until.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/Kucunrizhi")
public class KucunrizhiController {

    @Autowired
    private Kucunrizhi kucunrizhi;

    @PostMapping("/queryRi")
    public Result queryUser(@RequestBody String  json) {
        QueryPageUtil query =new QueryPageUtil();
        JSONObject jsonObject= JSONUtil.parseObj(json);
        query.setPageSize((int)jsonObject.get("pageSize"));
        query.setPageNum((int)jsonObject.get("pageNum"));

        JSONObject param= (JSONObject)jsonObject.get("param");

        com.yc.wms.bean.Kucunrizhi k = JSONUtil.toBean(param.toString(), com.yc.wms.bean.Kucunrizhi.class);

        return kucunrizhi.QueryJson(query,k);
    }

    @PostMapping("/log")
    public Result Log() {

        return kucunrizhi.Log();
    }
}
