use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.
the class EmailServerService method addEamilServer.
// 添加邮箱配置
public int addEamilServer(EmailServer emailServer) throws Exception {
if (emailServer == null)
throw new ServiceNullException("要添加的邮件配置为空");
emailServer.setCreateTime(new Date());
// 对密码进行加密
if (StringUtils.isNotBlank(emailServer.getAccountPasswd()))
emailServer.setAccountPasswd(AESencrp.encrypt(emailServer.getAccountPasswd(), dbEncKey));
// 添加时更新时间等于添加时间
emailServer.setLastModify(emailServer.getCreateTime());
sqlSession.insert("com.itrus.portal.db.EmailServerMapper.insert", emailServer);
return 0;
}
use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.
the class SysRegionService method getRegionsByCode.
/**
* 根据行政区代码,获取行政区子级信息
* @param code
* @param type
* @return
* @throws ServiceNullException
*/
public List<Region4t> getRegionsByCode(String code, Integer type) throws ServiceNullException {
List<Region4t> region4tList = new ArrayList<Region4t>();
SysRegion sysRegion = getRegionByCode(code);
// 指定代码不存在
if (sysRegion == null) {
throw new ServiceNullException("未知的行政区代码【" + code + "】");
}
// 查询指定代码的下层节点
SysRegionExample sysRegionExample = new SysRegionExample();
SysRegionExample.Criteria srCriteria = sysRegionExample.createCriteria();
srCriteria.andParentIdEqualTo(sysRegion.getId());
srCriteria.andTypeEqualTo(sysRegion.getType() + 1);
sysRegionExample.setOrderByClause("code asc");
Map<Long, SysRegion> childSR = sqlSession.selectMap("com.itrus.portal.db.SysRegionMapper.selectByExample", sysRegionExample, "id");
// 判断下级节点是否有子节点
sysRegionExample.clear();
sysRegionExample.setOrderByClause(null);
srCriteria = sysRegionExample.createCriteria();
srCriteria.andParentIdIn(new ArrayList<Long>(childSR.keySet()));
Map<Long, Object> childNumMap = new HashMap<Long, Object>();
if (!childSR.isEmpty())
childNumMap = sqlSession.selectMap("com.itrus.portal.db.SysRegionMapper.selectChildNumByExample", sysRegionExample, "parentId");
Iterator iter = childSR.entrySet().iterator();
while (iter.hasNext()) {
SysRegion sr = (SysRegion) ((Map.Entry) iter.next()).getValue();
region4tList.add(new Region4t(sr.getNameCn(), sr.getCode(), sr.getType(), childNumMap.containsKey(sr.getId()) ? 1 : 0));
}
return region4tList;
}
use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.
the class RealNameAuthenticationSerivceImpl method updateRealName.
// 修改信息
public void updateRealName(RealNameAuthentication realname) throws ServiceNullException, Exception {
if (realname == null || realname.getId() == null)
throw new ServiceNullException("配置为空");
RealNameAuthentication realname1 = getRealNameById(realname.getId());
if (realname1 == null)
throw new ServiceNullException("配置不存在");
sqlSession.update("com.itrus.portal.db.RealNameAuthenticationMapper.updateByPrimaryKeySelective", realname);
}
use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.
the class FilePathUtils method savepdf.
/**
* 保存pdf
* @param dir
* @param bfile
* @param bfile
* @param fileType
* @param itemType
* @return
* @throws IOException
* @throws UserInfoServiceException
* @throws ServiceNullException
*/
public File savepdf(File dir, byte[] bfile, String fileType, String itemType) throws IOException, UserInfoServiceException, ServiceNullException {
BufferedOutputStream bos = null;
FileOutputStream fos = null;
String filename = itemType + fileType;
// 创建磁盘文件
File file = null;
try {
// dir = new File(fileURI.substring(0,fileURI.lastIndexOf("/")+1).replace("/", "\\"));
if (!dir.exists() && dir.isDirectory()) {
// 判断文件目录是否存在
dir.mkdirs();
}
file = new File(dir, filename);
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
bos.write(bfile);
if (file.length() > IMG_MAX_SIZE) {
throw new UserInfoServiceException("PDF文件大小不能超过" + (IMG_MAX_SIZE / 1024) + "K");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bos != null) {
try {
bos.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
return file;
}
use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.
the class ImageByBase64 method saveImage.
/**
* 将图片写入磁盘
*
* @param fileBase64
* 图片的base64字符串
* @param saveFile
* 将写入的磁盘文件
* @throws ServiceNullException
*/
public void saveImage(String fileBase64, File saveFile) throws IOException, UserInfoServiceException, ServiceNullException {
if (fileBase64.indexOf("/reviewWeb/img/") != -1) {
String editbillImg = fileBase64.substring(fileBase64.indexOf("/reviewWeb/img/") + 15, fileBase64.length());
String[] ss = editbillImg.split("/");
Long type = Long.parseLong(ss[0]);
Long id = Long.parseLong(ss[1]);
Long num = Long.parseLong(ss[2]);
File tempFile = getImg(type, id, num);
if (null == tempFile) {
logger.error("fileBase64:" + fileBase64);
}
CopyFile.copyFile(tempFile, saveFile);
return;
}
// 检查传递的base64信息是否为图片地址:/img/{type}/{random}?t=uploadTime
if (fileBase64.length() < 100 && fileBase64.indexOf("/img/") != -1) {
try {
String[] baseInfos = fileBase64.split("/");
String[] uploadStr = baseInfos[3].split("=");
String random = uploadStr[0].substring(0, uploadStr[0].indexOf("?"));
String upload = uploadStr[1];
// upload = upload.substring(upload.indexOf("=") + 1);
// 上传时间
Date uploadTime = new Date(Long.parseLong(upload));
TempPic tempPic = tempPicService.getTempPicByRandomAndTime(random, uploadTime);
if (null == tempPic) {
logger.error("fileBase64:" + fileBase64);
throw new ServiceNullException("未找到上传的临时图片记录");
}
String type = baseInfos[2];
String fileName = null;
// } else
if ("1".equals(type)) {
// 证件图片A
fileName = tempPic.getImgFileA();
} else if ("2".equals(type)) {
// 证件图片B
fileName = tempPic.getImgFileB();
}
if (null == fileName) {
logger.error("fileBase64:" + fileBase64);
throw new ServiceNullException("未找到上传的临时图片名称");
}
File tempFile = new File(tempPicService.getDir(random), fileName);
// 将临时文件写入到需要保存的地方
CopyFile.copyFile(tempFile, saveFile);
} catch (Exception e) {
e.printStackTrace();
logger.error("fileBase64:" + fileBase64);
throw new ServiceNullException("未找到上传的临时图片记录信息");
}
} else if (fileBase64.indexOf("/editbillImg/") != -1) {
String editbillImg = fileBase64.substring(fileBase64.indexOf("/editbillImg/") + 13, fileBase64.length());
String[] ss = editbillImg.split("/");
String userSn = ss[2];
Integer type = Integer.parseInt(ss[0]);
Long editBillId = Long.parseLong(ss[1]);
EditBill editBill = null;
String fileName = "";
if (null == type || StringUtils.isBlank(userSn) || null == editBillId) {
logger.error("fileBase64:" + fileBase64);
throw new ServiceNullException("填写中的订单的图片url不正确");
}
editBill = sqlsession.selectOne("com.itrus.portal.db.EditBillMapper.selectByPrimaryKey", editBillId);
if (null == editBill) {
logger.error("fileBase64:" + fileBase64);
throw new ServiceNullException("找不到填写中的订单信息");
}
/*
* 0 营业执照图片, 1 组织机构代码图片, 2 税务登记图片, 3 法人正面图片
* 4 法人反面图片, 5 授权书图片, 6 代理人正面图片, 7 代理人反面图片
* */
if (type.equals(0)) {
fileName = editBill.getBlImgFile();
} else if (type.equals(1)) {
fileName = editBill.getOcImgFile();
} else if (type.equals(2)) {
fileName = editBill.getTrImgFile();
} else if (type.equals(3)) {
fileName = editBill.getIcfImgFile();
} else if (type.equals(4)) {
fileName = editBill.getIcbImgFile();
} else if (type.equals(5)) {
fileName = editBill.getPrImgFile();
} else if (type.equals(6)) {
fileName = editBill.getAtfImgFile();
} else if (type.equals(7)) {
fileName = editBill.getAtbImgFile();
}
File tempFile;
try {
tempFile = new File(filePathUtils.getDir(null, userSn), fileName);
// 将临时文件写入到需要保存的地方
CopyFile.copyFile(tempFile, saveFile);
} catch (Exception e) {
logger.error("fileBase64:" + fileBase64);
e.printStackTrace();
throw new ServiceNullException("填写中的订单的图片url不正确");
}
} else {
// Base64解码
byte[] b = Base64.decode(fileBase64);
OutputStream out = new FileOutputStream(saveFile);
out.write(b);
out.flush();
out.close();
}
}
Aggregations