75 lines
2.8 KiB
Java
75 lines
2.8 KiB
Java
package com.ifish.daoImpl;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
import org.springframework.stereotype.Repository;
|
|
|
|
import com.ifish.dao.UserDao;
|
|
import com.ifish.entity.User;
|
|
import com.ifish.enums.BooleanEnum;
|
|
import com.ifish.enums.PhoneTypeEnum;
|
|
import com.ifish.enums.PushTypeEnum;
|
|
import com.ifish.enums.UserTypeEnum;
|
|
import com.ifish.hibernate.HibernateBaseDao;
|
|
|
|
/**
|
|
* @ClassName: UserDaoImpl
|
|
* @Description: TODO
|
|
* @author ggw
|
|
*
|
|
*/
|
|
|
|
@Repository("userDao")
|
|
public class UserDaoImpl extends HibernateBaseDao<User, Integer> implements UserDao {
|
|
|
|
@Override
|
|
protected Class<User> getEntityClass() {
|
|
return User.class;
|
|
}
|
|
|
|
@Override
|
|
public void updateRemarks(User user) {
|
|
if(user.getUserId()!=null){
|
|
User tmp = this.get(user.getUserId());
|
|
if(tmp!=null){
|
|
tmp.setUpdateTime(new Date());
|
|
tmp.setRemarks(user.getRemarks());
|
|
this.getSession().update(tmp);
|
|
}
|
|
}
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
public List<Integer> getUserIds(String pushType,Integer firstResult, int maxResults) {
|
|
//商家用户
|
|
if(PushTypeEnum.all_shops_push.getKey().equals(pushType)){
|
|
String sql = "select DISTINCT user.user_id from tbl_user user,tbl_aliyun_device_info device where user_type=? and user.user_id = device.user_id and is_register_netease=? limit ?,?";
|
|
List<Integer> list = this.getSession().createSQLQuery(sql).setString(0, UserTypeEnum.userType1.getKey()).setString(1, BooleanEnum.YES.getKey()).setInteger(2, firstResult).setInteger(3,maxResults).list();
|
|
return list;
|
|
}
|
|
//安卓用户
|
|
else if(PushTypeEnum.all_android_push.getKey().equals(pushType)){
|
|
String sql = "select DISTINCT user.user_id from tbl_user user,tbl_aliyun_device_info device where user.user_id = device.user_id and is_register_netease=? limit ?,?";
|
|
List<Integer> list = this.getSession().createSQLQuery(sql).setString(0, BooleanEnum.YES.getKey()).setInteger(1, firstResult).setInteger(2,maxResults).list();
|
|
return list;
|
|
}
|
|
//IOS用户
|
|
else if(PushTypeEnum.all_ios_push.getKey().equals(pushType)){
|
|
String sql = "select DISTINCT user.user_id from tbl_user user,tbl_aliyun_device_info device where user.user_id = device.user_id and is_register_netease=? limit ?,?";
|
|
List<Integer> list = this.getSession().createSQLQuery(sql).setString(0, BooleanEnum.YES.getKey()).setInteger(1, firstResult).setInteger(2,maxResults).list();
|
|
return list;
|
|
}
|
|
//所有用户
|
|
else if(PushTypeEnum.all_push.getKey().equals(pushType)){
|
|
String sql = "select DISTINCT user.user_id from tbl_user user,tbl_aliyun_device_info device where is_register_netease=? and user.user_id = device.user_id limit ?,?";
|
|
List<Integer> list = this.getSession().createSQLQuery(sql).setString(0, BooleanEnum.YES.getKey()).setInteger(1, firstResult).setInteger(2,maxResults).list();
|
|
return list;
|
|
}
|
|
return new ArrayList<Integer>();
|
|
}
|
|
|
|
}
|