use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.
the class SysDepartPermissionController method saveDatarule.
/**
* 保存数据规则至部门菜单关联表
*/
@PostMapping(value = "/datarule")
public Result<?> saveDatarule(@RequestBody JSONObject jsonObject) {
try {
String permissionId = jsonObject.getString("permissionId");
String departId = jsonObject.getString("departId");
String dataRuleIds = jsonObject.getString("dataRuleIds");
log.info("保存数据规则>>" + "菜单ID:" + permissionId + "部门ID:" + departId + "数据权限ID:" + dataRuleIds);
LambdaQueryWrapper<SysDepartPermission> query = new LambdaQueryWrapper<SysDepartPermission>().eq(SysDepartPermission::getPermissionId, permissionId).eq(SysDepartPermission::getDepartId, departId);
SysDepartPermission sysDepartPermission = sysDepartPermissionService.getOne(query);
if (sysDepartPermission == null) {
return Result.error("请先保存部门菜单权限!");
} else {
sysDepartPermission.setDataRuleIds(dataRuleIds);
this.sysDepartPermissionService.updateById(sysDepartPermission);
}
} catch (Exception e) {
log.error("SysDepartPermissionController.saveDatarule()发生异常:" + e.getMessage(), e);
return Result.error("保存失败");
}
return Result.ok("保存成功!");
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.
the class SysAnnouncementServiceImpl method upDateAnnouncement.
/**
* @功能:编辑消息信息
*/
@Transactional
@Override
public boolean upDateAnnouncement(SysAnnouncement sysAnnouncement) {
// 1.更新系统信息表数据
sysAnnouncementMapper.updateById(sysAnnouncement);
String userId = sysAnnouncement.getUserIds();
if (oConvertUtils.isNotEmpty(userId) && sysAnnouncement.getMsgType().equals(CommonConstant.MSG_TYPE_UESR)) {
// 2.补充新的通知用户数据
String[] userIds = userId.substring(0, (userId.length() - 1)).split(",");
String anntId = sysAnnouncement.getId();
Date refDate = new Date();
for (int i = 0; i < userIds.length; i++) {
LambdaQueryWrapper<SysAnnouncementSend> queryWrapper = new LambdaQueryWrapper<SysAnnouncementSend>();
queryWrapper.eq(SysAnnouncementSend::getAnntId, anntId);
queryWrapper.eq(SysAnnouncementSend::getUserId, userIds[i]);
List<SysAnnouncementSend> announcementSends = sysAnnouncementSendMapper.selectList(queryWrapper);
if (announcementSends.size() <= 0) {
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
announcementSend.setAnntId(anntId);
announcementSend.setUserId(userIds[i]);
announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);
announcementSend.setReadTime(refDate);
sysAnnouncementSendMapper.insert(announcementSend);
}
}
// 3. 删除多余通知用户数据
Collection<String> delUserIds = Arrays.asList(userIds);
LambdaQueryWrapper<SysAnnouncementSend> queryWrapper = new LambdaQueryWrapper<SysAnnouncementSend>();
queryWrapper.notIn(SysAnnouncementSend::getUserId, delUserIds);
queryWrapper.eq(SysAnnouncementSend::getAnntId, anntId);
sysAnnouncementSendMapper.delete(queryWrapper);
}
return true;
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.
the class SysRoleController method saveDatarule.
/**
* 保存数据规则至角色菜单关联表
*/
@PostMapping(value = "/datarule")
public Result<?> saveDatarule(@RequestBody JSONObject jsonObject) {
try {
String permissionId = jsonObject.getString("permissionId");
String roleId = jsonObject.getString("roleId");
String dataRuleIds = jsonObject.getString("dataRuleIds");
log.info("保存数据规则>>" + "菜单ID:" + permissionId + "角色ID:" + roleId + "数据权限ID:" + dataRuleIds);
LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>().eq(SysRolePermission::getPermissionId, permissionId).eq(SysRolePermission::getRoleId, roleId);
SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
if (sysRolePermission == null) {
return Result.error("请先保存角色菜单权限!");
} else {
sysRolePermission.setDataRuleIds(dataRuleIds);
this.sysRolePermissionService.updateById(sysRolePermission);
}
} catch (Exception e) {
log.error("SysRoleController.saveDatarule()发生异常:" + e.getMessage(), e);
return Result.error("保存失败");
}
return Result.ok("保存成功!");
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.
the class SysUserAgentController method queryByUserName.
/**
* 通过userName查询
* @param userName
* @return
*/
@GetMapping(value = "/queryByUserName")
public Result<SysUserAgent> queryByUserName(@RequestParam(name = "userName", required = true) String userName) {
Result<SysUserAgent> result = new Result<SysUserAgent>();
LambdaQueryWrapper<SysUserAgent> queryWrapper = new LambdaQueryWrapper<SysUserAgent>();
queryWrapper.eq(SysUserAgent::getUserName, userName);
SysUserAgent sysUserAgent = sysUserAgentService.getOne(queryWrapper);
if (sysUserAgent == null) {
result.error500("未找到对应实体");
} else {
result.setResult(sysUserAgent);
result.setSuccess(true);
}
return result;
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.
the class SysUserController method updatePassword.
/**
* 首页用户重置密码
*/
// @RequiresRoles({"admin"})
@RequestMapping(value = "/updatePassword", method = RequestMethod.PUT)
public Result<?> updatePassword(@RequestBody JSONObject json) {
String username = json.getString("username");
String oldpassword = json.getString("oldpassword");
String password = json.getString("password");
String confirmpassword = json.getString("confirmpassword");
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (!sysUser.getUsername().equals(username)) {
return Result.error("只允许修改自己的密码!");
}
SysUser user = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, username));
if (user == null) {
return Result.error("用户不存在!");
}
return sysUserService.resetPassword(username, oldpassword, password, confirmpassword);
}
Aggregations