发表于: 2020-01-05 23:56:34
1 1145
今日想法:
今日作为:
页面一的表格类
public class Student {
private Long id;
private String name;
private String picture;
private Boolean working;
private String company;
private String job;
private Long profession_id;
private String expreience;
private Boolean excellent;
private Long create_time;
private Long update_time;
private String create_by;
private String update_by;
private Profession profession;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPicture() {
return picture;
}
public void setPicture(String picture) {
this.picture = picture;
}
public Boolean getWorking() {
return working;
}
public void setWorking(Boolean working) {
this.working = working;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
public Long getProfession_id() {
return profession_id;
}
public void setProfession_id(Long profession_id) {
this.profession_id = profession_id;
}
public String getExpreience() {
return expreience;
}
public void setExpreience(String expreience) {
this.expreience = expreience;
}
public Boolean getExcellent() {
return excellent;
}
public void setExcellent(Boolean excellent) {
this.excellent = excellent;
}
public Long getCreate_time() {
return create_time;
}
public void setCreate_time(Long create_time) {
this.create_time = create_time;
}
public Long getUpdate_time() {
return update_time;
}
public void setUpdate_time(Long update_time) {
this.update_time = update_time;
}
public String getCreate_by() {
return create_by;
}
public void setCreate_by(String create_by) {
this.create_by = create_by;
}
public String getUpdate_by() {
return update_by;
}
public void setUpdate_by(String update_by) {
this.update_by = update_by;
}
public Profession getProfession() {
return profession;
}
public void setProfession(Profession profession) {
this.profession = profession;
}
@Override
public String toString() {
return "Student{" +
"id=" + id +
", name='" + name + '\'' +
", picture='" + picture + '\'' +
", working=" + working +
", company='" + company + '\'' +
", job='" + job + '\'' +
", profession_id=" + profession_id +
", expreience='" + expreience + '\'' +
", excellent=" + excellent +
", create_time=" + create_time +
", update_time=" + update_time +
", create_by='" + create_by + '\'' +
", update_by='" + update_by + '\'' +
", profession=" + profession +
'}';
}
}
页面二的表格类
public class Profession {
private Long id;
private String name;
private String picture;
private String introduction;
private Long sill;
private Long grade;
private String growth;
private Long scarcity;
private String salary_one;
private String salary_two;
private String salary_three;
private Long number;
private Long create_time;
private Long update_time;
private String create_by;
private String update_by;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPicture() {
return picture;
}
public void setPicture(String picture) {
this.picture = picture;
}
public String getIntroduction() {
return introduction;
}
public void setIntroduction(String introduction) {
this.introduction = introduction;
}
public Long getSill() {
return sill;
}
public void setSill(Long sill) {
this.sill = sill;
}
public Long getGrade() {
return grade;
}
public void setGrade(Long grade) {
this.grade = grade;
}
public String getGrowth() {
return growth;
}
public void setGrowth(String growth) {
this.growth = growth;
}
public Long getScarcity() {
return scarcity;
}
public void setScarcity(Long scarcity) {
this.scarcity = scarcity;
}
public String getSalary_one() {
return salary_one;
}
public void setSalary_one(String salary_one) {
this.salary_one = salary_one;
}
public String getSalary_two() {
return salary_two;
}
public void setSalary_two(String salary_two) {
this.salary_two = salary_two;
}
public String getSalary_three() {
return salary_three;
}
public void setSalary_three(String salary_three) {
this.salary_three = salary_three;
}
public Long getNumber() {
return number;
}
public void setNumber(Long number) {
this.number = number;
}
public Long getCreate_time() {
return create_time;
}
public void setCreate_time(Long create_time) {
this.create_time = create_time;
}
public Long getUpdate_time() {
return update_time;
}
public void setUpdate_time(Long update_time) {
this.update_time = update_time;
}
public String getCreate_by() {
return create_by;
}
public void setCreate_by(String create_by) {
this.create_by = create_by;
}
public String getUpdate_by() {
return update_by;
}
public void setUpdate_by(String update_by) {
this.update_by = update_by;
}
@Override
public String toString() {
return "Profession{" +
"id=" + id +
", name='" + name + '\'' +
", picture='" + picture + '\'' +
", introduction='" + introduction + '\'' +
", sill=" + sill +
", grade=" + grade +
", growth='" + growth + '\'' +
", scarcity=" + scarcity +
", salary_one='" + salary_one + '\'' +
", salary_two='" + salary_two + '\'' +
", salary_three='" + salary_three + '\'' +
", number=" + number +
", create_time=" + create_time +
", update_time=" + update_time +
", create_by='" + create_by + '\'' +
", update_by='" + update_by + '\'' +
'}';
}
}
页面一的持久层的接口
@Mapper
public interface StudentMapper {
//展示优秀学员
List<Student> show();
//计算找到工作的学员人数
Integer countByWorking();
//计算正在学习的学员人数;
Integer countByLearning();
}
页面二的持久层的接口
@Mapper
public interface ProfessionMapper {
//展示职业信息
List<Profession> getListProfession();
}
页面一的持久层的接口的实现
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jnshu.Dao.StudentMapper">
<!-- 查询只是优秀学员的信息,只展示4位-->
<select id="show" resultType="com.jnshu.Entity.Student">
select * from student where excellent=1 limit 4
</select>
<!-- 查询已经找到工作的学员数量-->
<select id="countByWorking" resultType="java.lang.Integer" >
select count(working) from student where working=1
</select>
<!-- 查询在学的学员数量-->
<select id="countByLearning" resultType="java.lang.Integer" >
select count(working) from student where working=0
</select>
</mapper>
页面二的持久层的接口的实现
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jnshu.Dao.ProfessionMapper">
<select id="getListProfession" resultType="com.jnshu.Entity.Profession">
select profession.*,COUNT(*) AS proCount from student RIGHT JOIN profession
on profession.id = student.profession_id group BY profession.id
</select>
</mapper>
页面一的业务层的接口
public interface StudentService {
//展示优秀学员
List<Student> show();
//计算找到工作的学员人数
Integer countByWorking();
//计算正在学习的学员人数;
Integer countByLearning();
}
页面二的业务层的接口
public interface ProfessionService {
//展示职业信息
List<Profession> getListProfession();
}
页面一的业务层的接口的实现
@Service
public class StudentServiceImpl implements StudentService {
@Autowired
StudentMapper studentMapper;
@Override
public List<Student> show() {
return studentMapper.show();
}
@Override
public Integer countByWorking() {
return studentMapper.countByWorking();
}
@Override
public Integer countByLearning() {
return studentMapper.countByLearning();
}
}
页面二的业务层的接口的实现
@Service
public class ProfessionServiceImpl implements ProfessionService {
@Autowired
ProfessionMapper professionMapper;
@Override
public List<Profession> getListProfession() {
return professionMapper.getListProfession();
}
}
页面一的控制层的接口和实现
@RequestMapping(value = "/home",method = RequestMethod.GET)
public String show(Model model){
//展示优秀学员
List<Student> studentList=studentService.show();
//返回在学人数
Integer count=studentService.countByLearning();
//返回已经工作人数
Integer number=studentService.countByWorking();
model.addAttribute("studentList",studentList);
model.addAttribute("count",count);
model.addAttribute("number",number);
return "home";
}
页面二的控制层的接口和实现
@RequestMapping(value = "/profession",method = RequestMethod.GET)
public String find(Model model){
List<Profession> professionList = professionService.getListProfession();
System.out.println(professionList);
model.addAttribute("professionList",professionList);
return "profession";
}
今日问题:
再测一测,看看哪里需要改。
明日计划:
没什么问题,就可提交了,已经做了两周了,哎。
评论