mirror of
https://github.com/chatopera/cosin.git
synced 2025-07-16 00:22:22 +08:00
https://github.com/chatopera/cskefu/issues/466 enable multi text ads
This commit is contained in:
parent
a5b9e29aba
commit
f07e6ca849
@ -901,13 +901,14 @@ public class MainUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按照权重获取广告
|
* 获得所有广告
|
||||||
*
|
*
|
||||||
* @param adpos
|
* @param adpos
|
||||||
|
* @param skill
|
||||||
|
* @param orgi
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
public static List<AdType> getPointAdvs(String adpos, String skill, String orgi) {
|
||||||
public static AdType getPointAdv(String adpos, String skill, String orgi) {
|
|
||||||
List<AdType> adTypeList = new ArrayList<AdType>();
|
List<AdType> adTypeList = new ArrayList<AdType>();
|
||||||
List<AdType> cacheAdTypeList = MainContext.getCache().findOneSystemListByIdAndOrgi(
|
List<AdType> cacheAdTypeList = MainContext.getCache().findOneSystemListByIdAndOrgi(
|
||||||
Constants.CSKEFU_SYSTEM_ADV + "_" + skill, orgi);
|
Constants.CSKEFU_SYSTEM_ADV + "_" + skill, orgi);
|
||||||
@ -934,7 +935,19 @@ public class MainUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return weitht(adTypeList);
|
return adTypeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照权重获取广告
|
||||||
|
*
|
||||||
|
* @param adpos
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static AdType getPointAdv(String adpos, String skill, String orgi) {
|
||||||
|
List<AdType> ads = getPointAdvs(adpos, skill, orgi);
|
||||||
|
return weitht(ads);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Random random = new Random();
|
private static Random random = new Random();
|
||||||
@ -945,7 +958,7 @@ public class MainUtils {
|
|||||||
* @param adList
|
* @param adList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static AdType weitht(List<AdType> adList) {
|
public static AdType weitht(List<AdType> adList) {
|
||||||
AdType adType = null;
|
AdType adType = null;
|
||||||
int weight = 0;
|
int weight = 0;
|
||||||
if (adList != null && adList.size() > 0) {
|
if (adList != null && adList.size() > 0) {
|
||||||
@ -1003,7 +1016,7 @@ public class MainUtils {
|
|||||||
config.setCaching(false);
|
config.setCaching(false);
|
||||||
config.setMode(Pug4J.Mode.XML);
|
config.setMode(Pug4J.Mode.XML);
|
||||||
config.setPrettyPrint(true);
|
config.setPrettyPrint(true);
|
||||||
String retValue = config.renderTemplate(template,values);
|
String retValue = config.renderTemplate(template, values);
|
||||||
|
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ import com.chatopera.cc.persistence.repository.*;
|
|||||||
import com.chatopera.cc.proxy.OnlineUserProxy;
|
import com.chatopera.cc.proxy.OnlineUserProxy;
|
||||||
import com.chatopera.cc.socketio.util.RichMediaUtils;
|
import com.chatopera.cc.socketio.util.RichMediaUtils;
|
||||||
import com.chatopera.cc.util.*;
|
import com.chatopera.cc.util.*;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -67,10 +66,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/im")
|
@RequestMapping("/im")
|
||||||
@ -333,9 +329,31 @@ public class IMController extends Handler {
|
|||||||
// 用户的浏览历史会有很大的数据量,目前强制开启
|
// 用户的浏览历史会有很大的数据量,目前强制开启
|
||||||
userHistoryRes.save(userHistory);
|
userHistoryRes.save(userHistory);
|
||||||
|
|
||||||
view.addObject(
|
/**
|
||||||
"pointAd",
|
* 广告信息
|
||||||
MainUtils.getPointAdv(MainContext.AdPosEnum.POINT.toString(), invite.getConsult_skill_fixed_id(), Constants.SYSTEM_ORGI));
|
*/
|
||||||
|
List<AdType> ads = MainUtils.getPointAdvs(MainContext.AdPosEnum.POINT.toString(), invite.getConsult_skill_fixed_id(), Constants.SYSTEM_ORGI);
|
||||||
|
|
||||||
|
if (ads.size() > 0) {
|
||||||
|
view.addObject(
|
||||||
|
"pointAds",
|
||||||
|
ads
|
||||||
|
);
|
||||||
|
view.addObject(
|
||||||
|
"pointAd",
|
||||||
|
MainUtils.weitht(ads)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
view.addObject(
|
||||||
|
"pointAds",
|
||||||
|
null
|
||||||
|
);
|
||||||
|
view.addObject(
|
||||||
|
"pointAd",
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
view.addObject(
|
view.addObject(
|
||||||
"inviteAd",
|
"inviteAd",
|
||||||
MainUtils.getPointAdv(MainContext.AdPosEnum.INVITE.toString(), invite.getConsult_skill_fixed_id(), Constants.SYSTEM_ORGI));
|
MainUtils.getPointAdv(MainContext.AdPosEnum.INVITE.toString(), invite.getConsult_skill_fixed_id(), Constants.SYSTEM_ORGI));
|
||||||
@ -947,7 +965,7 @@ public class IMController extends Handler {
|
|||||||
view.addObject("commentList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_COMMENT_DIC));
|
view.addObject("commentList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_COMMENT_DIC));
|
||||||
view.addObject("commentItemList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_COMMENT_ITEM_DIC));
|
view.addObject("commentItemList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_COMMENT_ITEM_DIC));
|
||||||
view.addObject("welcomeAd", MainUtils.getPointAdv(MainContext.AdPosEnum.WELCOME.toString(), skill, orgi));
|
view.addObject("welcomeAd", MainUtils.getPointAdv(MainContext.AdPosEnum.WELCOME.toString(), skill, orgi));
|
||||||
view.addObject("imageAd", MainUtils.getPointAdv(MainContext.AdPosEnum.IMAGE.toString(), skill, orgi));
|
view.addObject("figureAds", MainUtils.getPointAdvs(MainContext.AdPosEnum.IMAGE.toString(), skill, orgi));
|
||||||
|
|
||||||
// 确定"接受邀请"被处理后,通知浏览器关闭弹出窗口
|
// 确定"接受邀请"被处理后,通知浏览器关闭弹出窗口
|
||||||
OnlineUserProxy.sendWebIMClients(userid, "accept");
|
OnlineUserProxy.sendWebIMClients(userid, "accept");
|
||||||
|
@ -389,13 +389,21 @@ html
|
|||||||
p(style="text-indent:25px;line-height:25px;")= inviteData.dialog_introduction
|
p(style="text-indent:25px;line-height:25px;")= inviteData.dialog_introduction
|
||||||
|
|
||||||
.content-pic(style='width:100%;height:192px;')
|
.content-pic(style='width:100%;height:192px;')
|
||||||
if imageAd
|
if figureAds
|
||||||
if imageAd.adtype == "image"
|
- var figureAdsNum = 0
|
||||||
a(href=imageAd.url, title=imageAd.tiptext, target="_blank")
|
for figureAd in figureAds
|
||||||
img(src=imageAd.imgurl, style="max-width:100%;max-height:190px;margin:0px;vertical-align: middle;")
|
if figureAd.adtype == "image" && figureAdsNum < 5
|
||||||
else
|
- figureAdsNum = 6
|
||||||
div(style="padding:0px 5px 10px 5px;border-bottom:1px solid #dedede;")
|
a(href=figureAd.url, title=figureAd.tiptext, target="_blank")
|
||||||
a#point_ad_text(href=imageAd.url, title=imageAd.tiptext, target="_blank")= imageAd.content
|
img(src=figureAd.imgurl, style="max-width:100%;max-height:190px;margin:0px;vertical-align: middle;")
|
||||||
|
else if figureAdsNum < 5
|
||||||
|
- figureAdsNum = figureAdsNum + 1
|
||||||
|
if figureAdsNum == 1
|
||||||
|
div(style="padding:4px 5px 1px 7px")
|
||||||
|
a#point_ad_text(href=figureAd.url, title=figureAd.tiptext, target="_blank")= figureAd.content
|
||||||
|
else
|
||||||
|
div(style="padding:1px 5px 1px 7px")
|
||||||
|
a#point_ad_text(href=figureAd.url, title=figureAd.tiptext, target="_blank")= figureAd.content
|
||||||
else if inviteData.dialog_ad
|
else if inviteData.dialog_ad
|
||||||
img(src="/res/image.html?id=" + inviteData.dialog_ad, style="height:190px;width:100%;")
|
img(src="/res/image.html?id=" + inviteData.dialog_ad, style="height:190px;width:100%;")
|
||||||
|
|
||||||
|
@ -431,13 +431,21 @@ html
|
|||||||
p(style="text-indent:25px;line-height:25px;")= inviteData.dialog_introduction
|
p(style="text-indent:25px;line-height:25px;")= inviteData.dialog_introduction
|
||||||
|
|
||||||
.content-pic(style='width:100%;height:192px;')
|
.content-pic(style='width:100%;height:192px;')
|
||||||
if imageAd
|
if figureAds
|
||||||
if imageAd.adtype == "image"
|
- var figureAdsNum = 0
|
||||||
a(href=imageAd.url, title=imageAd.tiptext, target="_blank")
|
for figureAd in figureAds
|
||||||
img(src=imageAd.imgurl, style="max-width:100%;max-height:190px;margin:0px;vertical-align: middle;")
|
if figureAd.adtype == "image" && figureAdsNum < 5
|
||||||
else
|
- figureAdsNum = 6
|
||||||
div(style="padding:0px 5px 10px 5px;border-bottom:1px solid #dedede;")
|
a(href=figureAd.url, title=figureAd.tiptext, target="_blank")
|
||||||
a#point_ad_text(href=imageAd.url, title=imageAd.tiptext, target="_blank")= imageAd.content
|
img(src=figureAd.imgurl, style="max-width:100%;max-height:190px;margin:0px;vertical-align: middle;")
|
||||||
|
else if figureAdsNum < 5
|
||||||
|
- figureAdsNum = figureAdsNum + 1
|
||||||
|
if figureAdsNum == 1
|
||||||
|
div(style="padding:4px 5px 1px 7px")
|
||||||
|
a#point_ad_text(href=figureAd.url, title=figureAd.tiptext, target="_blank")= figureAd.content
|
||||||
|
else
|
||||||
|
div(style="padding:1px 5px 1px 7px")
|
||||||
|
a#point_ad_text(href=figureAd.url, title=figureAd.tiptext, target="_blank")= figureAd.content
|
||||||
else if inviteData.dialog_ad
|
else if inviteData.dialog_ad
|
||||||
img(src="/res/image.html?id=" + inviteData.dialog_ad, style="height:190px;width:100%;")
|
img(src="/res/image.html?id=" + inviteData.dialog_ad, style="height:190px;width:100%;")
|
||||||
|
|
||||||
|
@ -66,8 +66,13 @@ else if inviteData.consult_invite_color == "6"
|
|||||||
a(href=pointAd.url, title=pointAd.tiptext, target="_blank")
|
a(href=pointAd.url, title=pointAd.tiptext, target="_blank")
|
||||||
img(src=baseUrl + pointAd.imgurl, style='max-width:140px;max-height:90px;margin:0 5px;vertical-align: middle;')
|
img(src=baseUrl + pointAd.imgurl, style='max-width:140px;max-height:90px;margin:0 5px;vertical-align: middle;')
|
||||||
else
|
else
|
||||||
div(style="padding:0px 5px 10px 5px;border-bottom:1px solid #dedede;")
|
// 文本
|
||||||
a#point_ad_text(href=pointAd.url, title=pointAd.tiptext, target="_blank")= pointAd.content
|
for ad in pointAds
|
||||||
|
- var pointAdsNum = 0
|
||||||
|
if ad.adtype == "text" && pointAdsNum <= 5
|
||||||
|
- pointAdsNum = pointAdsNum + 1
|
||||||
|
div(style="padding:0px 5px 10px 5px;border-bottom:1px solid #dedede;")
|
||||||
|
a#point_ad_text(href=ad.url, title=ad.tiptext, target="_blank")= ad.content
|
||||||
else
|
else
|
||||||
img(src=baseUrl + '/images/title.jpg', style='width:140px;margin:0 5px;vertical-align: middle;')
|
img(src=baseUrl + '/images/title.jpg', style='width:140px;margin:0 5px;vertical-align: middle;')
|
||||||
div(style="padding:10px 5px;text-align:center;color:#555;")= inviteData.skill == true && inviteData.consult_skill_fixed == false && inviteData.consult_skill_msg ? inviteData.consult_skill_msg : ''
|
div(style="padding:10px 5px;text-align:center;color:#555;")= inviteData.skill == true && inviteData.consult_skill_fixed == false && inviteData.consult_skill_msg ? inviteData.consult_skill_msg : ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user