通过条件模糊查询用户名

    /**
     * 获得学生信息
     * 通过班级id获得学生信息接口
     *
     * @TODO 权限
     * getStudents
     */
    @AutoLog(value = "通过id 或者学号 获得学生")
    @ApiOperation(value = "通过id 或者学号 获得学生", notes = "通过id 或者学号 获得学生")
    @GetMapping(value = "/getStudentByStuIdOrId")
//    @RequiresPermissions("stStudent:getStStudent")
    public Result<?> getStudentByStuIdOrId(String keyword, String key, 
                                           HttpServletRequest req) {
        if (keyword == null) {
            keyword = key;
        }
          QueryWrapper<StStudent> stStudentWrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(keyword)) {
            stStudentWrapper.like("student_id", keyword).or().like("st_name", keyword).or().like("id", keyword);
        }


    List<StStudent> stStudents = stStudentService.list(stStudentWrapper);
        Result result = new Result();
        List<DictModel> models = new ArrayList<>();
        for (StStudent stStudent : stStudents) {
            DictModel dictModel = new DictModel();
            dictModel.setValue(stStudent.getId());
            dictModel.setText(stStudent.getStName() + "(" + stStudent.getStudentId() + ")");
            dictModel.setPhone(stStudent.getStPhoto());
            dictModel.setStName(stStudent.getStName());
            dictModel.setStId(stStudent.getStudentId());
            models.add(dictModel);
        }
        result.setResult(models);
        return result;
    }

vo

package org.jeecg.common.system.vo;

import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class DictModel implements Serializable{
	private static final long serialVersionUID = 1L;

	public DictModel() {
	}
	
	public DictModel(String value, String text) {
		this.value = value;
		this.text = text;
	}
	
	/**
	 * 字典value
	 */
	private String value;
	/**
	 * 字典文本
	 */
	private String text;

	private String phone;
	private String stName;
	private String stId;
	/**
	 * 特殊用途: JgEditableTable
	 * @return
	 */
	public String getTitle() {
		return this.text;
	}

}

你可能感兴趣的:(项目碎片——java)