业务需求:
步骤一:添加查询语句:```Ora20796StudentMapper.xml```
<!--科目-->
<result column="COURSE" property="course" jdbcType="VARCHAR" />
<!--分数-->
<result column="SCORE" property="score" jdbcType="DECIMAL" />
<!---报表管理自定义-->
<select id="selectStudentReport"
resultMap="BaseResultMap"
parameterType="wht.ora20796.dto.Ora20796Student">
SELECT
stu.STUDENT_NAME,
stu.AGE,
stu.EMAIL,
stu.GRADE,
stus.COURSE as COURSE,
stus.SCORE as SCORE
FROM wht_ora_20796_student stu,wht_ora_20796_student_score stus
<where>
stu.student_id=stus.student_id
<if test="studentName!= null">
and stu.STUDENT_NAME LIKE concat( concat("%",#{studentName,jdbcType=VARCHAR}),"%")
</if>
</where>
</select>
去到学生的dto,添加年级和成绩两个字段:
Ora20796Student.java
/*****/
private String course;//年级
private Long score; //分数
public String getCourse() {
return course;
}
public void setCourse(String course) {
this.course = course;
}
public Long getScore() {
return score;
}
public void setScore(Long score) {
this.score = score;
}
步骤2:修改Ora20796StudentMapper.java
public interface Ora20796StudentMapper extends Mapper<Ora20796Student>{
List<Ora20796Student> selectStudentInfo(Ora20796Student dto);
//学生成绩报表
List<Ora20796Student> selectStudentReport(Ora20796Student dto);
}
步骤3:接口类 IOra20796StudentService.java
package wht.ora20796.service;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.dto.ResponseData;
import com.hand.hap.system.service.IBaseService;
import wht.ora20796.dto.Ora20796Student;
import java.io.InputStream;
import java.util.List;
public interface IOra20796StudentService extends IBaseService<Ora20796Student>, ProxySelf<IOra20796StudentService>{
/**
* 邮箱发送
*/
ResponseData sendEmail(IRequest iRequest, List<Ora20796Student> dto)throws Exception;
ResponseData importExcel(InputStream is, String fileName) throws Exception;
//学生成绩报表
List<Ora20796Student> selectStudentReport(IRequest iRequest, Ora20796Student dto, int page, int pageSize);
}
步骤4 实现类:Ora20796StudentServiceImpl.java
@Autowired
private IMessageService messageService;
/**
* 学生成绩报表
* @param iRequest
* @param dto
* @param page
* @param pageSize
* @return
*/
@Override
public List<Ora20796Student> selectStudentReport(IRequest iRequest, Ora20796Student dto, int page, int pageSize) {
PageHelper.startPage(page, pageSize);
return ora20796StudentMapper.selectStudentReport(dto);
}
步骤5:在components包下新建:Ora20796StudentScoreBean.java
package wht.ora20796.components;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.impl.RequestHelper;
import net.logstash.logback.encoder.org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import wht.ora20796.dto.Ora20796Student;
import wht.ora20796.dto.Ora20796StudentScore;
import wht.ora20796.mapper.Ora20796StudentMapper;
import wht.ora20796.service.IOra20796StudentService;
import java.util.List;
import java.util.Map;
@Component
public class Ora20796StudentScoreBean {
@Autowired
IOra20796StudentService ora20796StudentService;
@Autowired
Ora20796StudentMapper ora20796StudentMapper;
public List<Ora20796Student> loadStudentData(String dsName, String datasetName, Map<String, Object> parameters) {
IRequest iRequest = RequestHelper.newEmptyRequest();//创建一个空的request
//新建一个dto作为一个查询条件
Ora20796Student criteria = new Ora20796Student();
String studentName = String.valueOf(parameters.get("studentName"));
if (StringUtils.isNotBlank(studentName)) {
criteria.setStudentName(String.valueOf(parameters.get("studentName")));
}
return ora20796StudentService.selectStudentReport(iRequest, criteria, 1, 10000);
}
}
ok,到这里代码修改就结束了,重新部署一下
下面去点前端操作:
步骤7:表单设计:
大概样式:
ok,保存,去新建一个表单s
添加参数:
预览: