Search in sources :

Example 81 with LambdaQueryWrapper

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("保存成功!");
}
Also used : SysDepartPermission(org.jeecg.modules.system.entity.SysDepartPermission) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 82 with LambdaQueryWrapper

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;
}
Also used : SysAnnouncementSend(org.jeecg.modules.system.entity.SysAnnouncementSend) Date(java.util.Date) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

Example 83 with LambdaQueryWrapper

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("保存成功!");
}
Also used : SysRolePermission(org.jeecg.modules.system.entity.SysRolePermission) IOException(java.io.IOException) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 84 with LambdaQueryWrapper

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;
}
Also used : SysUserAgent(org.jeecg.modules.system.entity.SysUserAgent) Result(org.jeecg.common.api.vo.Result) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 85 with LambdaQueryWrapper

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);
}
Also used : LoginUser(org.jeecg.common.system.vo.LoginUser) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Aggregations

LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)381 Transactional (org.springframework.transaction.annotation.Transactional)60 JSONObject (com.alibaba.fastjson.JSONObject)52 Result (org.jeecg.common.api.vo.Result)50 ArrayList (java.util.ArrayList)42 List (java.util.List)30 Map (java.util.Map)29 Collectors (java.util.stream.Collectors)26 Service (org.springframework.stereotype.Service)24 LoginUser (org.jeecg.common.system.vo.LoginUser)22 SysPermission (org.jeecg.modules.system.entity.SysPermission)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)21 IPage (com.baomidou.mybatisplus.core.metadata.IPage)20 HashMap (java.util.HashMap)20 SysUser (org.jeecg.modules.system.entity.SysUser)20 ApiOperation (io.swagger.annotations.ApiOperation)19 ServiceException (cn.lili.common.exception.ServiceException)18 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)18 Autowired (org.springframework.beans.factory.annotation.Autowired)18