Commit 547ad67e authored by 赵啸非's avatar 赵啸非

添加公共庫

parent 7620efa2
......@@ -23,5 +23,5 @@ public interface MatterService extends ICRUDService<MatterEntity,Long>{
* 推荐or取消推荐
* @param id
*/
void recommend(Long id,Context context);
Rest<String> recommend(Long id,Context context);
}
\ No newline at end of file
......@@ -142,11 +142,12 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
}
@Override
public void recommend(Long id, Context context) {
public Rest<String> recommend(Long id, Context context) {
MatterEntity matterEntity = this.get(id, context);
if (matterEntity == null) {
throw new AppException("数据已更改,请重试");
}
String msg="推荐成功!";
int recommendCount = this.count(new MatterQuery().siteId(matterEntity.getSiteId()).isRecommend(YesNoEnum.YES.getValue()), null);
if (matterEntity.getIsRecommend() == YesNoEnum.NO.getValue()) {
if (recommendCount >= RECOMMEND_COUNT) {
......@@ -155,7 +156,10 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
matterEntity.setIsRecommend(YesNoEnum.YES.getValue());
} else {
matterEntity.setIsRecommend(YesNoEnum.NO.getValue());
msg="取消推荐成功!";
}
this.update(matterEntity, context);
return Rest.ok(msg);
}
}
\ No newline at end of file
......@@ -100,16 +100,16 @@ public class MatterController extends BaseCRUDJsonBodyMappingController<MatterSe
int code = 1;
String busiDesc = "推荐or取消推荐" + this.getModuleDesc();
try {
this.service.recommend(id,getContext());
model.put("message_info", this.getModuleDesc() + "推荐or取消推荐成功!");
this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + id + "]");
} catch (Exception var7) {
Rest<String> rest = this.service.recommend(id, getContext());
model.put("message_info", rest.getMsg());
this.recordSysLog(this.request, rest.getMsg());
} catch (Exception e) {
code = -1;
this.doException(this.request, busiDesc, model, var7);
this.doException(this.request, busiDesc, model, e);
}
JSONObject ret = new JSONObject();
ret.put("code", Integer.valueOf(code));
ret.put("code", code);
ret.put("msg", model.remove("message_info"));
ret.put("data", model);
return ret.toJSONString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment