Skip to content

Commit

Permalink
Fix b3log#756
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Oct 1, 2018
1 parent 3c205ec commit a5434ed
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@
import org.b3log.latke.servlet.advice.RequestProcessAdviceException;
import org.b3log.latke.util.Requests;
import org.b3log.symphony.model.Common;
import org.b3log.symphony.model.Pointtransfer;
import org.b3log.symphony.model.UserExt;
import org.b3log.symphony.service.UserQueryService;
import org.b3log.symphony.util.Symphonys;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
Expand All @@ -40,7 +43,7 @@
* Validates for user point transfer.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.1.3, Jul 28, 2018
* @version 1.0.1.4, Oct 1, 2018
* @since 1.3.0
*/
@Singleton
Expand Down Expand Up @@ -106,5 +109,12 @@ public void doAdvice(final HTTPRequestContext context, final Map<String, Object>
if (balance - amount < balanceMinLimit) {
throw new RequestProcessAdviceException(new JSONObject().put(Keys.MSG, langPropsService.get("insufficientBalanceLabel")));
}

String memo = StringUtils.trim(requestJSONObject.optString(Pointtransfer.MEMO));
if (128 < StringUtils.length(memo)) {
throw new RequestProcessAdviceException(new JSONObject().put(Keys.MSG, langPropsService.get("memoTooLargeLabel")));
}
memo = Jsoup.clean(memo, Whitelist.none());
request.setAttribute(Pointtransfer.MEMO, memo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.b3log.symphony.service;

import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys;
import org.b3log.latke.ioc.Inject;
import org.b3log.latke.logging.Level;
Expand All @@ -43,7 +44,7 @@
* Pointtransfer query service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.21.4.0, Aug 27, 2018
* @version 1.21.4.1, Oct 1, 2018
* @since 1.3.0
*/
@Service
Expand Down Expand Up @@ -511,6 +512,12 @@ public JSONObject getUserPoints(final String userId, final int currentPageNum, f

final String userLink = UserExt.getUserLink(user9);
desTemplate = desTemplate.replace("{user}", userLink);
final String memo = record.optString(Pointtransfer.MEMO);
if (StringUtils.isNotBlank(memo)) {
desTemplate = desTemplate.replace("{memo}", memo);
} else {
desTemplate = desTemplate.replace("{memo}", langPropsService.get("noMemoLabel"));
}

break;
case Pointtransfer.TRANSFER_TYPE_C_ACTIVITY_CHECKIN_STREAK:
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/lang_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,8 @@ pointType5InDesLabel=You reward {user} post {article}
pointType6DesLabel=You invite {user} to join
pointType7DesLabel={user} invite you
pointType8DesLabel=You took part in the activity - checkin
pointType9DesLabel=You transfer to {user}
pointType9InDesLabel={user} transfer to you
pointType9DesLabel=You transfer to {user} ({memo})
pointType9InDesLabel={user} transfer to you ({memo})
pointType10DesLabel=You took part in the activity - <a href="${servePath}/activity/1A0001">Shanghai Lottery</a>
pointType11DesLabel=Continuous sign in every 10 days bonus {point} points
pointType12DesLabel=Acitivity - <a href="${servePath}/activity/1A0001">Shanghai Lottery</a> return
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/lang_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,8 @@ pointType5InDesLabel=\u4F60\u6253\u8D4F\u4E86 {user} \u7684\u5E16\u5B50 {article
pointType6DesLabel=\u4F60\u9080\u8BF7\u4E86 {user} \u52A0\u5165
pointType7DesLabel={user} \u9080\u8BF7\u4E86\u4F60\u52A0\u5165
pointType8DesLabel=\u4F60\u53C2\u52A0\u4E86\u6D3B\u52A8 - \u9886\u53D6\u4ECA\u65E5\u7B7E\u5230\u5956\u52B1
pointType9DesLabel=\u4F60\u8F6C\u8D26\u7ED9 {user}
pointType9InDesLabel={user} \u8F6C\u8D26\u7ED9\u4F60
pointType9DesLabel=\u4F60\u8F6C\u8D26\u7ED9 {user}\uFF08{memo}\uFF09
pointType9InDesLabel={user} \u8F6C\u8D26\u7ED9\u4F60\uFF08{memo}\uFF09
pointType10DesLabel=\u4F60\u53C2\u52A0\u4E86\u6D3B\u52A8 - <a href="${servePath}/activity/1A0001">\u4E0A\u8BC1\u535A\u5F69</a>
pointType11DesLabel=\u8FDE\u7EED\u7B7E\u5230\u6BCF 10 \u5929\u5956\u52B1 {point} \u79EF\u5206
pointType12DesLabel=\u6D3B\u52A8 - <a href="${servePath}/activity/1A0001">\u4E0A\u8BC1\u535A\u5F69</a> \u8FD4\u5F69
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/repository.json
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,12 @@
"type": "String",
"length": 19,
"description": "数据实体 id"
},
{
"name": "memo",
"type": "String",
"length": 255,
"description": "备注"
}
]
},
Expand Down
4 changes: 3 additions & 1 deletion src/main/webapp/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ var Settings = {
})) {
var requestJSONObject = {
"userName": $("#pointTransferUserName").val(),
"amount": $("#pointTransferAmount").val()
"amount": $("#pointTransferAmount").val(),
"memo": $("#pointTransferMemo").val()
};

$.ajax({
Expand All @@ -415,6 +416,7 @@ var Settings = {
$("#pointTransferTip").addClass("succ").removeClass("error").html('<ul><li>' + Label.transferSuccLabel + '</li></ul>');
$("#pointTransferUserName").val('');
$("#pointTransferAmount").val('');
$("#pointTransferMemo").val('');
} else {
$("#pointTransferTip").addClass("error").removeClass("succ").html('<ul><li>' + result.msg + '</li></ul>');
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/skins/classic/home/settings/point.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
</span>
</div>
<div class="module-panel form fn-clear">
<input id="pointTransferUserName" type="text" placeholder="${userNameLabel}"/>
<br/> <br/>
<input id="pointTransferUserName" type="text" placeholder="${userNameLabel}"/><br/> <br/>
<input id="pointTransferAmount" type="number" placeholder="${amountLabel}"/> <br/><br/>
<input id="pointTransferMemo" type="text" placeholder="${memoLabel}"/> <br/><br/>
<div id="pointTransferTip" class="tip"></div> <br/>
<button class="red fn-right" onclick="Settings.pointTransfer('${csrfToken}')">${confirmTransferLabel}</button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/skins/mobile/home/settings/point.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
</div>
<div class="module-panel form fn-clear">
<br/>
<input id="pointTransferUserName" type="text" placeholder="${userNameLabel}"/>
<br/> <br/>
<input id="pointTransferUserName" type="text" placeholder="${userNameLabel}"/><br/> <br/>
<input id="pointTransferAmount" type="number" placeholder="${amountLabel}"/> <br/><br/>
<input id="pointTransferMemo" type="text" placeholder="${memoLabel}"/> <br/><br/>
<div id="pointTransferTip" class="tip"></div> <br/>
<button class="red fn-right" onclick="Settings.pointTransfer('${csrfToken}')">${confirmTransferLabel}</button>
</div>
Expand Down

0 comments on commit a5434ed

Please sign in to comment.