You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.0 KiB
72 lines
2.0 KiB
package com.platform.service;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
import com.platform.dao.DataInfoDao;
|
|
import com.platform.entities.DataInfoEntity;
|
|
import com.platform.entities.PagerOptions;
|
|
|
|
@Service(value = "dataInfoService")
|
|
public class DataInfoServiceImp implements DataInfoService {
|
|
@Resource(name = "dataInfoDao")
|
|
private DataInfoDao dfdDao;
|
|
|
|
public void setDfdDao(DataInfoDao dfdDao) {
|
|
this.dfdDao = dfdDao;
|
|
}
|
|
|
|
@Override
|
|
public ModelMap getPagerTableData(PagerOptions pagerOptions) {
|
|
// TODO Auto-generated method stub
|
|
ModelMap modelMap = new ModelMap();
|
|
int count = dfdDao.getLimitedDataCount(pagerOptions); //获取总记录条数
|
|
System.out.println("total colume " + count);
|
|
int offset = 0;
|
|
if (pagerOptions.getCurrentPageNum() > 1) {
|
|
pagerOptions.setTotalLimit((pagerOptions.getCurrentPageNum() - 1)
|
|
* pagerOptions.getPriorTableSize());
|
|
offset = dfdDao.getLimitedBeginId(pagerOptions); //获取起始查询id
|
|
System.out.println(offset);
|
|
}
|
|
pagerOptions.setOffset(offset + 1);
|
|
List<DataInfoEntity> result = dfdDao
|
|
.getLimitedDataInfoEntities(pagerOptions);
|
|
modelMap.addAttribute("data", result);
|
|
modelMap.addAttribute("length", count);
|
|
return modelMap;
|
|
}
|
|
|
|
@Override
|
|
public void deleteData(String[] id) throws Exception {
|
|
// TODO Auto-generated method stub
|
|
List<Integer> ids = new ArrayList<Integer>();
|
|
for(String idx: id){
|
|
ids.add(Integer.parseInt(idx));
|
|
}
|
|
if (ids.size() > 0) {
|
|
//数据在不在?
|
|
List<String> paths = dfdDao.getIdIsExist(ids);
|
|
if(paths.size()>0){
|
|
//删除文件操作
|
|
for (int i = 0; i < paths.size(); i++) {
|
|
System.out.println(paths.get(i));
|
|
}
|
|
//删除数据库记录
|
|
dfdDao.removes(ids);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public int save(DataInfoEntity data) throws Exception {
|
|
int result = dfdDao.save(data);
|
|
return result;
|
|
}
|
|
}
|