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;
}
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;
}
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 "用户创建成功";
}
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);
}
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);
}
}
Aggregations