package cn.com.tenlion.buildingpictures.controller.app.picturestemplatearea;

import cn.com.tenlion.buildingpictures.service.picturestemplatearea.IPicturesTemplateAreaService;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.exceptions.SaveException;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResultData;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @ClassName: PictruesTemplateAppController
 * @Description: 
 * @Author: CodeFactory
 * @Date: 2021-06-23 15:25:56
 * @Version: 3.0
 **/
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "接口")
@RestController
@RequestMapping(ISystemConstant.APP_PREFIX + "/pictruestemplatearea")
public class PictruesTemplateAreaAppController extends DefaultBaseController {

    @Autowired
    private IPicturesTemplateAreaService iPicturesTemplateAreaService;

    @ApiOperation(value = "文字转为条形码||二维码||地图||小程序二维码图片", notes = "文字转为条形码||二维码||地图||小程序二维码图片")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "token", value = "token", paramType = "header"),
        @ApiImplicitParam(name = "picturesTemplateAreaId", value = "ID", paramType = "path")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("createfile/{picturesTemplateAreaId}")
    public SuccessResultData<String> CreateFile(@RequestHeader("token") String token, @PathVariable("picturesTemplateAreaId") String picturesTemplateAreaId) {
        Map<String, Object> params = requestParams();
        if(params.get("content") == null) {
            throw new SaveException("内容不能为空");
        }
        return iPicturesTemplateAreaService.saveCreateFile(picturesTemplateAreaId, params.get("content").toString());
    }

}