use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project CSKY by SHU-Silence.
the class SearchServiceImpl method getSearchHistoryByUId.
@Override
public ResultVO getSearchHistoryByUId(Integer uid) {
QueryWrapper<Search> wrapper = new QueryWrapper<>();
wrapper.eq("uid", uid).orderByAsc("id").last("LIMIT 10");
List<Search> searches = searchMapper.selectList(wrapper);
ArrayList<String> textList = new ArrayList<>();
for (Search search : searches) {
textList.add(search.getText());
}
return new ResultVO(ResStatus.OK, "搜索历史返回成功", textList);
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project CSKY by SHU-Silence.
the class TagServiceImpl method addTagName.
@Override
public ResultVO addTagName(String tagName) {
QueryWrapper<TagName> tagNameQueryWrapper = new QueryWrapper<>();
tagNameQueryWrapper.eq("tag_name", tagName);
Long count = tagNameMapper.selectCount(tagNameQueryWrapper);
if (count > 0) {
return new ResultVO(ResStatus.NO, "改标签已存在", null);
}
TagName tagName1 = new TagName();
tagName1.setTagName(tagName);
tagNameMapper.insert(tagName1);
return new ResultVO(ResStatus.OK, "添加成功", tagName1);
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper 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);
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project CSKY by SHU-Silence.
the class UserServiceImpl method userRegister.
@Override
public ResultVO userRegister(String name, String pwd, String email) {
// 1.根据用户查询,这个用户是否已经被注册
if (isRegister(name)) {
return new ResultVO(ResStatus.NO, "用户名已经被注册!", null);
}
// 2.如果没有被注册则进行保存操作
String md5Pwd = MD5Utils.md5(pwd);
User u = new User();
u.setUsername(name);
u.setPassword(md5Pwd);
// 3. 设置随机头像
List<Avatar> avatarList = avatarMapper.selectList(null);
u.setUserImg(avatarList.get(new Random().nextInt(avatarList.size())).getSrc());
u.setUserEmail(email);
u.setUserRegtime(new Date());
u.setUserModtime(new Date());
// 执行保存操作
int count = userMapper.insert(u);
if (count == 1) {
User user = userMapper.selectOne(new QueryWrapper<User>().eq("username", u.getUsername()));
user.setPassword(null);
return new ResultVO(ResStatus.OK, "注册成功!", user);
}
return new ResultVO(ResStatus.NO, "注册失败!", null);
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project solon-examples by noear.
the class PlusServiceTest method selectOne.
@Test
public void selectOne() {
AppxModel app = appServicePlus.getOne(new QueryWrapper<AppxModel>().eq("app_id", 2));
System.out.println(app);
assert app != null;
assert app.getAppId() == 2;
}
Aggregations