fix: 为mapper加上and,修改部分代码生成器
This commit is contained in:
parent
955cc4aa65
commit
31b9bd8cb3
|
@ -22,7 +22,7 @@
|
|||
<where>
|
||||
#foreach($field in $pageQueryMap)
|
||||
<if test="dto.${field.property} != null and dto.${field.property} != ''">
|
||||
$field.column like CONCAT('%',#{dto.${field.property}},'%')
|
||||
and $field.column like CONCAT('%',#{dto.${field.property}},'%')
|
||||
</if>
|
||||
#end
|
||||
</where>
|
||||
|
|
|
@ -8,6 +8,8 @@ import type { FormItemProps } from '${typesPath}';
|
|||
import { $t } from '@/plugins/i18n';
|
||||
|
||||
export const formRef = ref();
|
||||
// 删除ids
|
||||
export const deleteIds = ref([]);
|
||||
const ${lowercaseName}Store = use${originalName}Store();
|
||||
|
||||
/**
|
||||
|
@ -103,3 +105,23 @@ export const onDelete = async (row: any) => {
|
|||
await ${lowercaseName}Store.delete${originalName}([id]);
|
||||
await onSearch();
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
export const onDeleteBatch = async () => {
|
||||
const ids = deleteIds.value;
|
||||
|
||||
// 是否确认删除
|
||||
const result = await messageBox({
|
||||
title: $t('confirm_delete'),
|
||||
showMessage: false,
|
||||
confirmMessage: undefined,
|
||||
cancelMessage: $t('cancel_delete'),
|
||||
});
|
||||
if (!result) return;
|
||||
|
||||
// 删除数据
|
||||
await ${lowercaseName}Store.delete${originalName}(ids);
|
||||
await onSearch();
|
||||
};
|
|
@ -4,7 +4,7 @@
|
|||
import PureTableBar from '@/components/TableBar/src/bar';
|
||||
import AddFill from '@iconify-icons/ri/add-circle-line';
|
||||
import PureTable from '@pureadmin/table';
|
||||
import { onAdd, onDelete, onSearch, onUpdate } from '${hookPath}';
|
||||
import { onAdd, onDelete, onSearch, onUpdate, deleteIds } from '${hookPath}';
|
||||
import Delete from '@iconify-icons/ep/delete';
|
||||
import EditPen from '@iconify-icons/ep/edit-pen';
|
||||
import Refresh from '@iconify-icons/ep/refresh';
|
||||
|
@ -34,19 +34,27 @@
|
|||
await onSearch();
|
||||
};
|
||||
|
||||
/**
|
||||
* * 选择多行
|
||||
* @param rows
|
||||
*/
|
||||
const onSelectionChange = (rows: Array<any>) => {
|
||||
deleteIds.value = rows.map((row: any) => row.id);
|
||||
};
|
||||
|
||||
/**
|
||||
* 重置表单
|
||||
* @param formEl
|
||||
*/
|
||||
const resetForm = async formEl => {
|
||||
const resetForm = async (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
await onSearch();
|
||||
};
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
onMounted(() => {
|
||||
onSearch();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -66,6 +74,11 @@
|
|||
<PureTableBar :columns="columns" title="${classDescription}" @fullscreen="tableRef.setAdaptive()" @refresh="onSearch">
|
||||
<template #buttons>
|
||||
<el-button :icon="useRenderIcon(AddFill)" type="primary" @click="onAdd"> {{ $t('add_new') }} </el-button>
|
||||
|
||||
<!-- 批量删除按钮 -->
|
||||
<el-button v-show="deleteIds.length > 0" :icon="useRenderIcon(Delete)" type="danger" @click="onDeleteBatch">
|
||||
{{ $t('delete_batches') }}
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template v-slot="{ size, dynamicColumns }">
|
||||
|
|
|
@ -41,8 +41,16 @@ public class GlobalExceptionHandler {
|
|||
// 解析异常
|
||||
String jsonParseError = "JSON parse error (.*)";
|
||||
Matcher jsonParseErrorMatcher = Pattern.compile(jsonParseError).matcher(message);
|
||||
if (jsonParseErrorMatcher.find())
|
||||
if (jsonParseErrorMatcher.find()) {
|
||||
return Result.error(null, 500, "JSON解析异常 " + jsonParseErrorMatcher.group(1));
|
||||
}
|
||||
|
||||
// 数据过大
|
||||
String dataTooLongError = "Data too long for column (.*?) at row 1";
|
||||
Matcher dataTooLongErrorMatcher = Pattern.compile(dataTooLongError).matcher(message);
|
||||
if (dataTooLongErrorMatcher.find()) {
|
||||
return Result.error(null, 500, dataTooLongErrorMatcher.group(1) + " 字段数据过大");
|
||||
}
|
||||
|
||||
return Result.error(null, 500, "服务器异常");
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ public enum ResultCodeEnum {
|
|||
EMAIL_CODE_EMPTY(201, "邮箱验证码过期或不存在"),
|
||||
DATA_EXIST(201, "数据已存在"),
|
||||
DATA_NOT_EXIST(201, "数据不存在"),
|
||||
EMAIL_EXIST(201, "邮箱已存在"),
|
||||
REQUEST_IS_EMPTY(201, "请求数据为空"),
|
||||
DATA_TOO_LARGE(201, "请求数据为空"),
|
||||
USER_IS_EMPTY(201, "用户不存在"),
|
||||
|
|
|
@ -66,9 +66,9 @@ public class EmailUsersController {
|
|||
|
||||
@Operation(summary = "更新邮箱用户状态", description = "更新邮箱用户状态")
|
||||
@PutMapping("updateEmailUserStatus")
|
||||
public Mono<Result<String>> updateEmailUserStatus(@Valid @RequestBody EmailUserUpdateStatusDto dto) {
|
||||
public Result<String> updateEmailUserStatus(@Valid @RequestBody EmailUserUpdateStatusDto dto) {
|
||||
emailUsersService.updateEmailUserStatus(dto);
|
||||
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除邮箱用户发送配置", description = "删除邮箱用户发送配置")
|
||||
|
|
|
@ -3,23 +3,30 @@ package cn.bunny.services.factory;
|
|||
import cn.bunny.common.service.exception.BunnyException;
|
||||
import cn.bunny.common.service.utils.mail.MailSenderUtil;
|
||||
import cn.bunny.dao.entity.system.EmailTemplate;
|
||||
import cn.bunny.dao.entity.system.EmailUsers;
|
||||
import cn.bunny.dao.pojo.common.EmailSend;
|
||||
import cn.bunny.dao.pojo.common.EmailSendInit;
|
||||
import cn.bunny.dao.pojo.common.EmailTemplateTypes;
|
||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.services.mapper.EmailTemplateMapper;
|
||||
import cn.bunny.services.mapper.EmailUsersMapper;
|
||||
import cn.hutool.captcha.CaptchaUtil;
|
||||
import cn.hutool.captcha.CircleCaptcha;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import jakarta.mail.MessagingException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class EmailFactory {
|
||||
|
||||
@Autowired
|
||||
private EmailTemplateMapper emailTemplateMapper;
|
||||
|
||||
@Autowired
|
||||
private EmailUsersMapper emailUsersMapper;
|
||||
|
||||
/**
|
||||
* 生成邮箱验证码
|
||||
*
|
||||
|
@ -58,4 +65,18 @@ public class EmailFactory {
|
|||
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断邮箱是否添加
|
||||
*
|
||||
* @param isDefault 邮箱是否为默认
|
||||
*/
|
||||
public void updateEmailUserDefault(Boolean isDefault) {
|
||||
EmailUsers emailUsers = new EmailUsers();
|
||||
// 判断状态,如果是默认将所有的内容都设为false
|
||||
if (isDefault) {
|
||||
emailUsers.setIsDefault(false);
|
||||
emailUsersMapper.update(emailUsers, Wrappers.<EmailUsers>lambdaUpdate().eq(EmailUsers::getIsDefault, true));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,20 +1,26 @@
|
|||
package cn.bunny.services.service.impl;
|
||||
|
||||
import cn.bunny.common.service.exception.BunnyException;
|
||||
import cn.bunny.dao.dto.system.email.EmailUserUpdateStatusDto;
|
||||
import cn.bunny.dao.dto.system.email.EmailUsersAddDto;
|
||||
import cn.bunny.dao.dto.system.email.EmailUsersDto;
|
||||
import cn.bunny.dao.dto.system.email.EmailUsersUpdateDto;
|
||||
import cn.bunny.dao.entity.system.EmailUsers;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.dao.vo.system.email.EmailUsersVo;
|
||||
import cn.bunny.services.factory.EmailFactory;
|
||||
import cn.bunny.services.mapper.EmailUsersMapper;
|
||||
import cn.bunny.services.service.EmailUsersService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -27,8 +33,12 @@ import java.util.List;
|
|||
* @since 2024-10-10 15:19:22
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class EmailUsersServiceImpl extends ServiceImpl<EmailUsersMapper, EmailUsers> implements EmailUsersService {
|
||||
|
||||
@Autowired
|
||||
private EmailFactory emailFactory;
|
||||
|
||||
/**
|
||||
* * 邮箱用户发送配置 服务实现类
|
||||
*
|
||||
|
@ -62,12 +72,21 @@ public class EmailUsersServiceImpl extends ServiceImpl<EmailUsersMapper, EmailUs
|
|||
*/
|
||||
@Override
|
||||
public void addEmailUsers(@Valid EmailUsersAddDto dto) {
|
||||
// 判断邮箱是否添加
|
||||
String email = dto.getEmail();
|
||||
List<EmailUsers> emailUsersList = list(Wrappers.<EmailUsers>lambdaQuery().eq(EmailUsers::getEmail, dto.getEmail()));
|
||||
if (!emailUsersList.isEmpty()) throw new BunnyException(ResultCodeEnum.EMAIL_EXIST);
|
||||
|
||||
// 更新邮箱默认状态
|
||||
emailFactory.updateEmailUserDefault(dto.getIsDefault());
|
||||
|
||||
// 保存数据
|
||||
EmailUsers emailUsers = new EmailUsers();
|
||||
BeanUtils.copyProperties(dto, emailUsers);
|
||||
save(emailUsers);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新邮箱用户发送配置
|
||||
*
|
||||
|
@ -75,6 +94,9 @@ public class EmailUsersServiceImpl extends ServiceImpl<EmailUsersMapper, EmailUs
|
|||
*/
|
||||
@Override
|
||||
public void updateEmailUsers(@Valid EmailUsersUpdateDto dto) {
|
||||
// 更新邮箱默认状态
|
||||
emailFactory.updateEmailUserDefault(dto.getIsDefault());
|
||||
|
||||
// 更新内容
|
||||
EmailUsers emailUsers = new EmailUsers();
|
||||
BeanUtils.copyProperties(dto, emailUsers);
|
||||
|
@ -98,6 +120,9 @@ public class EmailUsersServiceImpl extends ServiceImpl<EmailUsersMapper, EmailUs
|
|||
*/
|
||||
@Override
|
||||
public void updateEmailUserStatus(EmailUserUpdateStatusDto dto) {
|
||||
// 更新邮箱默认状态
|
||||
emailFactory.updateEmailUserDefault(dto.getIsDefault());
|
||||
|
||||
EmailUsers emailUsers = new EmailUsers();
|
||||
BeanUtils.copyProperties(dto, emailUsers);
|
||||
updateById(emailUsers);
|
||||
|
|
|
@ -6,7 +6,7 @@ management:
|
|||
web:
|
||||
exposure:
|
||||
include: "*"
|
||||
base-path: /actuator
|
||||
base-path: /admin
|
||||
info:
|
||||
env:
|
||||
enabled: true
|
||||
|
|
|
@ -28,13 +28,13 @@
|
|||
from sys_dept
|
||||
<where>
|
||||
<if test="dto.parentId != null and dto.parentId != ''">
|
||||
parent_id like CONCAT('%',#{dto.parentId},'%')
|
||||
and parent_id like CONCAT('%',#{dto.parentId},'%')
|
||||
</if>
|
||||
<if test="dto.deptName != null and dto.deptName != ''">
|
||||
dept_name like CONCAT('%',#{dto.deptName},'%')
|
||||
and dept_name like CONCAT('%',#{dto.deptName},'%')
|
||||
</if>
|
||||
<if test="dto.summary != null and dto.summary != ''">
|
||||
summary like CONCAT('%',#{dto.summary},'%')
|
||||
and summary like CONCAT('%',#{dto.summary},'%')
|
||||
</if>
|
||||
</where>
|
||||
order by update_time
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.bunny.dao.entity.system.EmailTemplate">
|
||||
<id column="id" property="id"/>
|
||||
<id column="create_time" property="createTime"/>
|
||||
<id column="update_time" property="updateTime"/>
|
||||
<id column="create_user" property="createUser"/>
|
||||
<id column="update_user" property="updateUser"/>
|
||||
<id column="is_deleted" property="isDeleted"/>
|
||||
<id column="template_name" property="templateName"/>
|
||||
<id column="subject" property="subject"/>
|
||||
<id column="body" property="body"/>
|
||||
<id column="type" property="type"/>
|
||||
<id column="is_default" property="isDefault"/>
|
||||
<id column="id" property="id"/>
|
||||
<id column="create_time" property="createTime"/>
|
||||
<id column="update_time" property="updateTime"/>
|
||||
<id column="create_user" property="createUser"/>
|
||||
<id column="update_user" property="updateUser"/>
|
||||
<id column="is_deleted" property="isDeleted"/>
|
||||
<id column="template_name" property="templateName"/>
|
||||
<id column="subject" property="subject"/>
|
||||
<id column="body" property="body"/>
|
||||
<id column="type" property="type"/>
|
||||
<id column="is_default" property="isDefault"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
|
@ -28,18 +28,18 @@
|
|||
<include refid="Base_Column_List"/>
|
||||
from sys_email_template
|
||||
<where>
|
||||
<if test="dto.templateName != null and dto.templateName != ''">
|
||||
template_name like CONCAT('%',#{dto.templateName},'%')
|
||||
</if>
|
||||
<if test="dto.subject != null and dto.subject != ''">
|
||||
subject like CONCAT('%',#{dto.subject},'%')
|
||||
</if>
|
||||
<if test="dto.body != null and dto.body != ''">
|
||||
body like CONCAT('%',#{dto.body},'%')
|
||||
</if>
|
||||
<if test="dto.type != null and dto.type != ''">
|
||||
type like CONCAT('%',#{dto.type},'%')
|
||||
</if>
|
||||
<if test="dto.templateName != null and dto.templateName != ''">
|
||||
and template_name like CONCAT('%',#{dto.templateName},'%')
|
||||
</if>
|
||||
<if test="dto.subject != null and dto.subject != ''">
|
||||
and subject like CONCAT('%',#{dto.subject},'%')
|
||||
</if>
|
||||
<if test="dto.body != null and dto.body != ''">
|
||||
and body like CONCAT('%',#{dto.body},'%')
|
||||
</if>
|
||||
<if test="dto.type != null and dto.type != ''">
|
||||
and type like CONCAT('%',#{dto.type},'%')
|
||||
</if>
|
||||
</where>
|
||||
order by update_time desc
|
||||
</select>
|
||||
|
|
|
@ -31,22 +31,22 @@
|
|||
from sys_email_users
|
||||
<where>
|
||||
<if test="dto.email != null and dto.email != ''">
|
||||
email like CONCAT('%',#{dto.email},'%')
|
||||
and email like CONCAT('%',#{dto.email},'%')
|
||||
</if>
|
||||
<if test="dto.emailTemplate != null and dto.emailTemplate != ''">
|
||||
email_template like CONCAT('%',#{dto.emailTemplate},'%')
|
||||
and email_template like CONCAT('%',#{dto.emailTemplate},'%')
|
||||
</if>
|
||||
<if test="dto.host != null and dto.host != ''">
|
||||
host like CONCAT('%',#{dto.host},'%')
|
||||
and host like CONCAT('%',#{dto.host},'%')
|
||||
</if>
|
||||
<if test="dto.port != null and dto.port != ''">
|
||||
port like CONCAT('%',#{dto.port},'%')
|
||||
and port like CONCAT('%',#{dto.port},'%')
|
||||
</if>
|
||||
<if test="dto.smtpAgreement != null and dto.smtpAgreement != ''">
|
||||
smtp_agreement like CONCAT('%',#{dto.smtpAgreement},'%')
|
||||
and smtp_agreement like CONCAT('%',#{dto.smtpAgreement},'%')
|
||||
</if>
|
||||
</where>
|
||||
order by update_time desc
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<!-- 物理删除邮箱用户发送配置 -->
|
||||
|
|
|
@ -24,21 +24,22 @@
|
|||
|
||||
<!-- 分页查询系统文件表内容 -->
|
||||
<select id="selectListByPage" resultType="cn.bunny.dao.entity.system.Files">
|
||||
select <include refid="Base_Column_List"/>
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from sys_files
|
||||
<where>
|
||||
<if test="dto.filename != null and dto.filename != ''">
|
||||
filename like CONCAT('%',#{dto.filename},'%')
|
||||
</if>
|
||||
<if test="dto.filepath != null and dto.filepath != ''">
|
||||
filepath like CONCAT('%',#{dto.filepath},'%')
|
||||
</if>
|
||||
<if test="dto.fileType != null and dto.fileType != ''">
|
||||
file_type like CONCAT('%',#{dto.fileType},'%')
|
||||
</if>
|
||||
<if test="dto.downloadCount != null and dto.downloadCount != ''">
|
||||
download_count like CONCAT('%',#{dto.downloadCount},'%')
|
||||
</if>
|
||||
<if test="dto.filename != null and dto.filename != ''">
|
||||
and filename like CONCAT('%',#{dto.filename},'%')
|
||||
</if>
|
||||
<if test="dto.filepath != null and dto.filepath != ''">
|
||||
and filepath like CONCAT('%',#{dto.filepath},'%')
|
||||
</if>
|
||||
<if test="dto.fileType != null and dto.fileType != ''">
|
||||
and file_type like CONCAT('%',#{dto.fileType},'%')
|
||||
</if>
|
||||
<if test="dto.downloadCount != null and dto.downloadCount != ''">
|
||||
and download_count like CONCAT('%',#{dto.downloadCount},'%')
|
||||
</if>
|
||||
</where>
|
||||
order by update_time
|
||||
</select>
|
||||
|
|
|
@ -37,13 +37,13 @@
|
|||
from sys_i18n
|
||||
<where>
|
||||
<if test="dto.keyName != null and dto.keyName != ''">
|
||||
key_name like CONCAT('%',#{dto.keyName},'%')
|
||||
and key_name like CONCAT('%',#{dto.keyName},'%')
|
||||
</if>
|
||||
<if test="dto.translation != null and dto.translation != ''">
|
||||
translation like CONCAT('%',#{dto.translation},'%')
|
||||
and translation like CONCAT('%',#{dto.translation},'%')
|
||||
</if>
|
||||
<if test="dto.typeName != null and dto.typeName != ''">
|
||||
type_name like CONCAT('%',#{dto.typeName},'%')
|
||||
and type_name like CONCAT('%',#{dto.typeName},'%')
|
||||
</if>
|
||||
</where>
|
||||
order by update_time
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
from sys_menu_icon
|
||||
<where>
|
||||
<if test="dto.iconCode != null and dto.iconCode != ''">
|
||||
icon_code like CONCAT('%',#{dto.iconCode},'%')
|
||||
and icon_code like CONCAT('%',#{dto.iconCode},'%')
|
||||
</if>
|
||||
<if test="dto.iconName != null and dto.iconName != ''">
|
||||
icon_name like CONCAT('%',#{dto.iconName},'%')
|
||||
and icon_name like CONCAT('%',#{dto.iconName},'%')
|
||||
</if>
|
||||
</where>
|
||||
order by update_time desc
|
||||
|
|
|
@ -28,13 +28,13 @@
|
|||
from sys_power
|
||||
<where>
|
||||
<if test="dto.powerCode != null and dto.powerCode != ''">
|
||||
power_code like CONCAT('%',#{dto.powerCode},'%')
|
||||
and power_code like CONCAT('%',#{dto.powerCode},'%')
|
||||
</if>
|
||||
<if test="dto.powerName != null and dto.powerName != ''">
|
||||
power_name like CONCAT('%',#{dto.powerName},'%')
|
||||
and power_name like CONCAT('%',#{dto.powerName},'%')
|
||||
</if>
|
||||
<if test="dto.requestUrl != null and dto.requestUrl != ''">
|
||||
request_url like CONCAT('%',#{dto.requestUrl},'%')
|
||||
and request_url like CONCAT('%',#{dto.requestUrl},'%')
|
||||
</if>
|
||||
</where>
|
||||
order by update_time desc
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
from sys_role
|
||||
<where>
|
||||
<if test="dto.roleCode != null and dto.roleCode != ''">
|
||||
role_code like CONCAT('%',#{dto.roleCode},'%')
|
||||
and role_code like CONCAT('%',#{dto.roleCode},'%')
|
||||
</if>
|
||||
<if test="dto.description != null and dto.description != ''">
|
||||
description like CONCAT('%',#{dto.description},'%')
|
||||
and description like CONCAT('%',#{dto.description},'%')
|
||||
</if>
|
||||
</where>
|
||||
order by update_time
|
||||
|
|
|
@ -70,10 +70,10 @@
|
|||
from sys_router
|
||||
<where>
|
||||
<if test="dto.title != null and dto.title != ''">
|
||||
title like CONCAT('%',#{dto.title},'%')
|
||||
and title like CONCAT('%',#{dto.title},'%')
|
||||
</if>
|
||||
<if test="dto.visible != null">
|
||||
visible = #{dto.visible}
|
||||
and visible = #{dto.visible}
|
||||
</if>
|
||||
</where>
|
||||
order by router_rank
|
||||
|
|
|
@ -35,28 +35,28 @@
|
|||
from sys_user user left join sys_user_dept user_dept on user.id = user_dept.user_id
|
||||
<where>
|
||||
<if test="dto.username != null and dto.username != ''">
|
||||
username like CONCAT('%',#{dto.username},'%')
|
||||
and username like CONCAT('%',#{dto.username},'%')
|
||||
</if>
|
||||
<if test="dto.nickName != null and dto.nickName != ''">
|
||||
nick_name like CONCAT('%',#{dto.nickName},'%')
|
||||
and nick_name like CONCAT('%',#{dto.nickName},'%')
|
||||
</if>
|
||||
<if test="dto.email != null and dto.email != ''">
|
||||
email like CONCAT('%',#{dto.email},'%')
|
||||
and email like CONCAT('%',#{dto.email},'%')
|
||||
</if>
|
||||
<if test="dto.phone != null and dto.phone != ''">
|
||||
phone like CONCAT('%',#{dto.phone},'%')
|
||||
and phone like CONCAT('%',#{dto.phone},'%')
|
||||
</if>
|
||||
<if test="dto.sex != null and dto.sex != ''">
|
||||
sex = #{dto.sex}
|
||||
and sex = #{dto.sex}
|
||||
</if>
|
||||
<if test="dto.summary != null and dto.summary != ''">
|
||||
summary like CONCAT('%',#{dto.summary},'%')
|
||||
and summary like CONCAT('%',#{dto.summary},'%')
|
||||
</if>
|
||||
<if test="dto.status != null and dto.status != ''">
|
||||
status = #{dto.status}
|
||||
and status = #{dto.status}
|
||||
</if>
|
||||
<if test="dto.deptIds != null and dto.deptIds.size() > 0">
|
||||
user_dept.dept_id in
|
||||
and user_dept.dept_id in
|
||||
<foreach collection="dto.deptIds" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package cn.bunny.service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
class Solution {
|
||||
public int longestConsecutive(int[] nums) {
|
||||
if (nums.length == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Set<Integer> numSet = new HashSet<>();
|
||||
for (int num : nums) {
|
||||
numSet.add(num);
|
||||
}
|
||||
|
||||
int longestStreak = 0;
|
||||
|
||||
for (int num : numSet) {
|
||||
if (!numSet.contains(num - 1)) {
|
||||
int currentStreak = 1;
|
||||
|
||||
while (numSet.contains(num + 1)) {
|
||||
num++;
|
||||
currentStreak++;
|
||||
}
|
||||
|
||||
// 更新最长连续序列长度
|
||||
longestStreak = Math.max(longestStreak, currentStreak);
|
||||
}
|
||||
}
|
||||
|
||||
return longestStreak;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue