fengxiang
2017-12-22 3e2436955a5daf512098dc879c470ee88ce003eb
src/main/java/com/moral/service/impl/AccountServiceImpl.java
@@ -23,6 +23,8 @@
import com.moral.common.bean.Constants;
import com.moral.common.bean.PageBean;
import com.moral.common.exception.BusinessException;
import com.moral.common.util.Crypto;
import com.moral.common.util.ResourceUtil;
import com.moral.entity.Account;
import com.moral.mapper.AccountMapper;
import com.moral.service.AccountService;
@@ -93,11 +95,17 @@
   public PageBean<Account> getAccountListByPage(Map<String, Object> parameters) {
      Example example = new Example(Account.class);
      Criteria criteria = example.createCriteria();
      if (parameters.containsKey("name")) {
         criteria.andLike("name", "%" + (String) parameters.get("name") + "%");
      if (parameters.containsKey("accountName")) {
         criteria.andLike("accountName", "%" + (String) parameters.get("accountName") + "%");
      }
      if (parameters.containsKey("mobile")) {
         criteria.andLike("mobile", "%" + (String) parameters.get("mobile") + "%");
      }
      if (parameters.containsKey("isDelete")) {
         criteria.andEqualTo("isDelete", parameters.get("isDelete"));
      }
      if (parameters.containsKey("sorter")) {
         example.setOrderByClause((String) parameters.get("sorter"));
      }
      PageHelper.startPage(Integer.valueOf((String) parameters.get("pageIndex")), Integer.valueOf((String) parameters.get("pageSize")));
      List<Account> accounts = accountMapper.selectByExample(example);
@@ -110,10 +118,31 @@
      if (ObjectUtils.isEmpty(account.getId())) {
         account.setIsDelete(Constants.IS_DELETE_FALSE);
         account.setCreateTime(new Date());
         account.setPassword(Crypto.md5(ResourceUtil.getValue("password")));
         return accountMapper.insertSelective(account);
      }else {
         return accountMapper.updateByPrimaryKeySelective(account);
      }
   }
   @Override
   @Transactional
   public Integer deleteAccountByLogic(Account account) {
      account.setIsDelete(Constants.IS_DELETE_TRUE);
      if (account.getId() > 0) {
         throw new BusinessException("hahahahahah..................");
      }
      return accountMapper.updateByPrimaryKeySelective(account);
   }
   @Override
   @Transactional
   public Integer deleteAccountsByLogic(List<Integer> ids) {
      Account account = new Account();
      account.setIsDelete(Constants.IS_DELETE_TRUE);
      Example example = new Example(Account.class);
      example.or().andIn("id", ids);
      return accountMapper.updateByExampleSelective(account, example);
   }
}