@Controller
public class ShowRecommendationController extends BaseController {
  private static Log logger = LogFactory.getLog(ShowRecommendationController.class);
  private static boolean isDebug = logger.isDebugEnabled();

  @Autowired IRecommendationService recommendationService;

  @RequestMapping(value = "/admin/showRecommendations", method = RequestMethod.GET)
  public String showRecommendations(
      Model model, HttpServletRequest request, HttpServletResponse response) throws Exception {

    // Integer sid = WebUtils.getReqParameter(request, "sid", -1);//default value should be -1, use
    // 1 for test
    Integer sid =
        Integer.parseInt(((T00User) getSessionData(request, StaticVarAll.USER_SESSION)).getId());
    model.addAttribute("sid", sid);
    // 获取页数
    int pagenum = WebUtils.getReqParameter(request, "pagenum", 1);
    if (pagenum <= 0 || pagenum <= 0) {
      pagenum = 1;
    }
    int pagesize = 20;
    List<T01Position> positionList = recommendationService.getRecommentdationPositionListBySid(sid);
    if (isDebug) {
      logger.debug("*****************sid******************" + sid);
      logger.debug("*****************positionList******************" + positionList);
      logger.debug("*****************pagenum******************" + pagenum);
    }
    Pager pager = new Pager(pagenum, recommendationService.getRecommendationCount(sid), pagesize);
    model.addAttribute("positionList", positionList);
    return "/admin/showRecommendations";
  }
}
示例#2
0
@Service
public class StudentRewardService implements IStudentRewardService {
  private static Log logger = LogFactory.getLog(StudentRewardService.class);

  public int addReward(T01RewardExp t01RewardExp) throws DaoException {
    String sql = "insert into t01_rewarded_exp values (null,?,?,?,?)";
    if (logger.isDebugEnabled()) {
      logger.debug("**sql:" + sql);
      logger.debug("**rid:" + t01RewardExp);
    }
    IDao dao = DaoFactory.createDaoInstance();
    return dao.update(
        "ijsp",
        sql,
        new Object[] {
          t01RewardExp.getRSid(),
          t01RewardExp.getRewardName(),
          t01RewardExp.getRewardTime(),
          t01RewardExp.getOrganization()
        });
  }

  public int updateReward(T01RewardExp t01RewardExp) throws DaoException {
    String sql =
        "update t01_rewarded_exp set rewardName=?, rewardTime=?,organization=? where rid = ?";
    if (logger.isDebugEnabled()) {
      logger.debug("**sql:" + sql);
      logger.debug("**rid:" + t01RewardExp);
    }
    IDao dao = DaoFactory.createDaoInstance();
    return dao.update(
        "ijsp",
        sql,
        new Object[] {
          t01RewardExp.getRewardName(),
          t01RewardExp.getRewardTime(),
          t01RewardExp.getOrganization(),
          t01RewardExp.getRid()
        });
  }

  public int getRewardCount(int rSid) throws DaoException {
    String sql = "select count(1) from t01_rewarded_exp where rSid = " + rSid;
    IDao dao = DaoFactory.createDaoInstance();
    int count = dao.queryCount("ijsp", sql);
    if (logger.isDebugEnabled()) {
      logger.debug("**sql:" + sql);
      logger.debug("**count:" + count);
    }
    return count;
  }

  public T01RewardExp getReward(long rid) throws DaoException {
    String sql = "select * from t01_rewarded_exp where rid=?";
    if (logger.isDebugEnabled()) {
      logger.debug("**sql:" + sql);
      logger.debug("**id:" + rid);
    }
    IDao dao = DaoFactory.createDaoInstance();
    return dao.queryUniq("ijsp", sql, T01RewardExp.class, rid);
  }

  public List<T01RewardExp> listReward(int start, int length, int rSid) throws DaoException {
    String sql = "select * from t01_rewarded_exp where rSid = ? limit ?,?";
    logger.debug("**sql:" + sql);
    logger.debug("**rSid:" + rSid);
    logger.debug("**start:" + start);
    logger.debug("**length:" + length);

    IDao dao = DaoFactory.createDaoInstance();
    List<T01RewardExp> list =
        dao.query("ijsp", sql, T01RewardExp.class, new Object[] {rSid, start, length});
    return list;
  }

  public int deleteReward(long rid) throws DaoException {
    String sql = "delete from t01_rewarded_exp where rid = ?";
    if (logger.isDebugEnabled()) {
      logger.debug("**sql:" + sql);
      logger.debug("**id:" + rid);
    }
    IDao dao = DaoFactory.createDaoInstance();
    return dao.update("ijsp", sql, rid);
  }
}