| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.moral.common.bean.Constants; |
| | |
| | | import com.moral.mapper.MenuMapper; |
| | | import com.moral.service.MenuService; |
| | | import com.moral.util.TkMybatisUtils; |
| | | import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer; |
| | | |
| | | import tk.mybatis.mapper.entity.Example; |
| | | |
| | |
| | | private MenuMapper menuMapper; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void addOrModify(Menu menu) { |
| | | try { |
| | | if(menu.getMenuParentId()==null){ |
| | | menu.setMenuParentId(0); |
| | | } |
| | | menu.setUpdateTime(new Date()); |
| | | menu.setUpdateUser(menu.getUpdateUser()); |
| | | if (menu.getId() != null) { |
| | |
| | | menu.setId(menuResult.getId()); |
| | | menuMapper.updateByPrimaryKeySelective(menu); |
| | | } else { |
| | | menu.setChannelId(menu.getChannelId()); |
| | | menu.setIsDelete(Constants.IS_DELETE_FALSE); |
| | | menu.setCreateTime(new Date()); |
| | | menu.setCreateUser(menu.getCreateUser()); |
| | |
| | | } catch (Exception ex) { |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public PageBean queryByPageBean(PageBean pageBean) { |
| | | Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean); |
| | | List<Example.Criteria> criteriaList = example.getOredCriteria(); |
| | | if (criteriaList != null && criteriaList.size() > 0) { |
| | | for (Example.Criteria cri : criteriaList) { |
| | | cri.andNotEqualTo("isDelete", Constants.IS_DELETE_TRUE); |
| | | } |
| | | } else { |
| | | example.or().andNotEqualTo("isDelete", Constants.IS_DELETE_TRUE); |
| | | } |
| | | if (example.getOrderByClause() == null || example.getOrderByClause().isEmpty()) { |
| | | example.setOrderByClause("menu_name asc"); |
| | | } |
| | | List<Menu> menuList = menuMapper.selectWithMenuNameByExample(example); |
| | | Iterator<Menu> iterator = menuList.iterator(); |
| | | while (iterator.hasNext()) { |
| | | Menu menu = iterator.next(); |
| | | if (menu.getMenuParentId() == null) { |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | return new PageBean(menuList); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public int countByExample(PageBean pageBean) { |
| | | Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean); |
| | | TkMybatisUtils.addDeletesToExample(example); |
| | | return menuMapper.selectCountByExample(example); |
| | | return menuMapper.countByExample(example); |
| | | } |
| | | |
| | | @Override |
| | | public PageBean getMenuList(PageBean pageBean) { |
| | | Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean); |
| | | TkMybatisUtils.addDeletesToExample(example); |
| | | if (pageBean.getPageSize() > 0) { |
| | | PageHelper.startPage(pageBean.getPageIndex(), pageBean.getPageSize()); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void deleteByIds(Integer[] ids) { |
| | | Menu menu = new Menu(); |
| | | menu.setIsDelete(Constants.IS_DELETE_TRUE); |