package org.jeecg.modules.fileupload.controller;

import cn.com.ctop.common.module.utils.Check;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.fileupload.service.IMaterialUsrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("materialUse")
@RestController
public class MaterialUsrController {
    @Autowired
    private IMaterialUsrService materialUsrService;

    @GetMapping("/getMaterialUseDetail")
    public Result<JSONObject> getMaterialUseDetail(String code) {
        Result<JSONObject> result = new Result<>();
        try {
            if (Check.isNull(code)) {
                throw new Exception("素材md5不能为空");
            }
            JSONObject json = materialUsrService.getMaterialUseInfo(code);
            result.setSuccess(true);
            result.setResult(json);
        } catch (Exception e) {
            result.setSuccess(false);
            result.setMessage(e.getMessage());
        }
        return result;

    }


}
