From 546adab3a6d9871e95f31b6462e170a58a2f0026 Mon Sep 17 00:00:00 2001 From: zhuangqian Date: Wed, 6 Jul 2016 10:24:22 +0800 Subject: [PATCH] update --- README.md | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/README.md b/README.md index 623db156..40fa4906 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,67 @@ public class Notice extends BaseModel { int cnt = Blade.create(News.class).deleteBy("status in #{join(#{ids})}", Maps.create().set("ids", idArr)); ``` +## 通用Service +``` + public interface NoticeService extends IService { + + } + + + @Service + public class NoticeServiceImpl extends BaseService implements NoticeService { + + } + + + @Autowired + NoticeService service; + + @ResponseBody + @RequestMapping(KEY_SAVE) + public AjaxResult save() { + Notice notice = mapping(PERFIX, Notice.class); + boolean temp = service.save(notice); + if (temp) { + return success(SAVE_SUCCESS_MSG); + } else { + return error(SAVE_FAIL_MSG); + } + } + +``` + +## 分页 +``` + @ResponseBody + @RequestMapping(KEY_LIST) + public Object list() { + Object grid = paginate(LIST_SOURCE, new IQuery() { + + @Override + public void queryBefore(AopContext ac) { + if (ShiroKit.lacksRole(ConstShiro.ADMINISTRATOR)) { + String condition = "and creater = #{creater}"; + ac.setCondition(condition); + ac.getParam().put("creater", ShiroKit.getUser().getId()); + } + } + + @Override + public void queryAfter(AopContext ac) { + @SuppressWarnings("unchecked") + PageInfo> page = (PageInfo>) ac.getObject(); + List> list = page.getList(); + for (Map map : list) { + map.put("createrName", Func.getDictName(102, map.get("creater"))); + } + } + }); + + return grid; + } +``` + 注: =======