package com.vci.web.controller;
|
|
import com.vci.corba.common.PLException;
|
import com.vci.starter.web.exception.VciBaseException;
|
import com.vci.starter.web.pagemodel.BaseQueryObject;
|
import com.vci.starter.web.pagemodel.BaseResult;
|
import com.vci.starter.web.pagemodel.DataGrid;
|
import com.vci.starter.web.util.ControllerUtil;
|
import com.vci.starter.web.util.LangBaseUtil;
|
import com.vci.dto.OsCodeGenSchemaDTO;
|
import com.vci.pagemodel.OsCodeGenSchemaVO;
|
import com.vci.starter.web.util.VciBaseUtil;
|
import com.vci.web.service.OsCodeGenSchemaServiceI;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.IOException;
|
|
/**
|
* 代码生成器
|
* @author weidy
|
* @date 2020/7/30 15:56
|
*/
|
@RestController
|
@RequestMapping("/codeGenSchemaController")
|
public class WebCodeGenSchemaController {
|
|
/**
|
* 代码生成服务
|
*/
|
@Autowired
|
private OsCodeGenSchemaServiceI codeGenSchemaService;
|
|
/**
|
* 代码生成方案列表
|
* @param baseQueryObject 基本查询对象,包含分页和排序
|
* @return 方案列表
|
*/
|
@GetMapping(value = "/gridSchema")
|
public DataGrid<OsCodeGenSchemaVO> gridSchema(BaseQueryObject baseQueryObject){
|
if(baseQueryObject == null){
|
baseQueryObject = new BaseQueryObject();
|
}
|
return codeGenSchemaService.gridSchema(baseQueryObject.getConditionMap(),baseQueryObject.getPageHelper());
|
}
|
|
/**
|
* 添加方案
|
* @param codeGenSchemaDTO 方案传输对象
|
* @return 执行结果,success为true表示成功
|
*/
|
@PostMapping(value = "/addSchema")
|
public BaseResult<OsCodeGenSchemaVO> addSchema(OsCodeGenSchemaDTO codeGenSchemaDTO){
|
OsCodeGenSchemaVO schemaVO = codeGenSchemaService.addSchema(codeGenSchemaDTO);
|
return BaseResult.success(schemaVO);
|
}
|
|
/**
|
* 修改方案
|
* @param codeGenSchemaDTO 方案传输对象
|
* @return 执行结果,success为true表示成功
|
*/
|
@PutMapping(value = "/editSchema")
|
public BaseResult<OsCodeGenSchemaVO> editSchema(OsCodeGenSchemaDTO codeGenSchemaDTO){
|
OsCodeGenSchemaVO schemaVO = codeGenSchemaService.editSchema(codeGenSchemaDTO);
|
return BaseResult.success();
|
}
|
|
/**
|
* 生成代码文件
|
* @param oid 方案的主键
|
* @return 执行结果
|
*/
|
@PostMapping(value = "/productCodeFile")
|
public BaseResult productCodeFile(String oid){
|
try {
|
codeGenSchemaService.productCodeFile(oid);
|
return BaseResult.success();
|
} catch (PLException e) {
|
e.printStackTrace();
|
String exceptionMessage = VciBaseUtil.getExceptionMessage(e);
|
throw new VciBaseException(exceptionMessage);
|
}
|
}
|
|
/**
|
* 预览代码文件
|
* @param oid 方案的主键
|
* @return key是文件的类型,value是文件的名称
|
*/
|
@PostMapping(value = "/previewCodeFile")
|
public BaseResult previewCodeFile(String oid){
|
return BaseResult.success(codeGenSchemaService.previewCodeFile(oid));
|
}
|
|
/**
|
* 下载代码文件
|
* @param oid 方案的主键
|
* @param downloadUUID 下载许可码
|
* @param response 响应的对象
|
* @return 执行结果,只有下载失败的时候才会这样
|
*/
|
@GetMapping(value = "/downloadCodeFile")
|
public BaseResult downloadCodeFile(String oid, String downloadUUID, HttpServletResponse response){
|
String codeZipFile = codeGenSchemaService.downloadCodeFile(oid);
|
try {
|
ControllerUtil.writeFileToResponse(response,codeZipFile);
|
} catch (IOException e) {
|
return BaseResult.fail(LangBaseUtil.getErrorMsg(e));
|
}
|
return BaseResult.success();
|
}
|
|
/**
|
* 根据主键获取方案对象
|
* @param oid 主键
|
* @return obj属性是方案对象,需要先判断success
|
*/
|
@GetMapping(value = "/getObjectByOid")
|
public BaseResult getObjectByOid(String oid){
|
OsCodeGenSchemaVO codeGenSchemaVO = codeGenSchemaService.getObjectByOid(oid);
|
BaseResult baseResult = BaseResult.success();
|
baseResult.setObj(codeGenSchemaVO);
|
return baseResult;
|
}
|
}
|