合同管理系统 - 合同操作 API 接口
/**
* 解除合同经济补偿金
* @param contractId
* @param user
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/cancelCompensate")
public String cancelCompensate(String contractId,User user) throws Exception{
String msg ="";
//1.更新合同信息
Contract contract = new Contract();
contract.setId(contractId);
contract.setUpdateBy(user.getId());
contract.setUpdateName(user.getName());
contract.setCancelCompensate(1);//已解除
contractService.update(contract);
msg ='解除经济补偿金成功';
return msg;
}
/**
* 根据责任部门ID查询责任人
* @param deptId
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/getDeptUser")
public List<User> getDeptUser(String deptId) throws Exception{
List<User> list = userService.getUserByDeptId(deptId);
return list;
}
/**
* 添加合同责任人
* @param contractId
* @param user
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/addContractDuty")
public String addContractDuty(String contractId,String dutyUserIds,User user) throws Exception{
String msg ="";
//1.更新合同信息
Contract contract = new Contract();
contract.setId(contractId);
contract.setUpdateBy(user.getId());
contract.setUpdateName(user.getName());
contract.setDutyUserIds(dutyUserIds);
contractService.update(contract);
msg ='添加合同责任人成功';
return msg;
}
/**
* 合同详情
* @param contractId
* @return
* @throws Exception
*/
@RequestMapping("/view")
public ModelAndView view(String contractId) throws Exception{
ModelAndView mv = new ModelAndView();
mv.addObject("head", "合同详情");
Contract contract = contractService.load(contractId);
mv.addObject("contract", contract);
//查询合同执行情况
ContractExecute contractExecute = new ContractExecute();
contractExecute.setContractId(contractId);
List<ContractExecute> list = contractExecuteService.list(contractExecute);
mv.addObject("list", list);
mv.setViewName("contract/contract/view_contract");
return mv;
}
/**
* 下载合同文件
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("/downFile")
public ResponseEntity<byte[]> downFile(HttpServletRequest request,HttpServletResponse response,String fileId) throws Exception{
//查询文件信息
FileInfo fileInfo = fileInfoService.load(fileId);
//查询文件
String fileName = fileInfo.getName() + "." + fileInfo.getSuffixName();//下载文件名
String filePath = request.getSession().getServletContext().getRealPath("upload") +"/" + fileInfo.getPath();//文件所在路径
byte[] body = null;
InputStream is = null;
ResponseEntity<byte[]> entity = null;
File file = new File(filePath);
is = new FileInputStream(file);
body = new byte[is.available()];
is.read(body);
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Disposition", "attchement;filename=" + new String(fileName.getBytes("utf-8"),"iso8859-1"));
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
entity = new ResponseEntity<byte[]>(body, headers, HttpStatus.OK);
return entity;
}
原文地址: https://www.cveoy.top/t/topic/lfD4 著作权归作者所有。请勿转载和采集!