Search in sources :

Example 86 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project EVA-API by PKAQ-LAB.

the class CategoryService method deleteCategory.

/**
 * 根据ID批量删除
 * @param ids
 * @return
 */
public Response deleteCategory(ArrayList<String> ids) {
    Response response = new Response();
    // 检查是否存在子节点,存在子节点不允许删除
    QueryWrapper<CategoryEntity> oew = new QueryWrapper<>();
    oew.setEntity(new CategoryEntity());
    oew.in("parent_ID", ids);
    List<CategoryEntity> leafList = this.mapper.selectList(oew);
    if (CollectionUtil.isNotEmpty(leafList)) {
        // 获取存在子节点的节点名称
        List<Object> list = CollectionUtil.getFieldValues(leafList, "parentName");
        // 拼接名称
        String name = CollectionUtil.join(list, ",");
        response = response.failure(BizCodeEnum.CHILD_EXIST.getIndex(), StrUtil.format("[{}] 存在子节点,无法删除。", name), null);
    } else {
        this.mapper.deleteBatchIds(ids);
        response = response.success(this.mapper.listCategory(null, null), BizCodeEnum.OPERATE_SUCCESS.getName());
    }
    return response;
}
Also used : Response(io.nerv.core.mvc.util.Response) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) CategoryEntity(io.nerv.web.jxc.base.category.entity.CategoryEntity)

Example 87 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project RG by ADrWondertainment.

the class UserServiceImpl method GetUserByEmail.

@Override
public Result GetUserByEmail(String email) {
    QueryWrapper<User> wrapper = new QueryWrapper<>();
    wrapper.eq("email", email);
    User user_result = userMapper.selectOne(wrapper);
    if (user_result == null) {
        throw new BackException(ErrorCode.USER_NAME_UNFINDED, "该用户不存在");
    }
    // if (user_result == null) {
    // ResultUtil.quickSet(
    // result,
    // ErrorCode.USER_NAME_UNFINDED,
    // "该用户不存在",
    // null
    // );
    // return result;
    // }
    ResultUtil.quickSet(result, ErrorCode.SUCCESS, "查询成功", user_result);
    return result;
}
Also used : User(ruangong.root.bean.User) BackException(ruangong.root.exception.BackException) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)

Example 88 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project springboot-scaffold by a241978181.

the class UserServiceImpl method signUp.

@Override
public String signUp(SignUpData data) {
    // 创建User对象
    User user = new User(data);
    try {
        // 加密密码
        user.setPassword(EncryptConfigUtil.encyptPwd(this.encryptorPassword, user.getPassword()));
        // 尝试创建用户
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("name", user.getName());
        User u = this.userMapper.selectOne(queryWrapper);
        if (u != null) {
            return u.getName() + "用户已存在,请修改用户名后重新创建!";
        }
        // 建议使用索引约束来判断用户名是否存在,用户存在时会抛出异常,可以自行捕获数据库的异常,并返回用户已存在的错误提示
        userMapper.insertOneUser(user);
    } catch (Exception e) {
        logger.error("用户创建失败", e);
        throw new ServiceException("用户创建失败");
    }
    return "用户创建成功";
}
Also used : User(com.jxys.entity.User) ErrorServiceException(com.jxys.base.exception.ErrorServiceException) ServiceException(com.jxys.base.exception.ServiceException) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) ErrorServiceException(com.jxys.base.exception.ErrorServiceException) ServiceException(com.jxys.base.exception.ServiceException) UserNotFoundException(com.jxys.user.exception.UserNotFoundException) PasswordErrorException(com.jxys.user.exception.PasswordErrorException)

Example 89 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project spring-boot-web by wangchengming666.

the class UcUserServiceImpl method list.

@Override
@UserOpreationLog(code = UserOperationConstants.U01)
public List<UserDTO> list(UserVO vo) {
    List<UserDTO> reList = new ArrayList<>(1);
    if (StringUtils.isNotBlank(vo.getCellphone())) {
        List<UcUserCellphone> cellphones = ucUserCellphoneMapper.selectList(new QueryWrapper<UcUserCellphone>().eq("cellphone", vo.getCellphone()));
        for (UcUserCellphone item : cellphones) {
            UcUser user = new UcUser();
            user.setId(item.getUserId());
            reList.addAll(listUser(user));
        }
        return reList;
    }
    if (StringUtils.isNotBlank(vo.getEmail())) {
        List<UcUserEmail> emails = ucUserEmailMapper.selectList(new QueryWrapper<UcUserEmail>().eq("email", vo.getEmail()));
        for (UcUserEmail item : emails) {
            UcUser user = new UcUser();
            user.setId(item.getUserId());
            reList.addAll(listUser(user));
        }
        return reList;
    }
    UcUser ucUser = new UcUser();
    ucUser.setIdentityCard(vo.getIdentityCard());
    ucUser.setTrueName(vo.getTrueName());
    ucUser.setNickName(vo.getNickName());
    ucUser.setUcName(vo.getUcName());
    return listUser(ucUser);
}
Also used : UcUserCellphone(com.web.framework.core.entity.UcUserCellphone) UcUserEmail(com.web.framework.core.entity.UcUserEmail) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) UserDTO(com.web.framework.core.model.dto.UserDTO) ArrayList(java.util.ArrayList) UcUser(com.web.framework.core.entity.UcUser) UserOpreationLog(com.web.framework.common.annotation.UserOpreationLog)

Example 90 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project flink-platform-backend by itinycheng.

the class JobRunner method execute.

@Override
public void execute(JobExecutionContext context) {
    JobDetail detail = context.getJobDetail();
    JobDataMap jobDataMap = detail.getJobDataMap();
    JobKey key = detail.getKey();
    Long jobId = Long.parseLong(key.getName());
    try {
        // Avoid preforming the same job multiple times at the same time.
        Long previous = RUNNER_MAP.putIfAbsent(jobId, System.currentTimeMillis());
        if (previous != null && previous > 0) {
            log.warn("The job: {} is already running, start time: {}", jobId, previous);
            return;
        }
        // Step 1: get job info
        JobInfo jobInfo = jobInfoService.getOne(new QueryWrapper<JobInfo>().lambda().eq(JobInfo::getId, jobId).eq(JobInfo::getStatus, JobStatus.ONLINE));
        if (jobInfo == null) {
            log.warn("The job:{} is no longer exists or not in ready/scheduled status.", jobId);
            return;
        }
        // Step 2: build cluster url, set localhost as default url if not specified.
        String routeUrl = jobInfo.getRouteUrl();
        routeUrl = HttpUtil.getUrlOrDefault(routeUrl);
        // Step 3: send http request.
        Map<String, Object> wrappedMap = jobDataMap.getWrappedMap();
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(APPLICATION_JSON);
        String httpUri = routeUrl + String.format(JOB_PROCESS_REST_PATH, jobId);
        ResultInfo<Long> response = restTemplate.exchange(httpUri, HttpMethod.POST, new HttpEntity<>(wrappedMap, headers), new ParameterizedTypeReference<ResultInfo<Long>>() {
        }).getBody();
        log.info("The job: {} is processed, job run result: {}", jobId, response);
    } catch (Exception e) {
        log.error("Cannot exec job: {}", jobId, e);
    } finally {
        RUNNER_MAP.remove(jobId);
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) JobDataMap(org.quartz.JobDataMap) HttpEntity(org.springframework.http.HttpEntity) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) JobDetail(org.quartz.JobDetail) JobKey(org.quartz.JobKey) JobInfo(com.flink.platform.dao.entity.JobInfo) ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference)

Aggregations

QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)723 Transactional (org.springframework.transaction.annotation.Transactional)98 IPage (com.baomidou.mybatisplus.core.metadata.IPage)82 UserRolesVo (top.hcode.hoj.pojo.vo.UserRolesVo)74 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)72 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)65 ArrayList (java.util.ArrayList)61 Session (org.apache.shiro.session.Session)61 StatusFailException (top.hcode.hoj.common.exception.StatusFailException)60 StatusForbiddenException (top.hcode.hoj.common.exception.StatusForbiddenException)55 Problem (top.hcode.hoj.pojo.entity.problem.Problem)50 UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)45 Date (java.util.Date)44 HttpServletRequest (javax.servlet.http.HttpServletRequest)35 HashMap (java.util.HashMap)34 RequiresAuthentication (org.apache.shiro.authz.annotation.RequiresAuthentication)34 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)34 ApiOperation (io.swagger.annotations.ApiOperation)32 HttpSession (javax.servlet.http.HttpSession)31 Judge (top.hcode.hoj.pojo.entity.judge.Judge)30