|
@@ -4,7 +4,13 @@ import com.caimei.modules.shiro.dao.UserDao;
|
|
|
import com.caimei.modules.shiro.entity.CmMallAdminUser;
|
|
|
import com.caimei.modules.shiro.entity.CmMallOrganize;
|
|
|
import com.caimei.modules.shiro.service.ShiroService;
|
|
|
+import com.caimei.utils.Encodes;
|
|
|
import com.caimei.utils.TokenEncryptUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.jsoup.Jsoup;
|
|
|
+import org.jsoup.nodes.Document;
|
|
|
+import org.jsoup.nodes.Element;
|
|
|
+import org.jsoup.select.Elements;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -28,7 +34,7 @@ public class ShiroServiceImpl implements ShiroService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String createToken(CmMallAdminUser user) throws Exception {
|
|
|
+ public String createToken(CmMallAdminUser user) {
|
|
|
// 获取当前时间戳(10位整数)
|
|
|
int time = (int) (System.currentTimeMillis() / 1000 + 3600 * 12);
|
|
|
String token = TokenEncryptUtils.encoded(time + "#,#" + user.getId() + "#,#" + user.getPassword());
|
|
@@ -52,7 +58,42 @@ public class ShiroServiceImpl implements ShiroService {
|
|
|
|
|
|
@Override
|
|
|
public void updateOrganizeInfo(CmMallOrganize mallOrganize) {
|
|
|
+ if (mallOrganize.getIntroduction() != null) {
|
|
|
+ mallOrganize.setIntroduction(alter(mallOrganize.getIntroduction()));
|
|
|
+ }
|
|
|
+ if (mallOrganize.getAfterSale() != null) {
|
|
|
+ mallOrganize.setAfterSale(alter(mallOrganize.getAfterSale()));
|
|
|
+ }
|
|
|
+ if (mallOrganize.getShoppingNotes() != null) {
|
|
|
+ mallOrganize.setShoppingNotes(alter(mallOrganize.getShoppingNotes()));
|
|
|
+ }
|
|
|
mallOrganize.setUpdateTime(new Date().toString());
|
|
|
userDao.updateOrganizeInfo(mallOrganize);
|
|
|
}
|
|
|
+
|
|
|
+ public String alter(String introduction) {
|
|
|
+ introduction = StringUtils.replace(introduction, "<body", "<div");
|
|
|
+ introduction = StringUtils.replace(introduction, "</body>", "</div>");
|
|
|
+ Document doc = Jsoup.parse(introduction);
|
|
|
+ Elements links = doc.getElementsByTag("img");
|
|
|
+ for (Element link : links) {
|
|
|
+ String linkSrc = link.attr("src");
|
|
|
+ String linkSrcOld = link.attr("src");
|
|
|
+ if (StringUtils.isNotBlank(linkSrc) && !linkSrc.contains("http:") && !linkSrc.contains("https:") && !linkSrc.contains("uploadFile/ueditor")) {//不包含http开头的
|
|
|
+ linkSrc = Encodes.urlDecode(linkSrc);
|
|
|
+ /*String realPath = UploadImageUtils.getAbsolutePath(linkSrc);
|
|
|
+ int pointerIndex = realPath.lastIndexOf(".");
|
|
|
+ ImageUploadInfo saveImageSerivce = new ImageUploadInfo();
|
|
|
+ try {
|
|
|
+ saveImageSerivce = ImagePathUtils.saveImageSerivce(realPath, pointerIndex, realPath);
|
|
|
+ String src = photoServer + saveImageSerivce.getSource();
|
|
|
+ introduction = StringUtils.replace(introduction, linkSrcOld, src);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ //logger.error("图片上传错误:" + e.toString(), e);
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return introduction;
|
|
|
+ }
|
|
|
}
|