package com.hx.phip.service.impl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hx.mybatisTool.SqlSentence; import com.hx.phip.dao.mapper.syn.SyncUserAccountRecordMapper; import com.hx.phip.dao.mapper.syn.SyncUserPictureRcordMapper; import com.hx.phiappt.dao.mapper.SyncUserRecordMapper; import com.hx.phip.model.SyncUserAccountRecord; import com.hx.phip.model.SyncUserPictureRcord; import com.hx.phiappt.model.sync.SyncUserRecord; import com.hx.phip.service.UserLogService; import com.hx.resultTool.Result; import com.hx.util.StringUtils; import net.sf.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.HashMap; import java.util.List; import java.util.Map; @Transactional @Service class UserLogServiceImpl implements UserLogService { private static Logger logger = LoggerFactory.getLogger(UserLogServiceImpl.class); @Resource private SyncUserRecordMapper syncUserRecordMapper; @Resource private SyncUserAccountRecordMapper syncUserAccountRecordMapper; @Resource private SyncUserPictureRcordMapper syncUserPictureRcordMapper; @Override public Result userListLog(JSONObject jsonObject) { Integer pageNum= jsonObject.optInt("pageNum",0); Integer pageSize=jsonObject.optInt("pageSize",0); //分页插件 PageHelper.startPage(pageNum==0?1:pageNum, pageSize==0?10:pageSize); SqlSentence sqlSentence = new SqlSentence(); Map map=new HashMap<>(); sqlSentence.setM(map); StringBuffer sql = new StringBuffer(); sql.append("SELECT * FROM sync_user WHERE isDel=0 "); if(!StringUtils.isEmpty(jsonObject.optString("startTime",null))){ sql.append(" and createTime >= #{m.startTime} "); map.put("startTime", jsonObject.optString("startTime")); } if(!StringUtils.isEmpty(jsonObject.optString("endTime",null))){ sql.append(" and createTime <= #{m.endTime} "); map.put("endTime", jsonObject.optString("endTime")); } if(!StringUtils.isEmpty(jsonObject.optString("type",null))){ sql.append(" and type = #{m.type} "); map.put("type", jsonObject.optString("type")); } sql.append(" ORDER BY editTime desc"); sqlSentence.setSqlSentence(sql.toString()); List orderTotalList = syncUserRecordMapper.selectList(sqlSentence); PageInfo pageInfo = new PageInfo<>(orderTotalList); Map data = new HashMap<>(); data.put("list", pageInfo.getList()); data.put("total", pageInfo.getTotal()); data.put("pages", pageInfo.getPages()); data.put("pageNum", pageInfo.getPageNum()); data.put("pageSize", pageInfo.getPageSize()); data.put("isLastPage", pageInfo.isIsLastPage()); return Result.success(data); } @Override public Result userAccountList(JSONObject jsonObject) { Integer pageNum= jsonObject.optInt("pageNum",0); Integer pageSize=jsonObject.optInt("pageSize",0); //分页插件 PageHelper.startPage(pageNum==0?1:pageNum, pageSize==0?10:pageSize); SqlSentence sqlSentence = new SqlSentence(); Map map=new HashMap<>(); sqlSentence.setM(map); StringBuffer sql = new StringBuffer(); sql.append("SELECT * FROM sync_user_account WHERE isDel=0 "); if(!StringUtils.isEmpty(jsonObject.optString("startTime",null))){ sql.append(" and createTime >= #{m.startTime} "); map.put("startTime", jsonObject.optString("startTime")); } if(!StringUtils.isEmpty(jsonObject.optString("endTime",null))){ sql.append(" and createTime <= #{m.endTime} "); map.put("endTime", jsonObject.optString("endTime")); } if(!StringUtils.isEmpty(jsonObject.optString("type",null))){ sql.append(" and type = #{m.type} "); map.put("type", jsonObject.optString("type")); } sql.append(" ORDER BY editTime desc"); sqlSentence.setSqlSentence(sql.toString()); List orderTotalList = syncUserAccountRecordMapper.selectList(sqlSentence); PageInfo pageInfo = new PageInfo<>(orderTotalList); Map data = new HashMap<>(); data.put("list", pageInfo.getList()); data.put("total", pageInfo.getTotal()); data.put("pages", pageInfo.getPages()); data.put("pageNum", pageInfo.getPageNum()); data.put("pageSize", pageInfo.getPageSize()); data.put("isLastPage", pageInfo.isIsLastPage()); return Result.success(data); } @Override public Result userPictureList(JSONObject jsonObject) { Integer pageNum= jsonObject.optInt("pageNum",0); Integer pageSize=jsonObject.optInt("pageSize",0); //分页插件 PageHelper.startPage(pageNum==0?1:pageNum, pageSize==0?10:pageSize); SqlSentence sqlSentence = new SqlSentence(); Map map=new HashMap<>(); sqlSentence.setM(map); StringBuffer sql = new StringBuffer(); sql.append("SELECT * FROM sync_user_picture WHERE isDel=0 "); if(!StringUtils.isEmpty(jsonObject.optString("startTime",null))){ sql.append(" and createTime >= #{m.startTime} "); map.put("startTime", jsonObject.optString("startTime")); } if(!StringUtils.isEmpty(jsonObject.optString("endTime",null))){ sql.append(" and createTime <= #{m.endTime} "); map.put("endTime", jsonObject.optString("endTime")); } if(!StringUtils.isEmpty(jsonObject.optString("type",null))){ sql.append(" and type = #{m.type} "); map.put("type", jsonObject.optString("type")); } sql.append(" ORDER BY editTime desc"); sqlSentence.setSqlSentence(sql.toString()); List orderTotalList = syncUserPictureRcordMapper.selectList(sqlSentence); PageInfo pageInfo = new PageInfo<>(orderTotalList); Map data = new HashMap<>(); data.put("list", pageInfo.getList()); data.put("total", pageInfo.getTotal()); data.put("pages", pageInfo.getPages()); data.put("pageNum", pageInfo.getPageNum()); data.put("pageSize", pageInfo.getPageSize()); data.put("isLastPage", pageInfo.isIsLastPage()); return Result.success(data); } }