📄 informationserviceimpl.java
字号:
package com.longtime.wap.module.business.service.impl;
import java.util.Date;
import java.util.List;
import com.longtime.wap.common.web.Page;
import com.longtime.wap.model.Information;
import com.longtime.wap.module.business.common.InformationQueryBean;
import com.longtime.wap.module.business.dao.InformationDao;
import com.longtime.wap.module.business.service.InformationService;
/**
* 信息服务实现类
*
* @author gengb
* @date Nov 15, 2007
*/
public class InformationServiceImpl implements InformationService {
private InformationDao inforDao;
/**
* 接受spring的注入,把dao对象注入到service中
*
* @param inforDao
* 信息Dao
*/
public void setInforDao(InformationDao inforDao) {
this.inforDao = inforDao;
}
/**
* 根据搜索条件获取信息列表
*
* @param searchValue
* 搜索的信息内容
* @param searchType
* 搜索的信息类型
* @param fromDate
* 搜索的起始时间
* @param toDate
* 搜索的截止时间
* @param pubType
* 搜索的发布类型
* @param page
* 分页
* @return 信息对象列表
*/
public List getInfosByCondition(String searchValue, String searchType,
String fromDate, String toDate, int pubType,
Page page) {
Integer isPub = null;
boolean isOverdue = false;
// 查询条件:isPub
if (pubType == 0) {
isPub = 1;
} else if (pubType == 1) {
isPub = 0;
fromDate = null;
toDate = null;
} else if (pubType == 3) {
isOverdue = true;
}
InformationQueryBean queryBean = new InformationQueryBean();
queryBean.setFromDate(fromDate);
queryBean.setToDate(toDate);
queryBean.setIsPub(isPub);
if (null != searchValue && searchValue.trim().length() > 0) {
queryBean.setSearchValue("%" + searchValue.trim() + "%");
}
page.setTotalCount(inforDao.retrieveInformationsCount(queryBean,
isOverdue, searchType));
return inforDao.retrieveInformationsByCondition(queryBean, searchType,
isOverdue, page);
}
/**
* 根据信息id获取信息
*
* @param id
* 信息id
* @return 信息对象
*/
public Information getInformationById(long id) {
return inforDao.retrieveInformationById(new Long(id));
}
/**
* 更新信息状态
*
* @param ids
* 信息id数组
* @param isPub
* 是否发布
*/
public void savePubStatus(String[] ids, boolean isPub) {
List informations = inforDao.retrieveInformationsByIds(ids);
for (int i = 0; i < informations.size(); i++) {
Information information = (Information) informations.get(i);
if (isPub) {
information.setIsPub(1);
information.setPubDate(new Date());
} else {
information.setIsPub(0);
information.setPubDate(null);
}
}
inforDao.updateInformations(informations);
}
/**
* 批量删除信息
*
* @param ids
* 信息id数组
*/
public void deleteInformations(String[] ids) {
List informations = inforDao.retrieveInformationsByIds(ids);
inforDao.deleteInformations(informations);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -