user
This commit is contained in:
@@ -29,7 +29,7 @@ public class BaseQuery<T> {
|
|||||||
|
|
||||||
private String sort;
|
private String sort;
|
||||||
|
|
||||||
public QueryWrapper<T> convertQ(){
|
public QueryWrapper<T> build(){
|
||||||
QueryWrapper<T> wrapper = new QueryWrapper<>();
|
QueryWrapper<T> wrapper = new QueryWrapper<>();
|
||||||
JSONObject json = (JSONObject)JSONObject.toJSON(this);
|
JSONObject json = (JSONObject)JSONObject.toJSON(this);
|
||||||
json.forEach(new BiConsumer<String, Object>() {
|
json.forEach(new BiConsumer<String, Object>() {
|
||||||
|
|||||||
@@ -1,470 +1,470 @@
|
|||||||
package org.nl.common.utils.email;
|
//package org.nl.common.utils.email;
|
||||||
|
//
|
||||||
import cn.hutool.core.collection.CollUtil;
|
//import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
//import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
//import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.CharUtil;
|
//import cn.hutool.core.util.CharUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
//import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.mail.Mail;
|
//import cn.hutool.extra.mail.Mail;
|
||||||
import cn.hutool.extra.mail.MailAccount;
|
//import cn.hutool.extra.mail.MailAccount;
|
||||||
import cn.hutool.extra.mail.UserPassAuthenticator;
|
//import cn.hutool.extra.mail.UserPassAuthenticator;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
//import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
//import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
import lombok.AccessLevel;
|
//import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
//import lombok.NoArgsConstructor;
|
||||||
|
//
|
||||||
import javax.mail.Authenticator;
|
//import javax.mail.Authenticator;
|
||||||
import javax.mail.Session;
|
//import javax.mail.Session;
|
||||||
import java.io.File;
|
//import java.io.File;
|
||||||
import java.io.InputStream;
|
//import java.io.InputStream;
|
||||||
import java.util.Collection;
|
//import java.util.Collection;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 邮件工具类
|
// * 邮件工具类
|
||||||
*/
|
// */
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
//@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class MailUtils {
|
//public class MailUtils {
|
||||||
|
//
|
||||||
private static final MailAccount ACCOUNT = SpringUtils.getBean(MailAccount.class);
|
// private static final MailAccount ACCOUNT = SpringUtils.getBean(MailAccount.class);
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 获取邮件发送实例
|
// * 获取邮件发送实例
|
||||||
*/
|
// */
|
||||||
public static MailAccount getMailAccount() {
|
// public static MailAccount getMailAccount() {
|
||||||
return ACCOUNT;
|
// return ACCOUNT;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 获取邮件发送实例 (自定义发送人以及授权码)
|
// * 获取邮件发送实例 (自定义发送人以及授权码)
|
||||||
*
|
// *
|
||||||
* @param user 发送人
|
// * @param user 发送人
|
||||||
* @param pass 授权码
|
// * @param pass 授权码
|
||||||
*/
|
// */
|
||||||
public static MailAccount getMailAccount(String from, String user, String pass) {
|
// public static MailAccount getMailAccount(String from, String user, String pass) {
|
||||||
ACCOUNT.setFrom(StringUtils.blankToDefault(from, ACCOUNT.getFrom()));
|
// ACCOUNT.setFrom(StringUtils.blankToDefault(from, ACCOUNT.getFrom()));
|
||||||
ACCOUNT.setUser(StringUtils.blankToDefault(user, ACCOUNT.getUser()));
|
// ACCOUNT.setUser(StringUtils.blankToDefault(user, ACCOUNT.getUser()));
|
||||||
ACCOUNT.setPass(StringUtils.blankToDefault(pass, ACCOUNT.getPass()));
|
// ACCOUNT.setPass(StringUtils.blankToDefault(pass, ACCOUNT.getPass()));
|
||||||
return ACCOUNT;
|
// return ACCOUNT;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送文本邮件,发送给单个或多个收件人<br>
|
// * 使用配置文件中设置的账户发送文本邮件,发送给单个或多个收件人<br>
|
||||||
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
// * 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
*
|
// *
|
||||||
* @param to 收件人
|
// * @param to 收件人
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 3.2.0
|
// * @since 3.2.0
|
||||||
*/
|
// */
|
||||||
public static String sendText(String to, String subject, String content, File... files) {
|
// public static String sendText(String to, String subject, String content, File... files) {
|
||||||
return send(to, subject, content, false, files);
|
// return send(to, subject, content, false, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送HTML邮件,发送给单个或多个收件人<br>
|
// * 使用配置文件中设置的账户发送HTML邮件,发送给单个或多个收件人<br>
|
||||||
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
// * 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
*
|
// *
|
||||||
* @param to 收件人
|
// * @param to 收件人
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 3.2.0
|
// * @since 3.2.0
|
||||||
*/
|
// */
|
||||||
public static String sendHtml(String to, String subject, String content, File... files) {
|
// public static String sendHtml(String to, String subject, String content, File... files) {
|
||||||
return send(to, subject, content, true, files);
|
// return send(to, subject, content, true, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
|
// * 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
|
||||||
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
// * 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
*
|
// *
|
||||||
* @param to 收件人
|
// * @param to 收件人
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param isHtml 是否为HTML
|
// * @param isHtml 是否为HTML
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
*/
|
// */
|
||||||
public static String send(String to, String subject, String content, boolean isHtml, File... files) {
|
// public static String send(String to, String subject, String content, boolean isHtml, File... files) {
|
||||||
return send(splitAddress(to), subject, content, isHtml, files);
|
// return send(splitAddress(to), subject, content, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
|
// * 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
|
||||||
* 多个收件人、抄送人、密送人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
// * 多个收件人、抄送人、密送人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
*
|
// *
|
||||||
* @param to 收件人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
// * @param to 收件人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
* @param cc 抄送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
// * @param cc 抄送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
* @param bcc 密送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
// * @param bcc 密送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param isHtml 是否为HTML
|
// * @param isHtml 是否为HTML
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 4.0.3
|
// * @since 4.0.3
|
||||||
*/
|
// */
|
||||||
public static String send(String to, String cc, String bcc, String subject, String content, boolean isHtml, File... files) {
|
// public static String send(String to, String cc, String bcc, String subject, String content, boolean isHtml, File... files) {
|
||||||
return send(splitAddress(to), splitAddress(cc), splitAddress(bcc), subject, content, isHtml, files);
|
// return send(splitAddress(to), splitAddress(cc), splitAddress(bcc), subject, content, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送文本邮件,发送给多人
|
// * 使用配置文件中设置的账户发送文本邮件,发送给多人
|
||||||
*
|
// *
|
||||||
* @param tos 收件人列表
|
// * @param tos 收件人列表
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
*/
|
// */
|
||||||
public static String sendText(Collection<String> tos, String subject, String content, File... files) {
|
// public static String sendText(Collection<String> tos, String subject, String content, File... files) {
|
||||||
return send(tos, subject, content, false, files);
|
// return send(tos, subject, content, false, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送HTML邮件,发送给多人
|
// * 使用配置文件中设置的账户发送HTML邮件,发送给多人
|
||||||
*
|
// *
|
||||||
* @param tos 收件人列表
|
// * @param tos 收件人列表
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 3.2.0
|
// * @since 3.2.0
|
||||||
*/
|
// */
|
||||||
public static String sendHtml(Collection<String> tos, String subject, String content, File... files) {
|
// public static String sendHtml(Collection<String> tos, String subject, String content, File... files) {
|
||||||
return send(tos, subject, content, true, files);
|
// return send(tos, subject, content, true, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送邮件,发送给多人
|
// * 使用配置文件中设置的账户发送邮件,发送给多人
|
||||||
*
|
// *
|
||||||
* @param tos 收件人列表
|
// * @param tos 收件人列表
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param isHtml 是否为HTML
|
// * @param isHtml 是否为HTML
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
*/
|
// */
|
||||||
public static String send(Collection<String> tos, String subject, String content, boolean isHtml, File... files) {
|
// public static String send(Collection<String> tos, String subject, String content, boolean isHtml, File... files) {
|
||||||
return send(tos, null, null, subject, content, isHtml, files);
|
// return send(tos, null, null, subject, content, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送邮件,发送给多人
|
// * 使用配置文件中设置的账户发送邮件,发送给多人
|
||||||
*
|
// *
|
||||||
* @param tos 收件人列表
|
// * @param tos 收件人列表
|
||||||
* @param ccs 抄送人列表,可以为null或空
|
// * @param ccs 抄送人列表,可以为null或空
|
||||||
* @param bccs 密送人列表,可以为null或空
|
// * @param bccs 密送人列表,可以为null或空
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param isHtml 是否为HTML
|
// * @param isHtml 是否为HTML
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 4.0.3
|
// * @since 4.0.3
|
||||||
*/
|
// */
|
||||||
public static String send(Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, boolean isHtml, File... files) {
|
// public static String send(Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, boolean isHtml, File... files) {
|
||||||
return send(getMailAccount(), true, tos, ccs, bccs, subject, content, null, isHtml, files);
|
// return send(getMailAccount(), true, tos, ccs, bccs, subject, content, null, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// ------------------------------------------------------------------------------------------------------------------------------- Custom MailAccount
|
// // ------------------------------------------------------------------------------------------------------------------------------- Custom MailAccount
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 发送邮件给多人
|
// * 发送邮件给多人
|
||||||
*
|
// *
|
||||||
* @param mailAccount 邮件认证对象
|
// * @param mailAccount 邮件认证对象
|
||||||
* @param to 收件人,多个收件人逗号或者分号隔开
|
// * @param to 收件人,多个收件人逗号或者分号隔开
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param isHtml 是否为HTML格式
|
// * @param isHtml 是否为HTML格式
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 3.2.0
|
// * @since 3.2.0
|
||||||
*/
|
// */
|
||||||
public static String send(MailAccount mailAccount, String to, String subject, String content, boolean isHtml, File... files) {
|
// public static String send(MailAccount mailAccount, String to, String subject, String content, boolean isHtml, File... files) {
|
||||||
return send(mailAccount, splitAddress(to), subject, content, isHtml, files);
|
// return send(mailAccount, splitAddress(to), subject, content, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 发送邮件给多人
|
// * 发送邮件给多人
|
||||||
*
|
// *
|
||||||
* @param mailAccount 邮件帐户信息
|
// * @param mailAccount 邮件帐户信息
|
||||||
* @param tos 收件人列表
|
// * @param tos 收件人列表
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param isHtml 是否为HTML格式
|
// * @param isHtml 是否为HTML格式
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
*/
|
// */
|
||||||
public static String send(MailAccount mailAccount, Collection<String> tos, String subject, String content, boolean isHtml, File... files) {
|
// public static String send(MailAccount mailAccount, Collection<String> tos, String subject, String content, boolean isHtml, File... files) {
|
||||||
return send(mailAccount, tos, null, null, subject, content, isHtml, files);
|
// return send(mailAccount, tos, null, null, subject, content, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 发送邮件给多人
|
// * 发送邮件给多人
|
||||||
*
|
// *
|
||||||
* @param mailAccount 邮件帐户信息
|
// * @param mailAccount 邮件帐户信息
|
||||||
* @param tos 收件人列表
|
// * @param tos 收件人列表
|
||||||
* @param ccs 抄送人列表,可以为null或空
|
// * @param ccs 抄送人列表,可以为null或空
|
||||||
* @param bccs 密送人列表,可以为null或空
|
// * @param bccs 密送人列表,可以为null或空
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param isHtml 是否为HTML格式
|
// * @param isHtml 是否为HTML格式
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 4.0.3
|
// * @since 4.0.3
|
||||||
*/
|
// */
|
||||||
public static String send(MailAccount mailAccount, Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, boolean isHtml, File... files) {
|
// public static String send(MailAccount mailAccount, Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, boolean isHtml, File... files) {
|
||||||
return send(mailAccount, false, tos, ccs, bccs, subject, content, null, isHtml, files);
|
// return send(mailAccount, false, tos, ccs, bccs, subject, content, null, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送HTML邮件,发送给单个或多个收件人<br>
|
// * 使用配置文件中设置的账户发送HTML邮件,发送给单个或多个收件人<br>
|
||||||
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
// * 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
*
|
// *
|
||||||
* @param to 收件人
|
// * @param to 收件人
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
// * @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 3.2.0
|
// * @since 3.2.0
|
||||||
*/
|
// */
|
||||||
public static String sendHtml(String to, String subject, String content, Map<String, InputStream> imageMap, File... files) {
|
// public static String sendHtml(String to, String subject, String content, Map<String, InputStream> imageMap, File... files) {
|
||||||
return send(to, subject, content, imageMap, true, files);
|
// return send(to, subject, content, imageMap, true, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
|
// * 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
|
||||||
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
// * 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
*
|
// *
|
||||||
* @param to 收件人
|
// * @param to 收件人
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
// * @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
* @param isHtml 是否为HTML
|
// * @param isHtml 是否为HTML
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
*/
|
// */
|
||||||
public static String send(String to, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
// public static String send(String to, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
return send(splitAddress(to), subject, content, imageMap, isHtml, files);
|
// return send(splitAddress(to), subject, content, imageMap, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
|
// * 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
|
||||||
* 多个收件人、抄送人、密送人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
// * 多个收件人、抄送人、密送人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
*
|
// *
|
||||||
* @param to 收件人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
// * @param to 收件人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
* @param cc 抄送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
// * @param cc 抄送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
* @param bcc 密送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
// * @param bcc 密送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
// * @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
* @param isHtml 是否为HTML
|
// * @param isHtml 是否为HTML
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 4.0.3
|
// * @since 4.0.3
|
||||||
*/
|
// */
|
||||||
public static String send(String to, String cc, String bcc, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
// public static String send(String to, String cc, String bcc, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
return send(splitAddress(to), splitAddress(cc), splitAddress(bcc), subject, content, imageMap, isHtml, files);
|
// return send(splitAddress(to), splitAddress(cc), splitAddress(bcc), subject, content, imageMap, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送HTML邮件,发送给多人
|
// * 使用配置文件中设置的账户发送HTML邮件,发送给多人
|
||||||
*
|
// *
|
||||||
* @param tos 收件人列表
|
// * @param tos 收件人列表
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
// * @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 3.2.0
|
// * @since 3.2.0
|
||||||
*/
|
// */
|
||||||
public static String sendHtml(Collection<String> tos, String subject, String content, Map<String, InputStream> imageMap, File... files) {
|
// public static String sendHtml(Collection<String> tos, String subject, String content, Map<String, InputStream> imageMap, File... files) {
|
||||||
return send(tos, subject, content, imageMap, true, files);
|
// return send(tos, subject, content, imageMap, true, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送邮件,发送给多人
|
// * 使用配置文件中设置的账户发送邮件,发送给多人
|
||||||
*
|
// *
|
||||||
* @param tos 收件人列表
|
// * @param tos 收件人列表
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
// * @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
* @param isHtml 是否为HTML
|
// * @param isHtml 是否为HTML
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
*/
|
// */
|
||||||
public static String send(Collection<String> tos, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
// public static String send(Collection<String> tos, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
return send(tos, null, null, subject, content, imageMap, isHtml, files);
|
// return send(tos, null, null, subject, content, imageMap, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 使用配置文件中设置的账户发送邮件,发送给多人
|
// * 使用配置文件中设置的账户发送邮件,发送给多人
|
||||||
*
|
// *
|
||||||
* @param tos 收件人列表
|
// * @param tos 收件人列表
|
||||||
* @param ccs 抄送人列表,可以为null或空
|
// * @param ccs 抄送人列表,可以为null或空
|
||||||
* @param bccs 密送人列表,可以为null或空
|
// * @param bccs 密送人列表,可以为null或空
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
// * @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
* @param isHtml 是否为HTML
|
// * @param isHtml 是否为HTML
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 4.0.3
|
// * @since 4.0.3
|
||||||
*/
|
// */
|
||||||
public static String send(Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
// public static String send(Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
return send(getMailAccount(), true, tos, ccs, bccs, subject, content, imageMap, isHtml, files);
|
// return send(getMailAccount(), true, tos, ccs, bccs, subject, content, imageMap, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// ------------------------------------------------------------------------------------------------------------------------------- Custom MailAccount
|
// // ------------------------------------------------------------------------------------------------------------------------------- Custom MailAccount
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 发送邮件给多人
|
// * 发送邮件给多人
|
||||||
*
|
// *
|
||||||
* @param mailAccount 邮件认证对象
|
// * @param mailAccount 邮件认证对象
|
||||||
* @param to 收件人,多个收件人逗号或者分号隔开
|
// * @param to 收件人,多个收件人逗号或者分号隔开
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
// * @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
* @param isHtml 是否为HTML格式
|
// * @param isHtml 是否为HTML格式
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 3.2.0
|
// * @since 3.2.0
|
||||||
*/
|
// */
|
||||||
public static String send(MailAccount mailAccount, String to, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
// public static String send(MailAccount mailAccount, String to, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
return send(mailAccount, splitAddress(to), subject, content, imageMap, isHtml, files);
|
// return send(mailAccount, splitAddress(to), subject, content, imageMap, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 发送邮件给多人
|
// * 发送邮件给多人
|
||||||
*
|
// *
|
||||||
* @param mailAccount 邮件帐户信息
|
// * @param mailAccount 邮件帐户信息
|
||||||
* @param tos 收件人列表
|
// * @param tos 收件人列表
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
// * @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
* @param isHtml 是否为HTML格式
|
// * @param isHtml 是否为HTML格式
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 4.6.3
|
// * @since 4.6.3
|
||||||
*/
|
// */
|
||||||
public static String send(MailAccount mailAccount, Collection<String> tos, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
// public static String send(MailAccount mailAccount, Collection<String> tos, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
return send(mailAccount, tos, null, null, subject, content, imageMap, isHtml, files);
|
// return send(mailAccount, tos, null, null, subject, content, imageMap, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 发送邮件给多人
|
// * 发送邮件给多人
|
||||||
*
|
// *
|
||||||
* @param mailAccount 邮件帐户信息
|
// * @param mailAccount 邮件帐户信息
|
||||||
* @param tos 收件人列表
|
// * @param tos 收件人列表
|
||||||
* @param ccs 抄送人列表,可以为null或空
|
// * @param ccs 抄送人列表,可以为null或空
|
||||||
* @param bccs 密送人列表,可以为null或空
|
// * @param bccs 密送人列表,可以为null或空
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
// * @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
* @param isHtml 是否为HTML格式
|
// * @param isHtml 是否为HTML格式
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 4.6.3
|
// * @since 4.6.3
|
||||||
*/
|
// */
|
||||||
public static String send(MailAccount mailAccount, Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, Map<String, InputStream> imageMap,
|
// public static String send(MailAccount mailAccount, Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, Map<String, InputStream> imageMap,
|
||||||
boolean isHtml, File... files) {
|
// boolean isHtml, File... files) {
|
||||||
return send(mailAccount, false, tos, ccs, bccs, subject, content, imageMap, isHtml, files);
|
// return send(mailAccount, false, tos, ccs, bccs, subject, content, imageMap, isHtml, files);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 根据配置文件,获取邮件客户端会话
|
// * 根据配置文件,获取邮件客户端会话
|
||||||
*
|
// *
|
||||||
* @param mailAccount 邮件账户配置
|
// * @param mailAccount 邮件账户配置
|
||||||
* @param isSingleton 是否单例(全局共享会话)
|
// * @param isSingleton 是否单例(全局共享会话)
|
||||||
* @return {@link Session}
|
// * @return {@link Session}
|
||||||
* @since 5.5.7
|
// * @since 5.5.7
|
||||||
*/
|
// */
|
||||||
public static Session getSession(MailAccount mailAccount, boolean isSingleton) {
|
// public static Session getSession(MailAccount mailAccount, boolean isSingleton) {
|
||||||
Authenticator authenticator = null;
|
// Authenticator authenticator = null;
|
||||||
if (mailAccount.isAuth()) {
|
// if (mailAccount.isAuth()) {
|
||||||
authenticator = new UserPassAuthenticator(mailAccount.getUser(), mailAccount.getPass());
|
// authenticator = new UserPassAuthenticator(mailAccount.getUser(), mailAccount.getPass());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return isSingleton ? Session.getDefaultInstance(mailAccount.getSmtpProps(), authenticator) //
|
// return isSingleton ? Session.getDefaultInstance(mailAccount.getSmtpProps(), authenticator) //
|
||||||
: Session.getInstance(mailAccount.getSmtpProps(), authenticator);
|
// : Session.getInstance(mailAccount.getSmtpProps(), authenticator);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// ------------------------------------------------------------------------------------------------------------------------ Private method start
|
// // ------------------------------------------------------------------------------------------------------------------------ Private method start
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 发送邮件给多人
|
// * 发送邮件给多人
|
||||||
*
|
// *
|
||||||
* @param mailAccount 邮件帐户信息
|
// * @param mailAccount 邮件帐户信息
|
||||||
* @param useGlobalSession 是否全局共享Session
|
// * @param useGlobalSession 是否全局共享Session
|
||||||
* @param tos 收件人列表
|
// * @param tos 收件人列表
|
||||||
* @param ccs 抄送人列表,可以为null或空
|
// * @param ccs 抄送人列表,可以为null或空
|
||||||
* @param bccs 密送人列表,可以为null或空
|
// * @param bccs 密送人列表,可以为null或空
|
||||||
* @param subject 标题
|
// * @param subject 标题
|
||||||
* @param content 正文
|
// * @param content 正文
|
||||||
* @param imageMap 图片与占位符,占位符格式为cid:${cid}
|
// * @param imageMap 图片与占位符,占位符格式为cid:${cid}
|
||||||
* @param isHtml 是否为HTML格式
|
// * @param isHtml 是否为HTML格式
|
||||||
* @param files 附件列表
|
// * @param files 附件列表
|
||||||
* @return message-id
|
// * @return message-id
|
||||||
* @since 4.6.3
|
// * @since 4.6.3
|
||||||
*/
|
// */
|
||||||
private static String send(MailAccount mailAccount, boolean useGlobalSession, Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content,
|
// private static String send(MailAccount mailAccount, boolean useGlobalSession, Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content,
|
||||||
Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
// Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
final Mail mail = Mail.create(mailAccount).setUseGlobalSession(useGlobalSession);
|
// final Mail mail = Mail.create(mailAccount).setUseGlobalSession(useGlobalSession);
|
||||||
|
//
|
||||||
// 可选抄送人
|
// // 可选抄送人
|
||||||
if (CollUtil.isNotEmpty(ccs)) {
|
// if (CollUtil.isNotEmpty(ccs)) {
|
||||||
mail.setCcs(ccs.toArray(new String[0]));
|
// mail.setCcs(ccs.toArray(new String[0]));
|
||||||
}
|
// }
|
||||||
// 可选密送人
|
// // 可选密送人
|
||||||
if (CollUtil.isNotEmpty(bccs)) {
|
// if (CollUtil.isNotEmpty(bccs)) {
|
||||||
mail.setBccs(bccs.toArray(new String[0]));
|
// mail.setBccs(bccs.toArray(new String[0]));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
mail.setTos(tos.toArray(new String[0]));
|
// mail.setTos(tos.toArray(new String[0]));
|
||||||
mail.setTitle(subject);
|
// mail.setTitle(subject);
|
||||||
mail.setContent(content);
|
// mail.setContent(content);
|
||||||
mail.setHtml(isHtml);
|
// mail.setHtml(isHtml);
|
||||||
mail.setFiles(files);
|
// mail.setFiles(files);
|
||||||
|
//
|
||||||
// 图片
|
// // 图片
|
||||||
if (MapUtil.isNotEmpty(imageMap)) {
|
// if (MapUtil.isNotEmpty(imageMap)) {
|
||||||
for (Map.Entry<String, InputStream> entry : imageMap.entrySet()) {
|
// for (Map.Entry<String, InputStream> entry : imageMap.entrySet()) {
|
||||||
mail.addImage(entry.getKey(), entry.getValue());
|
// mail.addImage(entry.getKey(), entry.getValue());
|
||||||
// 关闭流
|
// // 关闭流
|
||||||
IoUtil.close(entry.getValue());
|
// IoUtil.close(entry.getValue());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return mail.send();
|
// return mail.send();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 将多个联系人转为列表,分隔符为逗号或者分号
|
// * 将多个联系人转为列表,分隔符为逗号或者分号
|
||||||
*
|
// *
|
||||||
* @param addresses 多个联系人,如果为空返回null
|
// * @param addresses 多个联系人,如果为空返回null
|
||||||
* @return 联系人列表
|
// * @return 联系人列表
|
||||||
*/
|
// */
|
||||||
private static List<String> splitAddress(String addresses) {
|
// private static List<String> splitAddress(String addresses) {
|
||||||
if (StrUtil.isBlank(addresses)) {
|
// if (StrUtil.isBlank(addresses)) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
List<String> result;
|
// List<String> result;
|
||||||
if (StrUtil.contains(addresses, CharUtil.COMMA)) {
|
// if (StrUtil.contains(addresses, CharUtil.COMMA)) {
|
||||||
result = StrUtil.splitTrim(addresses, CharUtil.COMMA);
|
// result = StrUtil.splitTrim(addresses, CharUtil.COMMA);
|
||||||
} else if (StrUtil.contains(addresses, ';')) {
|
// } else if (StrUtil.contains(addresses, ';')) {
|
||||||
result = StrUtil.splitTrim(addresses, ';');
|
// result = StrUtil.splitTrim(addresses, ';');
|
||||||
} else {
|
// } else {
|
||||||
result = CollUtil.newArrayList(addresses);
|
// result = CollUtil.newArrayList(addresses);
|
||||||
}
|
// }
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
// ------------------------------------------------------------------------------------------------------------------------ Private method end
|
// // ------------------------------------------------------------------------------------------------------------------------ Private method end
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -26,21 +26,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.catalina.User;
|
||||||
import org.nl.common.domain.PageQuery;
|
import org.nl.common.domain.PageQuery;
|
||||||
import org.nl.modules.common.config.RsaProperties;
|
import org.nl.modules.common.config.RsaProperties;
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
import org.nl.modules.common.utils.RedisUtils;
|
|
||||||
import org.nl.modules.common.utils.RsaUtils;
|
import org.nl.modules.common.utils.RsaUtils;
|
||||||
import org.nl.modules.common.utils.SecurityUtils;
|
import org.nl.modules.common.utils.SecurityUtils;
|
||||||
import org.nl.modules.logging.annotation.Log;
|
import org.nl.modules.logging.annotation.Log;
|
||||||
import org.nl.modules.system.service.dto.UserQueryCriteria;
|
|
||||||
import org.nl.system.service.user.ISysUserService;
|
import org.nl.system.service.user.ISysUserService;
|
||||||
import org.nl.system.service.user.UserService;
|
|
||||||
import org.nl.system.service.user.dao.SysUser;
|
import org.nl.system.service.user.dao.SysUser;
|
||||||
import org.nl.system.service.user.dao.User;
|
|
||||||
import org.nl.system.service.user.dto.UserQuery;
|
import org.nl.system.service.user.dto.UserQuery;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -69,7 +65,7 @@ public class UserController {
|
|||||||
@GetMapping
|
@GetMapping
|
||||||
// @SaCheckPermission("user:list")
|
// @SaCheckPermission("user:list")
|
||||||
public ResponseEntity<Object> query(UserQuery query, PageQuery page){
|
public ResponseEntity<Object> query(UserQuery query, PageQuery page){
|
||||||
Page page = userService.page(new Page<>(page.getPage(),query.getSize()),)
|
Page<SysUser> pageable = userService.page(page.build(), query.build());
|
||||||
return new ResponseEntity<>(null,HttpStatus.OK);
|
return new ResponseEntity<>(null,HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,8 +73,7 @@ public class UserController {
|
|||||||
@ApiOperation("新增用户")
|
@ApiOperation("新增用户")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
// @SaCheckPermission("user:add")
|
// @SaCheckPermission("user:add")
|
||||||
public ResponseEntity<Object> create(@Validated @RequestBody User resources){
|
public ResponseEntity<Object> create(@Validated @RequestBody SysUser resources){
|
||||||
checkLevel(resources);
|
|
||||||
// 默认密码 123456
|
// 默认密码 123456
|
||||||
if (ObjectUtil.isEmpty(resources.getPassword())) {
|
if (ObjectUtil.isEmpty(resources.getPassword())) {
|
||||||
resources.setPassword(SaSecureUtil.md5BySalt("123456", "salt"));
|
resources.setPassword(SaSecureUtil.md5BySalt("123456", "salt"));
|
||||||
@@ -93,8 +88,7 @@ public class UserController {
|
|||||||
@ApiOperation("修改用户")
|
@ApiOperation("修改用户")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
// @SaCheckPermission("user:edit")
|
// @SaCheckPermission("user:edit")
|
||||||
public ResponseEntity<Object> update( @RequestBody User resources) throws Exception {
|
public ResponseEntity<Object> update( @RequestBody SysUser resources) throws Exception {
|
||||||
checkLevel(resources);
|
|
||||||
userService.saveOrUpdate(resources);
|
userService.saveOrUpdate(resources);
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
@@ -102,7 +96,7 @@ public class UserController {
|
|||||||
@Log("修改用户:个人中心")
|
@Log("修改用户:个人中心")
|
||||||
@ApiOperation("修改用户:个人中心")
|
@ApiOperation("修改用户:个人中心")
|
||||||
// @PutMapping(value = "center")
|
// @PutMapping(value = "center")
|
||||||
public ResponseEntity<Object> center(@RequestBody User resources){
|
public ResponseEntity<Object> center(@RequestBody SysUser resources){
|
||||||
if(!resources.getUserId().equals(StpUtil.getLoginIdAsLong())){
|
if(!resources.getUserId().equals(StpUtil.getLoginIdAsLong())){
|
||||||
throw new BadRequestException("不能修改他人资料");
|
throw new BadRequestException("不能修改他人资料");
|
||||||
}
|
}
|
||||||
@@ -158,13 +152,13 @@ public class UserController {
|
|||||||
@Log("修改邮箱")
|
@Log("修改邮箱")
|
||||||
@ApiOperation("修改邮箱")
|
@ApiOperation("修改邮箱")
|
||||||
@PostMapping(value = "/updateEmail/{code}")
|
@PostMapping(value = "/updateEmail/{code}")
|
||||||
public ResponseEntity<Object> updateEmail(@PathVariable String code,@RequestBody User user) throws Exception {
|
public ResponseEntity<Object> updateEmail(@PathVariable String code,@RequestBody SysUser user) throws Exception {
|
||||||
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,user.getPassword());
|
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,user.getPassword());
|
||||||
User userInfo = userService.getOne(new QueryWrapper<User>().eq("username",SecurityUtils.getCurrentUsername()));
|
SysUser userInfo = userService.getOne(new QueryWrapper<SysUser>().eq("username",SecurityUtils.getCurrentUsername()));
|
||||||
if(!SaSecureUtil.md5BySalt(userInfo.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(password, "salt"))){
|
if(!SaSecureUtil.md5BySalt(userInfo.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(password, "salt"))){
|
||||||
throw new BadRequestException("密码错误");
|
throw new BadRequestException("密码错误");
|
||||||
}
|
}
|
||||||
userService.update(new UpdateWrapper<User>().set(userInfo.getUsername(),user.getEmail()));
|
userService.update(new UpdateWrapper<SysUser>().set(userInfo.getUsername(),user.getEmail()));
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,11 +166,5 @@ public class UserController {
|
|||||||
* 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误
|
* 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误
|
||||||
* @param resources /
|
* @param resources /
|
||||||
*/
|
*/
|
||||||
private void checkLevel(User resources) {
|
|
||||||
// Integer currentLevel = Collections.min(roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList()));
|
|
||||||
// Integer optLevel = roleService.findByRoles(resources.getRoles());
|
|
||||||
// if (currentLevel > optLevel) {
|
|
||||||
// throw new BadRequestException("角色权限不足");
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package org.nl.system.service.user;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.nl.system.service.user.dao.SysUser;
|
import org.nl.system.service.user.dao.SysUser;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -12,5 +15,6 @@ import org.nl.system.service.user.dao.SysUser;
|
|||||||
* @since 2022-12-15
|
* @since 2022-12-15
|
||||||
*/
|
*/
|
||||||
public interface ISysUserService extends IService<SysUser> {
|
public interface ISysUserService extends IService<SysUser> {
|
||||||
|
Map<String, String> updateAvatar(MultipartFile avatar);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package org.nl.system.service.user.dto;
|
package org.nl.system.service.user.dto;
|
||||||
|
|
||||||
import org.apache.catalina.User;
|
import org.nl.common.domain.BaseQuery;
|
||||||
import org.nl.common.BaseQuery;
|
import org.nl.system.service.user.dao.SysUser;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @author ZZQ
|
* @author ZZQ
|
||||||
* @Date 2022/12/15 9:53 上午
|
* @Date 2022/12/15 9:53 上午
|
||||||
*/
|
*/
|
||||||
public class UserQuery extends BaseQuery<User> {
|
public class UserQuery extends BaseQuery<SysUser> {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,22 @@
|
|||||||
package org.nl.system.service.user.impl;
|
package org.nl.system.service.user.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.nl.modules.common.config.FileProperties;
|
||||||
|
import org.nl.modules.common.utils.FileUtil;
|
||||||
|
import org.nl.modules.common.utils.SecurityUtils;
|
||||||
import org.nl.system.service.user.ISysUserService;
|
import org.nl.system.service.user.ISysUserService;
|
||||||
import org.nl.system.service.user.dao.SysUser;
|
import org.nl.system.service.user.dao.SysUser;
|
||||||
import org.nl.system.service.user.dao.mapper.SysUserMapper;
|
import org.nl.system.service.user.dao.mapper.SysUserMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -17,4 +29,22 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class ISysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
|
public class ISysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
FileProperties properties;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> updateAvatar(MultipartFile multipartFile) {
|
||||||
|
SysUser user = this.getOne(new QueryWrapper<SysUser>().eq("username", SecurityUtils.getCurrentUsername()));
|
||||||
|
String oldPath = user.getAvatarPath();
|
||||||
|
File file = FileUtil.upload(multipartFile, properties.getPath().getAvatar());
|
||||||
|
user.setAvatarPath(Objects.requireNonNull(file).getPath());
|
||||||
|
user.setAvatarName(file.getName());
|
||||||
|
this.saveOrUpdate(user);
|
||||||
|
if (StrUtil.isNotEmpty(oldPath)) {
|
||||||
|
FileUtil.del(oldPath);
|
||||||
|
}
|
||||||
|
return new HashMap<String, String>(1) {{
|
||||||
|
put("avatar", file.getName());
|
||||||
|
}};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user