Search in sources :

Example 11 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project jeecg-boot by jeecgboot.

the class SysDepartController method getDepartName.

/**
 * 根据部门编码获取部门信息
 *
 * @param orgCode
 * @return
 */
@GetMapping("/getDepartName")
public Result<SysDepart> getDepartName(@RequestParam(name = "orgCode") String orgCode) {
    Result<SysDepart> result = new Result<>();
    LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<>();
    query.eq(SysDepart::getOrgCode, orgCode);
    SysDepart sysDepart = sysDepartService.getOne(query);
    result.setSuccess(true);
    result.setResult(sysDepart);
    return result;
}
Also used : SysDepart(org.jeecg.modules.system.entity.SysDepart) Result(org.jeecg.common.api.vo.Result) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 12 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project jeecg-boot by jeecgboot.

the class SysDepartPermissionController method queryTreeListForDeptRole.

/**
 * 用户角色授权功能,查询菜单权限树
 * @param request
 * @return
 */
@RequestMapping(value = "/queryTreeListForDeptRole", method = RequestMethod.GET)
public Result<Map<String, Object>> queryTreeListForDeptRole(@RequestParam(name = "departId", required = true) String departId, HttpServletRequest request) {
    Result<Map<String, Object>> result = new Result<>();
    // 全部权限ids
    List<String> ids = new ArrayList<>();
    try {
        LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
        query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
        query.orderByAsc(SysPermission::getSortNo);
        query.inSql(SysPermission::getId, "select permission_id  from sys_depart_permission where depart_id='" + departId + "'");
        List<SysPermission> list = sysPermissionService.list(query);
        for (SysPermission sysPer : list) {
            ids.add(sysPer.getId());
        }
        List<TreeModel> treeList = new ArrayList<>();
        getTreeModelList(treeList, list, null);
        Map<String, Object> resMap = new HashMap<String, Object>();
        // 全部树节点数据
        resMap.put("treeList", treeList);
        // 全部树ids
        resMap.put("ids", ids);
        result.setResult(resMap);
        result.setSuccess(true);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    return result;
}
Also used : Result(org.jeecg.common.api.vo.Result) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) TreeModel(org.jeecg.modules.system.model.TreeModel) SysPermission(org.jeecg.modules.system.entity.SysPermission) JSONObject(com.alibaba.fastjson.JSONObject)

Example 13 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project jeecg-boot by jeecgboot.

the class SysDepartPermissionController method loadDatarule.

/**
 * 部门管理授权查询数据规则数据
 */
@GetMapping(value = "/datarule/{permissionId}/{departId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId, @PathVariable("departId") String departId) {
    List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
    if (list == null || list.size() == 0) {
        return Result.error("未找到权限配置信息");
    } else {
        Map<String, Object> map = new HashMap<>();
        map.put("datarule", list);
        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 {
            String drChecked = sysDepartPermission.getDataRuleIds();
            if (oConvertUtils.isNotEmpty(drChecked)) {
                map.put("drChecked", drChecked.endsWith(",") ? drChecked.substring(0, drChecked.length() - 1) : drChecked);
            }
        }
        return Result.ok(map);
    // TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
    }
}
Also used : SysDepartPermission(org.jeecg.modules.system.entity.SysDepartPermission) SysPermissionDataRule(org.jeecg.modules.system.entity.SysPermissionDataRule) JSONObject(com.alibaba.fastjson.JSONObject) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 14 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project jeecg-boot by jeecgboot.

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 15 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project jeecg-boot by jeecgboot.

the class SysAnnouncementController method listByUser.

/**
 * @功能:补充用户数据,并返回系统消息
 * @return
 */
@RequestMapping(value = "/listByUser", method = RequestMethod.GET)
public Result<Map<String, Object>> listByUser(@RequestParam(required = false, defaultValue = "5") Integer pageSize) {
    Result<Map<String, Object>> result = new Result<Map<String, Object>>();
    LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    String userId = sysUser.getId();
    // 1.将系统消息补充到用户通告阅读标记表中
    LambdaQueryWrapper<SysAnnouncement> querySaWrapper = new LambdaQueryWrapper<SysAnnouncement>();
    // 全部人员
    querySaWrapper.eq(SysAnnouncement::getMsgType, CommonConstant.MSG_TYPE_ALL);
    // 未删除
    querySaWrapper.eq(SysAnnouncement::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
    // 已发布
    querySaWrapper.eq(SysAnnouncement::getSendStatus, CommonConstant.HAS_SEND);
    // 新注册用户不看结束通知
    querySaWrapper.ge(SysAnnouncement::getEndTime, sysUser.getCreateTime());
    // update-begin--Author:liusq  Date:20210108 for:[JT-424] 【开源issue】bug处理--------------------
    querySaWrapper.notInSql(SysAnnouncement::getId, "select annt_id from sys_announcement_send where user_id='" + userId + "'");
    // update-begin--Author:liusq  Date:20210108  for: [JT-424] 【开源issue】bug处理--------------------
    List<SysAnnouncement> announcements = sysAnnouncementService.list(querySaWrapper);
    if (announcements.size() > 0) {
        for (int i = 0; i < announcements.size(); i++) {
            // update-begin--Author:wangshuai  Date:20200803  for: 通知公告消息重复LOWCOD-759--------------------
            // 因为websocket没有判断是否存在这个用户,要是判断会出现问题,故在此判断逻辑
            LambdaQueryWrapper<SysAnnouncementSend> query = new LambdaQueryWrapper<>();
            query.eq(SysAnnouncementSend::getAnntId, announcements.get(i).getId());
            query.eq(SysAnnouncementSend::getUserId, userId);
            SysAnnouncementSend one = sysAnnouncementSendService.getOne(query);
            if (null == one) {
                log.info("listByUser接口新增了SysAnnouncementSend:pageSize{}:" + pageSize);
                SysAnnouncementSend announcementSend = new SysAnnouncementSend();
                announcementSend.setAnntId(announcements.get(i).getId());
                announcementSend.setUserId(userId);
                announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);
                sysAnnouncementSendService.save(announcementSend);
                log.info("announcementSend.toString()", announcementSend.toString());
            }
        // update-end--Author:wangshuai  Date:20200803  for: 通知公告消息重复LOWCOD-759------------
        }
    }
    // 2.查询用户未读的系统消息
    Page<SysAnnouncement> anntMsgList = new Page<SysAnnouncement>(0, pageSize);
    // 通知公告消息
    anntMsgList = sysAnnouncementService.querySysCementPageByUserId(anntMsgList, userId, "1");
    Page<SysAnnouncement> sysMsgList = new Page<SysAnnouncement>(0, pageSize);
    // 系统消息
    sysMsgList = sysAnnouncementService.querySysCementPageByUserId(sysMsgList, userId, "2");
    Map<String, Object> sysMsgMap = new HashMap<String, Object>();
    sysMsgMap.put("sysMsgList", sysMsgList.getRecords());
    sysMsgMap.put("sysMsgTotal", sysMsgList.getTotal());
    sysMsgMap.put("anntMsgList", anntMsgList.getRecords());
    sysMsgMap.put("anntMsgTotal", anntMsgList.getTotal());
    result.setSuccess(true);
    result.setResult(sysMsgMap);
    return result;
}
Also used : SysAnnouncementSend(org.jeecg.modules.system.entity.SysAnnouncementSend) SysAnnouncement(org.jeecg.modules.system.entity.SysAnnouncement) HashMap(java.util.HashMap) IPage(com.baomidou.mybatisplus.core.metadata.IPage) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) LoginUser(org.jeecg.common.system.vo.LoginUser) Result(org.jeecg.common.api.vo.Result) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) JSONObject(com.alibaba.fastjson.JSONObject) Map(java.util.Map) HashMap(java.util.HashMap)

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