Search in sources :

Example 1 with TeacherPageParam

use of shu.java.csky.vo.param.TeacherPageParam in project CSKY by SHU-Silence.

the class TeacherServiceImpl method fuzzyQueryTeacher.

@Override
public ResultVO fuzzyQueryTeacher(TeacherPageParam teacherPageParam) {
    String text = teacherPageParam.getText();
    Integer uid = teacherPageParam.getUid();
    if (text == null)
        return new ResultVO(ResStatus.OK, "text为空", null);
    QueryWrapper<Teachers> wrapper = new QueryWrapper<>();
    wrapper.eq("schoolId", teacherPageParam.getSid()).and(wr -> {
        wr.like("tname", text).or().like("studydir", text).or().like("eduresume", text).or().like("proresume", text).or().like("tURL", text);
    }).orderByAsc("id");
    IPage<Teachers> teachersPage = new Page<>();
    BeanUtils.copyProperties(teacherPageParam, teachersPage);
    teachersMapper.selectPage(teachersPage, wrapper);
    TeacherPageVo teacherPageVo = new TeacherPageVo();
    BeanUtils.copyProperties(teachersPage, teacherPageVo);
    ArrayList<TeacherVo> teacherVos = new ArrayList<>();
    for (Teachers record : teachersPage.getRecords()) {
        TeacherVo teacherVo = new TeacherVo();
        BeanUtils.copyProperties(record, teacherVo);
        teacherVos.add(teacherVo);
    }
    // 若查到数据,插入search表
    if (!teacherVos.isEmpty() && (uid != null))
        searchMapper.insert(new Search(0, uid, text));
    teacherPageVo.setTeacherVoList(teacherVos);
    return new ResultVO(ResStatus.OK, "教师模糊查询分页信息返回成功", teacherPageVo);
}
Also used : ResultVO(shu.java.csky.vo.ResultVO) TeacherPageParam(shu.java.csky.vo.param.TeacherPageParam) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) TeacherVo(shu.java.csky.vo.TeacherVo) SearchMapper(shu.java.csky.dao.SearchMapper) Resource(javax.annotation.Resource) ResultVO(shu.java.csky.vo.ResultVO) TeacherService(shu.java.csky.TeacherService) Search(shu.java.csky.entity.Search) TeachersMapper(shu.java.csky.dao.TeachersMapper) ArrayList(java.util.ArrayList) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) Teachers(shu.java.csky.entity.Teachers) ResStatus(shu.java.csky.vo.ResStatus) List(java.util.List) TeacherPageVo(shu.java.csky.vo.page.TeacherPageVo) Service(org.springframework.stereotype.Service) IPage(com.baomidou.mybatisplus.core.metadata.IPage) BeanUtils(org.springframework.beans.BeanUtils) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) ArrayList(java.util.ArrayList) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) Teachers(shu.java.csky.entity.Teachers) Search(shu.java.csky.entity.Search) TeacherVo(shu.java.csky.vo.TeacherVo) TeacherPageVo(shu.java.csky.vo.page.TeacherPageVo)

Aggregations

QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 IPage (com.baomidou.mybatisplus.core.metadata.IPage)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Resource (javax.annotation.Resource)1 BeanUtils (org.springframework.beans.BeanUtils)1 Service (org.springframework.stereotype.Service)1 TeacherService (shu.java.csky.TeacherService)1 SearchMapper (shu.java.csky.dao.SearchMapper)1 TeachersMapper (shu.java.csky.dao.TeachersMapper)1 Search (shu.java.csky.entity.Search)1 Teachers (shu.java.csky.entity.Teachers)1 ResStatus (shu.java.csky.vo.ResStatus)1 ResultVO (shu.java.csky.vo.ResultVO)1 TeacherVo (shu.java.csky.vo.TeacherVo)1 TeacherPageVo (shu.java.csky.vo.page.TeacherPageVo)1 TeacherPageParam (shu.java.csky.vo.param.TeacherPageParam)1