yujian
2019-03-20 1e53e5f28c55ece70b28c752fa318e2fd951e643
fanli/src/main/java/com/yeshi/fanli/service/impl/user/AccountMessageServiceImpl.java
@@ -1,6 +1,5 @@
package com.yeshi.fanli.service.impl.user;
import java.io.Serializable;
import java.util.List;
import javax.annotation.Resource;
@@ -11,7 +10,7 @@
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.config.SystemZnxDao;
import com.yeshi.fanli.dao.user.AccountMessageDao;
import com.yeshi.fanli.dao.mybatis.AccountMessageMapper;
import com.yeshi.fanli.dao.user.UserInfoDao;
import com.yeshi.fanli.entity.bus.user.AccountMessage;
import com.yeshi.fanli.entity.bus.user.UserInfo;
@@ -23,47 +22,43 @@
public class AccountMessageServiceImpl implements AccountMessageService {
   @Resource
   private AccountMessageDao dao;
   private AccountMessageMapper accountMessageMapper;
   @Resource
   private UserInfoDao userInfoDao;
   @Resource
   private SystemZnxDao systemZnxDao;
   @Resource
   private AccountMessageService accountMessageService;
   @Override
   public List<AccountMessage> findAccountMessageList(long uid, int page) {
      return dao.list("from AccountMessage am where am.userInfo.id=? order by id desc",
            (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, new Serializable[] { uid });
      return accountMessageMapper.listByUidOrderByIdDesc(uid, (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE);
   }
   @Override
   public int getCount(long uid) {
      return (int) dao.getCount("select count(*) from AccountMessage am where am.userInfo.id=?",
            new Serializable[] { uid });
      return (int) accountMessageMapper.countByUidAndOpen(uid, null);
   }
   @Override
   public void open(long id) {
      AccountMessage find = dao.find(AccountMessage.class, id);
      AccountMessage find = accountMessageMapper.selectByPrimaryKey(id);
      if (find != null) {
         find.setIsOpen(true);
         dao.update(find);
         AccountMessage update = new AccountMessage();
         update.setId(id);
         update.setIsOpen(true);
         accountMessageMapper.updateByPrimaryKeySelective(update);
      }
   }
   @Override
   public int getCanOpenCount(long uid) {
      return (int) dao.getCount("select count(*) from AccountMessage am where am.userInfo.id=? and am.isOpen=0",
            new Serializable[] { uid });
      return (int) accountMessageMapper.countByUidAndOpen(uid, false);
   }
   @Override
   public void save(AccountMessage accountMessage) {
      if (accountMessage != null)
         dao.save(accountMessage);
         accountMessageMapper.insertSelective(accountMessage);
   }
   @SuppressWarnings("unchecked")
@@ -97,7 +92,7 @@
            accountMessage.setIsOpen(false);
            accountMessage.setUserInfo(new UserInfo(uid));
            accountMessage.setSystemMsgId(systemZnx.getId());
            accountMessageService.save(accountMessage);
            save(accountMessage);
         }
   }