parent
769baae2b7
commit
8908204792
|
|
@ -109,6 +109,7 @@ public class SystemLoginServiceImpl implements ISystemLoginService {
|
|||
throw new LoginException(ErrorEnum.FAILED.getCode(), ErrorEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
}
|
||||
String md5Pwd = ToolUtils.makePassword(password);
|
||||
System.out.println(md5Pwd);
|
||||
if (!md5Pwd.equals(sysAdmin.getPassword())) {
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getAccount(), ErrorEnum.FAILED.getMsg());
|
||||
throw new LoginException(ErrorEnum.FAILED.getCode(), ErrorEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ public class File implements Serializable {
|
|||
@ApiModelProperty("上传者id")
|
||||
private Integer sourceId;
|
||||
|
||||
@ApiModelProperty("来源类型[0-后台,1-用户]")
|
||||
private Integer source;
|
||||
|
||||
@ApiModelProperty("文件类型: [10=图片, 20=视频]")
|
||||
private Integer type;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,47 +18,30 @@ public class NoticeRecord implements Serializable {
|
|||
@ApiModelProperty("主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("场景")
|
||||
private Integer scene;
|
||||
|
||||
@ApiModelProperty("用户")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty("账号")
|
||||
private String account;
|
||||
|
||||
@ApiModelProperty("编码")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty("编码")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty("内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("错误")
|
||||
private String error;
|
||||
|
||||
@ApiModelProperty("发送类型: [1=系统, 2=短信, 3=公众号, 4=小程序]")
|
||||
private Integer sender;
|
||||
|
||||
@ApiModelProperty("接收对象: [1=用户, 2=平台]")
|
||||
private Integer receiver;
|
||||
|
||||
@ApiModelProperty("通知状态: [0=等待, 1=成功, 2=失败]")
|
||||
private Integer status;
|
||||
@ApiModelProperty("场景")
|
||||
private Integer sceneId;
|
||||
|
||||
@ApiModelProperty("已读状态: [0=未读, 1=已读]")
|
||||
private Integer isRead;
|
||||
private Integer read;
|
||||
|
||||
@ApiModelProperty("是验证码: [0=否的, 1=是的]")
|
||||
private Integer isCaptcha;
|
||||
@ApiModelProperty("通知接收对象类型;1-会员;2-商家;3-平台;4-游客(未注册用户)")
|
||||
private Integer recipient;
|
||||
|
||||
@ApiModelProperty("是否删除: [0=否,1=是]")
|
||||
private Integer isDelete;
|
||||
|
||||
@ApiModelProperty("失效时间")
|
||||
private Long expireTime;
|
||||
@ApiModelProperty("通知发送类型 1-系统通知 2-短信通知 3-微信模板 4-微信小程序")
|
||||
private Integer sendType;
|
||||
@ApiModelProperty("通知类型 1-业务通知 2-验证码")
|
||||
private Integer noticeType;
|
||||
@ApiModelProperty("其他")
|
||||
private String extra;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Long createTime;
|
||||
|
|
@ -68,5 +51,4 @@ public class NoticeRecord implements Serializable {
|
|||
|
||||
@ApiModelProperty("删除时间")
|
||||
private Long deleteTime;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
package com.mdd.common.entity.smsLog;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("短信记录实体")
|
||||
public class SmsLog implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@ApiModelProperty("主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("场景")
|
||||
private Integer sceneId;
|
||||
|
||||
@ApiModelProperty("手机号码")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty("发送内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("发送关键字(注册、找回密码)")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty("是否已验证;0-否;1-是")
|
||||
private Integer isVerify;
|
||||
|
||||
@ApiModelProperty("验证次数")
|
||||
private Integer checkNum;
|
||||
|
||||
@ApiModelProperty("发送状态:0-发送中;1-发送成功;2-发送失败")
|
||||
private Integer sendStatus;
|
||||
|
||||
@ApiModelProperty("发送时间")
|
||||
private Long sendTime;
|
||||
|
||||
@ApiModelProperty("短信结果")
|
||||
private String results;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Long createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Long updateTime;
|
||||
|
||||
@ApiModelProperty("删除时间")
|
||||
private Long deleteTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.mdd.common.enums;
|
||||
|
||||
/**
|
||||
* 相册枚举
|
||||
*/
|
||||
public enum FileEnum {
|
||||
|
||||
IMAGE_TYPE(10, "图片类型"),
|
||||
VIDEO_TYPE(20, "视频类型"),
|
||||
FILE_TYPE(30, "文件类型"),
|
||||
|
||||
// 图片来源
|
||||
SOURCE_ADMIN(0, "后台"),
|
||||
SOURCE_USER(1, "用户");
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*/
|
||||
private final int code;
|
||||
private final String msg;
|
||||
FileEnum(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态码
|
||||
*
|
||||
* @author fzr
|
||||
* @return Long
|
||||
*/
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提示
|
||||
*
|
||||
* @author fzr
|
||||
* @return String
|
||||
*/
|
||||
public String getMsg() {
|
||||
return this.msg;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
package com.mdd.common.enums;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 通知枚举类
|
||||
*/
|
||||
|
|
@ -17,10 +20,10 @@ public enum NoticeEnum {
|
|||
SENDER_MNP(3, "小程序类型"),
|
||||
SENDER_OA(4, "公众号类型"),
|
||||
|
||||
LOGIN_CODE(101, "登录验证码"),
|
||||
BIND_MOBILE_CODE(102, "绑定手机验证码"),
|
||||
CHANGE_MOBILE_CODE(103, "变更手机验证码"),
|
||||
FORGOT_PASSWORD_CODE(104, "找回登录密码验证码");
|
||||
LOGIN_CAPTCHA(101, "登录验证码"),
|
||||
BIND_MOBILE_CAPTCHA(102, "绑定手机验证码"),
|
||||
CHANGE_MOBILE_CAPTCHA(103, "变更手机验证码"),
|
||||
FIND_LOGIN_PASSWORD_CAPTCHA(104, "找回登录密码验证码");
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
|
|
@ -52,4 +55,24 @@ public enum NoticeEnum {
|
|||
return this.msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更具标记获取场景
|
||||
* @param $tag
|
||||
* @return int|string
|
||||
* @author damonyuan
|
||||
*/
|
||||
public static Integer getSceneByTag( String tag ) {
|
||||
JSONObject scene = new JSONObject();
|
||||
// 手机验证码登录
|
||||
scene.put("YZMDL", LOGIN_CAPTCHA.getCode());
|
||||
// 绑定手机号验证码
|
||||
scene.put("BDSJHM", BIND_MOBILE_CAPTCHA.getCode());
|
||||
// 变更手机号验证码
|
||||
scene.put("BGSJHM", CHANGE_MOBILE_CAPTCHA.getCode());
|
||||
// 找回登录密码
|
||||
scene.put("ZHDLMM", FIND_LOGIN_PASSWORD_CAPTCHA.getCode());
|
||||
|
||||
return scene.getInteger(tag);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package com.mdd.common.mapper.smsLog;
|
||||
|
||||
import com.mdd.common.core.basics.IBaseMapper;
|
||||
import com.mdd.common.entity.Config;
|
||||
import com.mdd.common.entity.smsLog.SmsLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 短信记录
|
||||
*/
|
||||
@Mapper
|
||||
public interface SmsLogMapper extends IBaseMapper<SmsLog> {
|
||||
}
|
||||
|
|
@ -30,9 +30,9 @@ public class NoticeCheck {
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean result = noticeRecord.getExpireTime() > (System.currentTimeMillis() / 1000);
|
||||
boolean result = noticeRecord.getCreateTime() > ((System.currentTimeMillis() / 1000) - (5 * 60)); //5分钟有效
|
||||
|
||||
noticeRecord.setIsRead(1);
|
||||
noticeRecord.setRead(1);
|
||||
noticeRecord.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
noticeRecordMapper.updateById(noticeRecord);
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ package com.mdd.common.plugin.notice;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.common.entity.notice.NoticeSetting;
|
||||
import com.mdd.common.entity.smsLog.SmsLog;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.notice.NoticeSettingMapper;
|
||||
import com.mdd.common.mapper.smsLog.SmsLogMapper;
|
||||
import com.mdd.common.plugin.notice.engine.SmsNoticeHandle;
|
||||
import com.mdd.common.plugin.notice.template.SmsTemplate;
|
||||
import com.mdd.common.plugin.notice.vo.NoticeSmsVo;
|
||||
|
|
@ -16,6 +18,7 @@ import com.mdd.common.util.StringUtils;
|
|||
public class NoticeDriver {
|
||||
|
||||
public static void handle(NoticeSmsVo noticeSmsVo) {
|
||||
System.out.println(11123);
|
||||
// 场景模板
|
||||
NoticeSettingMapper noticeSettingMapper = SpringUtils.getBean(NoticeSettingMapper.class);
|
||||
NoticeSetting noticeSetting = noticeSettingMapper.selectOne(
|
||||
|
|
@ -32,6 +35,7 @@ public class NoticeDriver {
|
|||
smsTemplate.setName(noticeSetting.getSceneName());
|
||||
smsTemplate.setType(noticeSetting.getType());
|
||||
smsTemplate.setParams(noticeSetting.getSmsNotice());
|
||||
System.out.println(1111);
|
||||
if (StringUtils.isNotNull(smsTemplate.getStatus()) && smsTemplate.getStatus().equals(1)) {
|
||||
(new SmsNoticeHandle()).send(noticeSmsVo, smsTemplate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
package com.mdd.common.plugin.notice.engine;
|
||||
|
||||
import com.mdd.common.entity.notice.NoticeRecord;
|
||||
import com.mdd.common.entity.smsLog.SmsLog;
|
||||
import com.mdd.common.enums.NoticeEnum;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.notice.NoticeRecordMapper;
|
||||
import com.mdd.common.mapper.smsLog.SmsLogMapper;
|
||||
import com.mdd.common.plugin.notice.vo.NoticeSmsVo;
|
||||
import com.mdd.common.plugin.notice.template.SmsTemplate;
|
||||
import com.mdd.common.plugin.sms.SmsDriver;
|
||||
|
|
@ -26,6 +28,7 @@ public class SmsNoticeHandle {
|
|||
* @param smsTemplate 短信模板
|
||||
*/
|
||||
public void send(NoticeSmsVo noticeSmsVo, SmsTemplate smsTemplate) {
|
||||
System.out.println("111asd");
|
||||
// 基础参数
|
||||
String mobile = noticeSmsVo.getMobile();
|
||||
Integer scene = noticeSmsVo.getScene();
|
||||
|
|
@ -45,21 +48,23 @@ public class SmsNoticeHandle {
|
|||
NoticeRecordMapper noticeRecordMapper = SpringUtils.getBean(NoticeRecordMapper.class);
|
||||
int expire = StringUtils.isNull(noticeSmsVo.getExpire()) ? 0 : noticeSmsVo.getExpire();
|
||||
NoticeRecord noticeRecord = new NoticeRecord();
|
||||
noticeRecord.setScene(scene);
|
||||
noticeRecord.setSceneId(scene);
|
||||
noticeRecord.setUserId(0);
|
||||
noticeRecord.setAccount(mobile);
|
||||
noticeRecord.setTitle(smsTemplate.getName());
|
||||
noticeRecord.setCode(params.getOrDefault("code", ""));
|
||||
noticeRecord.setContent(this.getContent(params, smsTemplate.getContent()));
|
||||
noticeRecord.setReceiver(NoticeEnum.SENDER_SMS.getCode());
|
||||
noticeRecord.setStatus(NoticeEnum.STATUS_WAIT.getCode());
|
||||
noticeRecord.setIsRead(NoticeEnum.VIEW_UNREAD.getCode());
|
||||
noticeRecord.setIsCaptcha(smsTemplate.getType().equals(2) ? 1 : 0);
|
||||
noticeRecord.setExpireTime(expire + (System.currentTimeMillis() / 1000));
|
||||
noticeRecord.setRecipient(NoticeEnum.SENDER_SMS.getCode());
|
||||
noticeRecord.setRead(NoticeEnum.VIEW_UNREAD.getCode());
|
||||
noticeRecord.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
noticeRecord.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
noticeRecordMapper.insert(noticeRecord);
|
||||
|
||||
//记录到sms log
|
||||
SmsLogMapper smsLogMapper = SpringUtils.getBean(SmsLogMapper.class);
|
||||
SmsLog smsLog = new SmsLog();
|
||||
smsLog.setSceneId(noticeSmsVo.getScene());
|
||||
smsLog.setMobile(noticeSmsVo.getMobile());
|
||||
smsLog.setContent(this.getContent(params, smsTemplate.getContent()));
|
||||
|
||||
// 消息发送
|
||||
if (StringUtils.isNotEmpty(mobile)) {
|
||||
try {
|
||||
|
|
@ -69,14 +74,30 @@ public class SmsNoticeHandle {
|
|||
.setTemplateParam(this.getSmsParams(params, smsTemplate.getContent()))
|
||||
.sendSms();
|
||||
|
||||
noticeRecord.setStatus(NoticeEnum.STATUS_OK.getCode());
|
||||
noticeRecord.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
noticeRecordMapper.updateById(noticeRecord);
|
||||
|
||||
//记录到log
|
||||
smsLog.setIsVerify(0);
|
||||
smsLog.setCheckNum(0);
|
||||
smsLog.setSendStatus(1);
|
||||
smsLog.setSendTime(System.currentTimeMillis() / 1000);
|
||||
smsLog.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
smsLog.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
smsLogMapper.insert(smsLog);
|
||||
|
||||
} catch (OperateException e) {
|
||||
noticeRecord.setError(e.getMsg());
|
||||
noticeRecord.setStatus(NoticeEnum.STATUS_FAIL.getCode());
|
||||
noticeRecord.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
noticeRecordMapper.updateById(noticeRecord);
|
||||
|
||||
//记录到log
|
||||
smsLog.setIsVerify(0);
|
||||
smsLog.setCheckNum(0);
|
||||
smsLog.setSendStatus(2);
|
||||
smsLog.setSendTime(System.currentTimeMillis() / 1000);
|
||||
smsLog.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
smsLog.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
smsLogMapper.insert(smsLog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,34 +74,4 @@ public class IndexController {
|
|||
List<String> list = iIndexService.hotSearch();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@NotLogin
|
||||
@PostMapping("/sendSms")
|
||||
@ApiOperation(value="发送短信")
|
||||
public AjaxResult<Object> sendSms(@Validated @RequestBody SmsValidate smsValidate) {
|
||||
NoticeRecord noticeRecord = noticeRecordMapper.selectOne(new QueryWrapper<NoticeRecord>()
|
||||
.eq("account", smsValidate.getMobile())
|
||||
.eq("scene", smsValidate.getScene())
|
||||
.eq("status", Arrays.asList(NoticeEnum.STATUS_WAIT, NoticeEnum.STATUS_OK))
|
||||
.orderByDesc("id")
|
||||
.last("limit 1"));
|
||||
|
||||
if (StringUtils.isNotNull(noticeRecord)) {
|
||||
if (noticeRecord.getCreateTime() >= (System.currentTimeMillis() / 1000 - 60)){
|
||||
throw new OperateException("操作频繁,请稍后再试!");
|
||||
}
|
||||
}
|
||||
|
||||
NoticeSmsVo params = new NoticeSmsVo()
|
||||
.setScene(smsValidate.getScene())
|
||||
.setMobile(smsValidate.getMobile())
|
||||
.setExpire(900)
|
||||
.setParams(new String[] {
|
||||
"code:" + ToolUtils.randomInt(4)
|
||||
});
|
||||
|
||||
NoticeDriver.handle(params);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
package com.mdd.front.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.common.aop.NotLogin;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.entity.notice.NoticeRecord;
|
||||
import com.mdd.common.enums.NoticeEnum;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.notice.NoticeRecordMapper;
|
||||
import com.mdd.common.plugin.notice.NoticeDriver;
|
||||
import com.mdd.common.plugin.notice.vo.NoticeSmsVo;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
import com.mdd.common.util.ToolUtils;
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import com.mdd.front.service.IIndexService;
|
||||
import com.mdd.front.validate.common.SmsValidate;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/sms")
|
||||
@Api(tags = "主页管理")
|
||||
public class SmsController {
|
||||
|
||||
@Resource
|
||||
NoticeRecordMapper noticeRecordMapper;
|
||||
|
||||
@NotLogin
|
||||
@PostMapping("/sendCode")
|
||||
@ApiOperation(value="发送短信")
|
||||
public AjaxResult<Object> sendSms(@Validated @RequestBody SmsValidate smsValidate) {
|
||||
NoticeRecord noticeRecord = noticeRecordMapper.selectOne(new QueryWrapper<NoticeRecord>()
|
||||
.eq("account", smsValidate.getMobile())
|
||||
.eq("scene", smsValidate.getScene())
|
||||
.eq("status", Arrays.asList(NoticeEnum.STATUS_WAIT, NoticeEnum.STATUS_OK))
|
||||
.orderByDesc("id")
|
||||
.last("limit 1"));
|
||||
|
||||
if (StringUtils.isNotNull(noticeRecord)) {
|
||||
if (noticeRecord.getCreateTime() >= (System.currentTimeMillis() / 1000 - 60)){
|
||||
throw new OperateException("操作频繁,请稍后再试!");
|
||||
}
|
||||
}
|
||||
|
||||
NoticeSmsVo params = new NoticeSmsVo()
|
||||
.setScene(NoticeEnum.getSceneByTag(smsValidate.getScene()))
|
||||
.setMobile(smsValidate.getMobile())
|
||||
.setExpire(900)
|
||||
.setParams(new String[] {
|
||||
"code:" + ToolUtils.randomInt(4)
|
||||
});
|
||||
|
||||
NoticeDriver.handle(params);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,10 +3,14 @@ package com.mdd.front.controller;
|
|||
import com.mdd.common.aop.NotLogin;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.enums.AlbumEnum;
|
||||
import com.mdd.common.enums.FileEnum;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.plugin.storage.StorageDriver;
|
||||
import com.mdd.common.plugin.storage.UploadFilesVo;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
import com.mdd.front.LikeFrontThreadLocal;
|
||||
import com.mdd.front.service.IFileService;
|
||||
import com.mdd.front.vo.upload.UploadImagesVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
|
@ -15,17 +19,23 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartRequest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/upload")
|
||||
@Api(tags = "上传管理")
|
||||
public class UploadController {
|
||||
|
||||
@Resource
|
||||
IFileService iFileService;
|
||||
|
||||
@NotLogin
|
||||
@PostMapping("/image")
|
||||
@ApiOperation(value="上传图片")
|
||||
public AjaxResult<UploadFilesVo> image(HttpServletRequest request) {
|
||||
public AjaxResult<UploadImagesVo> image(HttpServletRequest request) {
|
||||
MultipartFile multipartFile;
|
||||
try {
|
||||
multipartFile = ((MultipartRequest) request).getFile("file");
|
||||
|
|
@ -44,7 +54,25 @@ public class UploadController {
|
|||
|
||||
StorageDriver storageDriver = new StorageDriver();
|
||||
UploadFilesVo vo = storageDriver.upload(multipartFile, folder, AlbumEnum.IMAGE.getCode());
|
||||
return AjaxResult.success(vo);
|
||||
System.out.println(vo);
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("cid", "0");
|
||||
params.put("uid", String.valueOf(LikeFrontThreadLocal.getUserId()));
|
||||
params.put("source", String.valueOf(FileEnum.SOURCE_USER.getCode()));
|
||||
params.put("type", String.valueOf(FileEnum.IMAGE_TYPE.getCode()));
|
||||
params.put("name", vo.getName());
|
||||
params.put("url", vo.getUrl());
|
||||
Integer id = iFileService.fileAdd(params);
|
||||
|
||||
UploadImagesVo upVo = new UploadImagesVo();
|
||||
upVo.setUrl(vo.getUrl());
|
||||
upVo.setUri(vo.getPath());
|
||||
upVo.setId(id);
|
||||
upVo.setType(FileEnum.IMAGE_TYPE.getCode());
|
||||
upVo.setName(vo.getName());
|
||||
upVo.setCid(0);
|
||||
return AjaxResult.success(upVo);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,12 +41,12 @@ public class UserController {
|
|||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
@PostMapping("/edit")
|
||||
@PostMapping("/setInfo")
|
||||
@ApiOperation(value="编辑信息")
|
||||
public AjaxResult<Object> edit(@Validated @RequestBody UserUpdateValidate updateValidate) {
|
||||
public AjaxResult<Object> setInfo(@Validated @RequestBody UserUpdateValidate updateValidate) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
|
||||
iUserService.edit(updateValidate, userId);
|
||||
iUserService.setInfo(updateValidate, userId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.mdd.front.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文件服务接口类
|
||||
*/
|
||||
public interface IFileService {
|
||||
/**
|
||||
* 文件新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 文件信息参数
|
||||
*/
|
||||
Integer fileAdd(Map<String, String> params);
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ public interface IUserService {
|
|||
* @param updateValidate 参数
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
void edit(UserUpdateValidate updateValidate, Integer userId);
|
||||
void setInfo(UserUpdateValidate updateValidate, Integer userId);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
package com.mdd.front.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.file.File;
|
||||
import com.mdd.common.entity.file.FileCate;
|
||||
import com.mdd.common.mapper.album.FileCateMapper;
|
||||
import com.mdd.common.mapper.album.FileMapper;
|
||||
import com.mdd.common.util.*;
|
||||
import com.mdd.front.service.IFileService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文件服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class FileServiceImpl implements IFileService {
|
||||
|
||||
@Resource
|
||||
FileMapper fileMapper;
|
||||
|
||||
@Resource
|
||||
FileCateMapper fileCateMapper;
|
||||
|
||||
/**
|
||||
* 文件新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 文件信息参数
|
||||
*/
|
||||
@Override
|
||||
public Integer fileAdd(Map<String, String> params) {
|
||||
String name = params.get("name");
|
||||
if (name.length() >= 100) {
|
||||
name = name.substring(0, 99);
|
||||
}
|
||||
|
||||
File album = new File();
|
||||
album.setCid(Integer.parseInt(params.get("cid") == null ? "0" : params.get("cid")));
|
||||
album.setSourceId(Integer.parseInt(params.get("uid") == null ? "0" : params.get("uid")));
|
||||
album.setType(Integer.parseInt(params.get("type")));
|
||||
album.setSource(Integer.parseInt(params.get("source") == null ? "0" : params.get("source")));
|
||||
album.setName(name);
|
||||
album.setUri(params.get("url"));
|
||||
album.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
album.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
fileMapper.insert(album);
|
||||
return album.getId();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ public class LoginServiceImpl implements ILoginService {
|
|||
@Override
|
||||
public LoginTokenVo mobileLogin(String mobile, String code, Integer terminal) {
|
||||
// 校验验证码
|
||||
int sceneCode = NoticeEnum.LOGIN_CODE.getCode();
|
||||
int sceneCode = NoticeEnum.LOGIN_CAPTCHA.getCode();
|
||||
if (!NoticeCheck.verify(sceneCode, code)) {
|
||||
throw new OperateException("验证码错误!");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ public class UserServiceImpl implements IUserService {
|
|||
* @param userId 用户ID
|
||||
*/
|
||||
@Override
|
||||
public void edit(UserUpdateValidate updateValidate, Integer userId) {
|
||||
public void setInfo(UserUpdateValidate updateValidate, Integer userId) {
|
||||
String field = updateValidate.getField();
|
||||
String value = updateValidate.getValue();
|
||||
|
||||
|
|
@ -142,11 +142,11 @@ public class UserServiceImpl implements IUserService {
|
|||
avatarUser.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
userMapper.updateById(avatarUser);
|
||||
break;
|
||||
case "username":
|
||||
case "account":
|
||||
User usernameUser = userMapper.selectOne(new QueryWrapper<User>()
|
||||
.select("id,username")
|
||||
.eq("username", value)
|
||||
.eq("is_delete", 0)
|
||||
.select("id,account")
|
||||
.eq("account", value)
|
||||
.isNull("delete_time")
|
||||
.last("limit 1"));
|
||||
|
||||
if (StringUtils.isNotNull(usernameUser) && !usernameUser.getId().equals(userId)) {
|
||||
|
|
@ -194,7 +194,7 @@ public class UserServiceImpl implements IUserService {
|
|||
User user = userMapper.selectOne(new QueryWrapper<User>()
|
||||
.select("id,password,salt")
|
||||
.eq("id", userId)
|
||||
.eq("is_delete", 0)
|
||||
.isNull("delete_time")
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(user, "用户不存在");
|
||||
|
|
@ -227,15 +227,15 @@ public class UserServiceImpl implements IUserService {
|
|||
@Override
|
||||
public void forgotPwd(String password, String mobile, String code) {
|
||||
// 校验验证码
|
||||
int sceneCode = NoticeEnum.FORGOT_PASSWORD_CODE.getCode();
|
||||
int sceneCode = NoticeEnum.FIND_LOGIN_PASSWORD_CAPTCHA.getCode();
|
||||
if (!NoticeCheck.verify(sceneCode, code)) {
|
||||
throw new OperateException("验证码错误!");
|
||||
}
|
||||
|
||||
// 查询手机号
|
||||
User user = userMapper.selectOne(new QueryWrapper<User>()
|
||||
.select("id,username,mobile,is_disable")
|
||||
.eq("is_delete", 0)
|
||||
.select("id,account,mobile,is_disable")
|
||||
.isNull("delete_time")
|
||||
.eq("mobile", mobile)
|
||||
.last("limit 1"));
|
||||
|
||||
|
|
@ -265,15 +265,15 @@ public class UserServiceImpl implements IUserService {
|
|||
String code = mobileValidate.getCode().toLowerCase();
|
||||
|
||||
// 校验验证码
|
||||
int sceneCode = type.equals("bind") ? NoticeEnum.BIND_MOBILE_CODE.getCode() : NoticeEnum.CHANGE_MOBILE_CODE.getCode() ;
|
||||
int sceneCode = type.equals("bind") ? NoticeEnum.BIND_MOBILE_CAPTCHA.getCode() : NoticeEnum.CHANGE_MOBILE_CAPTCHA.getCode() ;
|
||||
if (!NoticeCheck.verify(sceneCode, code)) {
|
||||
throw new OperateException("验证码错误!");
|
||||
}
|
||||
|
||||
User user = userMapper.selectOne(new QueryWrapper<User>()
|
||||
.select("id,username,mobile")
|
||||
.select("id,account,mobile")
|
||||
.eq("mobile", mobile)
|
||||
.eq("is_delete", 0)
|
||||
.isNull("delete_time")
|
||||
.last("limit 1"));
|
||||
|
||||
if (StringUtils.isNotNull(user) && user.getId().equals(userId)) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public class SmsValidate implements Serializable {
|
|||
|
||||
@NotNull(message = "scene参数缺失")
|
||||
@ApiModelProperty(value = "场景码")
|
||||
private Integer scene;
|
||||
private String scene;
|
||||
|
||||
@NotNull(message = "mobile参数缺失")
|
||||
@NotEmpty(message = "手机号不能为空")
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ public class UserUpdateValidate implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull(message = "field参数缺失")
|
||||
@StringContains(values = {"avatar", "username", "nickname", "sex"})
|
||||
@ApiModelProperty(value = "操作字段", required = true, example = "avatar,username,nickname,sex")
|
||||
@StringContains(values = {"avatar", "account", "nickname", "sex"})
|
||||
@ApiModelProperty(value = "操作字段", required = true, example = "avatar,account,nickname,sex")
|
||||
private String field;
|
||||
|
||||
@NotNull(message = "value参数缺失")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.mdd.front.vo.upload;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class UploadImagesVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private Integer cid;
|
||||
private Integer type;
|
||||
private String name;
|
||||
private String url;
|
||||
private String uri;
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue