package cn.ysk.cashier.controller;

import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

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

/**
 * 收银系统图片模板库
 * @author lyf
 */
@RestController
@RequestMapping("/channel")
public class PHPController {
    /**
     * 获取图片分类
     * @return
     */
    @GetMapping("/file/getcommon-category")
    public JSONObject getcommonCategory(){
        String baseUrl = "https://kysh.sxczgkj.cn/channel/file/getcommon-category";
        RestTemplate restTemplate = new RestTemplate();
        String forObject = restTemplate.getForObject(baseUrl, String.class);
        return JSONObject.parseObject(forObject);
    }

    @GetMapping("/file/getcommon-picture")
    public JSONObject getcommonPicture(@RequestParam String category, @RequestParam String page, @RequestParam String size){
        String baseUrl = "https://kysh.sxczgkj.cn/channel/file/getcommon-picture?";
        RestTemplate restTemplate = new RestTemplate();
        Map<String, Object> map = new HashMap<>();
        map.put("category", category);
        map.put("page", page);
        map.put("size", size);
        String forObject = restTemplate.postForObject(baseUrl,map, String.class);
        return JSONObject.parseObject(forObject);
    }
}
