Commit 7620efa2 authored by 赵啸非's avatar 赵啸非

添加公共庫

parent 772a9699
......@@ -23,5 +23,5 @@ public interface MatterService extends ICRUDService<MatterEntity,Long>{
* 推荐or取消推荐
* @param id
*/
void recommend(Long id);
void recommend(Long id,Context context);
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.MatterSourceEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.ParamKey;
import com.mortals.xhx.common.utils.StringUtils;
import com.mortals.xhx.module.matter.model.MatterDatumEntity;
......@@ -52,11 +53,11 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
return params;
}
@Override
protected void updateBefore(MatterEntity entity, Context context) throws AppException {
entity.setIsRecommend(null);
this.validData(entity, context);
}
// @Override
// protected void updateBefore(MatterEntity entity, Context context) throws AppException {
// entity.setIsRecommend(null);
// this.validData(entity, context);
// }
// @Override
// protected void removeBefore(Long[] ids, Context context) throws AppException {
......@@ -86,7 +87,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
@Override
public Rest<String> createMatterbBySheetMatter(Long[] sheetMatterIds, Long siteId, Context context) {
if(ObjectUtils.isEmpty(sheetMatterIds)){
if (ObjectUtils.isEmpty(sheetMatterIds)) {
throw new AppException("事项ids is null");
}
int success = 0;
......@@ -141,26 +142,20 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
}
@Override
public void recommend(Long id) {
MatterEntity matterEntity = this.get(id);
public void recommend(Long id, Context context) {
MatterEntity matterEntity = this.get(id, context);
if (matterEntity == null) {
throw new AppException("数据已更改,请重试");
}
int recommendCount = paramService.getParamIntValue(ParamKey.MATTER_RECOMMEND_COUNT);
Map<String, Object> data = new HashMap<>();
Map<String, Object> condition = new HashMap<>();
condition.put("id", id);
if (matterEntity.getIsRecommend() == 0) {
int recommendCount = this.count(new MatterQuery().siteId(matterEntity.getSiteId()).isRecommend(YesNoEnum.YES.getValue()), null);
if (matterEntity.getIsRecommend() == YesNoEnum.NO.getValue()) {
if (recommendCount >= RECOMMEND_COUNT) {
throw new AppException("超过推荐个数");
throw new AppException("超过推荐个数!");
}
recommendCount++;
data.put("isRecommend", 1);
matterEntity.setIsRecommend(YesNoEnum.YES.getValue());
} else {
recommendCount--;
data.put("isRecommend", 0);
matterEntity.setIsRecommend(YesNoEnum.NO.getValue());
}
this.dao.update(data, condition);
paramService.setValueByKey(ParamKey.MATTER_RECOMMEND_COUNT, String.valueOf(recommendCount));
this.update(matterEntity, context);
}
}
\ No newline at end of file
......@@ -96,12 +96,11 @@ public class MatterController extends BaseCRUDJsonBodyMappingController<MatterSe
@RequestMapping(value = {"recommend"},method = {RequestMethod.POST, RequestMethod.GET})
public String recommend(Long id) {
Context context = this.getContext();
Map<String, Object> model = new HashMap();
int code = 1;
String busiDesc = "推荐or取消推荐" + this.getModuleDesc();
try {
this.service.recommend(id);
this.service.recommend(id,getContext());
model.put("message_info", this.getModuleDesc() + "推荐or取消推荐成功!");
this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + id + "]");
} catch (Exception var7) {
......
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