package com.winsun.controller;

import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.winsun.bean.AttributeList;
import com.winsun.bean.Order;
import com.winsun.constant.Constant;
import com.winsun.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

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

@RestController
public class TestController {

    @Autowired
    private OrderMapper orderMapper;

    @RequestMapping(value = "testPost", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public String testPost(@RequestBody JSONObject requestBean) {
        Order order = new Order();
        order.setOrderId((String) requestBean.get("orderId"));
        order = orderMapper.selectOne(order);
        Map<Object, Object> imgUrlMap = new HashMap<>();
        imgUrlMap.put("身份证正面", order.getIdCardz() != null ? Constant.SYSTEMURL + order.getIdCardz().replace("manager", "app") : "");
        imgUrlMap.put("身份证反面", order.getIdCardf() != null ? Constant.SYSTEMURL + order.getIdCardf().replace("manager", "app") : "");
        imgUrlMap.put("手持身份证", order.getIdCardzs() != null ? Constant.SYSTEMURL + order.getIdCardzs().replace("manager", "app") : "null");
        imgUrlMap.put("学生证", order.getStudenCard() != null ? Constant.SYSTEMURL + order.getStudenCard().replace("manager", "app") : "");
        String imgUrlJSON = JSONUtils.toJSONString(imgUrlMap);
        return imgUrlJSON;
    }
}