* 学生类
*/
public class Student {
private String name;//学生姓名
private String pwd;//学生密码
//补充完成该类的含参构造方法
public Student(String name,String pwd){
this.name = name;
this.pwd = pwd;
}}
/** * 使用全局变量: sdf,将字符串转换为java.util.Date类型并返回 * @param stringDate * 注意,不能声明任何形式的异常抛出,否则测试用例无法通过 * @return */ public static Date convertFromStringToDate(String stringDate) { // 补全代码: Date date = null; return date; }
*处理日期的工具类
*/
public class DateUtil {
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
* 使用全局变量: sdf,将字符串转换为java.util.Date类型并返回
* 注意,不能声明任何形式的异常抛出,否则测试用例无法通过
* @param stringDate
* @return
*/
public static Date convertFromStringToDate(String stringDate) {
// 补全代码:
Date date = null;
try {
date = sdf.parse(stringDate);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/**
* 使用全局变量: sdf,将日期转换成字符串
* @param date 需要被转换的日期
* @return 转换之后的字符串形式的日期
*/
public static String convertFromDateToString(Date date) {
return sdf.format(date);
}
}
package org.lanqiao.daoimpl;
import java.util.List;
import org.lanqiao.bean.Account;
import org.lanqiao.bean.Info;
import org.lanqiao.dao.SSDao;
import org.lanqiao.db.ObjectUtil;
/**
* 接口实现类
*/
public class SSDaoImpl implements SSDao{
/*
* ObjectUtil工具类提供的方法能实现对数据库的CRUD操作
* */
ObjectUtil<Info> infoUtil = new ObjectUtil<Info>();
ObjectUtil<Account> accountUtil = new ObjectUtil<Account>();
/**
* 依据员工姓名查询员工信息
* @param name 员工姓名
* @return 有的话返回对象,没有的话返回null
*/
public Info queryByName(String name){
// 请补全sql语句
String sql = "select * from info where name=?";
Info i = infoUtil.getOne(sql, Info.class, name);
return i;
}
/**
* 依据员工姓名和绩效日期查询绩效分
* @param name 员工姓名
* @param time 绩效日期
* @return 有的话返回绩效分,没有的话返回0
*/
public int queryScore(String name, String time){
// 请补全sql语句
String sql = "select * from account where name=? and time=?";
Account i = accountUtil.getOne(sql, Account.class, name, time);
if(i==null){
return 0;
}else{
return i.getScore();
}
}
/**
* 查询绩效分最高的员工姓名
* @return 返回员工姓名
*/
public String queryMaxScore(){
// 请补全sql语句
String sql = "select * from account order by score desc limit 1";
Account i = accountUtil.getOne(sql, Account.class);
return i.getName();
}
/**
* 查询平均绩效分最高的员工姓名
* @return 返回姓名
*/
public String queryMaxAvg() {
// 请补全sql语句
String sql = "select * from account where name=(select name from account group by name order by avg(score) desc limit 1)";
Account i = accountUtil.getOne(sql, Account.class);
return i.getName();
}
/**
* 查询员工绩效分最高分与最低分差值最大的员工姓名
* @return 返回姓名
*/
public String queryMaxMin() {
// 请补全sql语句
String sql = "select * from account where name=(select name from account group by name order by max(score)-min(score) desc limit 1)";
Account i = accountUtil.getOne(sql, Account.class);
return i.getName();
}
}