UserScoreSignDaoImpl 코드 기록
package com.iflytek.edu.zx.archive.dao.impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import org.springframework.util.Assert;
import com.iflytek.edu.elp.common.dao.base.AbstractBaseDao;
import com.iflytek.edu.elp.common.dto.page.PageParam;
import com.iflytek.edu.zx.archive.dao.UserScoreSignDao;
import com.iflytek.edu.zx.archive.model.UserScoreSign;
/**
* @author yywang5
*/
@Repository("userScoreSignDao")
public class UserScoreSignDaoImpl extends AbstractBaseDao implements UserScoreSignDao {
@Override
public void insert(UserScoreSign userScoreSign) {
Assert.notNull(userScoreSign, "userScoreSign is required!");
String sql = "insert into archive_userscoresign (id,topicSetId,userId,userName,classId,signUserName,phoneNum,createTime,parentTitle)";
sql += "values(:id,:topicSetId,:userId,:userName,:classId,:signUserName,:phoneNum,:createTime,:parentTitle)";
Map params = new HashMap();
params.put("id", userScoreSign.getId());
params.put("topicSetId", userScoreSign.getTopicSetId());
params.put("userId", userScoreSign.getUserId());
params.put("userName", userScoreSign.getUserName());
params.put("classId", userScoreSign.getClassId());
params.put("signUserName", userScoreSign.getSignUserName());
params.put("phoneNum", userScoreSign.getPhoneNum());
params.put("createTime", userScoreSign.getCreateTime());
params.put("parentTitle", userScoreSign.getParentTitle());
namedParameterJdbcTemplate.update(sql, params);
}
@Override
public UserScoreSign find(String topicSetId, String userId) {
Assert.notNull(topicSetId, "topicSetId is required!");
Assert.notNull(userId, "userId is required!");
String sql = "select * from archive_userscoresign where topicSetId=:topicSetId and userId=:userId limit 1";
Map params = new HashMap();
params.put("topicSetId", topicSetId);
params.put("userId", userId);
List ussList = namedParameterJdbcTemplate.query(sql, params, new UserScoreSignMapper());
if (CollectionUtils.isNotEmpty(ussList)) {
return ussList.get(0);
}
return null;
}
@Override
public List findByClassId(String topicSetId, String classId) {
Assert.notNull(topicSetId, "topicSetId is required!");
Assert.notNull(classId, "classId is required!");
String sql = "select * from archive_userscoresign where topicSetId=:topicSetId and classId=:classId ";
Map params = new HashMap();
params.put("topicSetId", topicSetId);
params.put("classId", classId);
return namedParameterJdbcTemplate.query(sql, params, new UserScoreSignMapper());
}
@Override
public List findByClassId(Set classIds, PageParam pageParams) {
Assert.notNull(classIds, "classIds is required!");
Map params = new HashMap();
params.put("classIds", classIds);
String orderBy = StringUtils.isEmpty(pageParams.getOrderBy())? "createTime":pageParams.getOrderBy();
String orderDirection = pageParams.getOrderDirection() == null? "desc":pageParams.getOrderDirection().name();
String sql = "select * from archive_userscoresign where classId in (:classIds) order by " +orderBy+ " "+orderDirection+" limit :startIndex, :pageSize";
return namedParameterJdbcTemplate.query(sql, params, new UserScoreSignMapper());
}
@Override
public List findByUserIds(Set userIds, PageParam pageParams) {
Assert.notEmpty(userIds,"userIds is required!");
Map params = new HashMap();
params.put("userIds", userIds);
String orderBy = StringUtils.isEmpty(pageParams.getOrderBy())? "createTime":pageParams.getOrderBy();
String orderDirection = pageParams.getOrderDirection() == null? "desc":pageParams.getOrderDirection().name();
params.put("startIndex", pageParams.getStartIndex());
params.put("pageSize", pageParams.getPageSize());
String sql = "select * from archive_userscoresign where userId in (:userIds) order by " +orderBy+ " "+orderDirection+" limit :startIndex, :pageSize";
return namedParameterJdbcTemplate.query(sql, params, new UserScoreSignMapper());
}
private class UserScoreSignMapper implements RowMapper {
@Override
public UserScoreSign mapRow(ResultSet rs, int rowNum) throws SQLException {
UserScoreSign userScoreSign = new UserScoreSign();
userScoreSign.setId(rs.getString("id"));
userScoreSign.setClassId(rs.getString("classId"));
userScoreSign.setTopicSetId(rs.getString("topicSetId"));
userScoreSign.setPhoneNum(rs.getString("phoneNum"));
userScoreSign.setSignUserName(rs.getString("signUserName"));
userScoreSign.setUserId(rs.getString("userId"));
userScoreSign.setUserName(rs.getString("userName"));
userScoreSign.setCreateTime(rs.getTimestamp("createTime"));
userScoreSign.setParentTitle(rs.getString("parentTitle"));
return userScoreSign;
}
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
【eclipse】같은 파일을 2개 열고 싶다【에디터의 분할】「이런 것은 다른 클래스로 나누어야 한다!」라든지 있다고는 생각합니다만. 실제로 실무 속에서 프로그램을 쓰고 있으면, 이런 소스에 눈에 걸리는 일도 적지 않을까···. 그건 그렇고, 내 노트북에서 이렇게 보입니다 네...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.