Merge remote-tracking branch 'origin/mdc' into mdc

This commit is contained in:
nieziyan 2024-02-20 15:51:37 +08:00
commit 6e7573d01b
4 changed files with 117 additions and 8 deletions

View File

@ -18,7 +18,7 @@ import java.util.Map;
public interface MessageService { public interface MessageService {
@GetMapping(value = "/sys/sysAnnouncementSend/getMyAnnouncementSend") @GetMapping(value = "/sys/sysAnnouncementSend/getMyAnnouncementSendApp")
Result<IPage<AnnouncementSendModel>> getMyAnnouncementSend(@RequestParam AnnouncementSendModel announcementSendModel, Result<IPage<AnnouncementSendModel>> getMyAnnouncementSend(@RequestParam AnnouncementSendModel announcementSendModel,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize); @RequestParam(name="pageSize", defaultValue="10") Integer pageSize);

View File

@ -23,7 +23,7 @@ public interface SystemClient {
Result<JSONObject> mLogin(@RequestBody SysLoginModel sysLoginModel); Result<JSONObject> mLogin(@RequestBody SysLoginModel sysLoginModel);
/** /**
* 图形验证码 * 保存用户关联客户端
* @return * @return
*/ */
@PostMapping("/userClient/saveOrUpdateClient") @PostMapping("/userClient/saveOrUpdateClient")
@ -33,19 +33,19 @@ public interface SystemClient {
* 登出 * 登出
* @return * @return
*/ */
@RequestMapping("/logout") @RequestMapping("/mlogout")
Result<Object> logout(@RequestBody HttpServletRequest request); Result<Object> logout(@RequestBody HttpServletRequest request);
/** /**
* 图形验证码 * 图形验证码
*/ */
@GetMapping("/randomImage/{key}") @GetMapping("/mRandomImage/{key}")
Result<String> randomImage(@PathVariable("key") String key); Result<String> randomImage(@PathVariable("key") String key);
/** /**
* 图形验证码 * 图形验证码
* @return * @return
*/ */
@PostMapping("/checkCaptcha") @PostMapping("/mCheckCaptcha")
Result<?> checkCaptcha(); Result<?> checkCaptcha();
} }

View File

@ -214,6 +214,38 @@ public class LoginController {
return Result.error("Token无效!"); return Result.error("Token无效!");
} }
} }
/**
* app端退出登录
* @return
*/
@RequestMapping(value = "/mlogout")
public Result<Object> mlogout(@RequestBody HttpServletRequest request) {
//用户退出逻辑
String token = request.getHeader(CommonConstant.X_ACCESS_TOKEN);
if(oConvertUtils.isEmpty(token)) {
return Result.error("退出登录失败!");
}
String username = JwtUtil.getUsername(token);
LoginUser sysUser = sysBaseApi.getUserByName(username);
if(sysUser!=null) {
//update-begin--Author:wangshuai Date:20200714 for登出日志没有记录人员
baseCommonService.addLog("用户名: "+sysUser.getRealname()+",退出成功!", CommonConstant.LOG_TYPE_1, null,sysUser);
//update-end--Author:wangshuai Date:20200714 for登出日志没有记录人员
log.info(" 用户名: "+sysUser.getRealname()+",退出成功! ");
//清空用户登录Token缓存
redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token);
//清空用户登录Shiro权限缓存
redisUtil.del(CommonConstant.PREFIX_USER_SHIRO_CACHE + sysUser.getId());
//清空用户的缓存信息包括部门信息例如sys:cache:user::<username>
redisUtil.del(String.format("%s::%s", CacheConstant.SYS_USERS_CACHE, sysUser.getUsername()));
//调用shiro的logout
SecurityUtils.getSubject().logout();
return Result.ok("退出登录成功!");
}else {
return Result.error("Token无效!");
}
}
/** /**
* 获取访问量 * 获取访问量
@ -510,6 +542,40 @@ public class LoginController {
@ApiOperation("获取验证码") @ApiOperation("获取验证码")
@GetMapping(value = "/randomImage/{key}") @GetMapping(value = "/randomImage/{key}")
public Result<String> randomImage(HttpServletResponse response,@PathVariable("key") String key){ public Result<String> randomImage(HttpServletResponse response,@PathVariable("key") String key){
Result<String> res = new Result<String>();
try {
//生成验证码
String code = RandomUtil.randomString(BASE_CHECK_CODES,4);
//存到redis中
String lowerCaseCode = code.toLowerCase();
//update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 漏洞发现新漏洞待处理20220906
// 加入密钥作为混淆避免简单的拼接被外部利用用户自定义该密钥即可
String origin = lowerCaseCode+key+jeecgBaseConfig.getSignatureSecret();
String realKey = Md5Util.md5Encode(origin, "utf-8");
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 漏洞发现新漏洞待处理20220906
redisUtil.set(realKey, lowerCaseCode, 60);
log.info("获取验证码Redis key = {}checkCode = {}", realKey, code);
//返回前端
String base64 = RandImageUtil.generate(code);
res.setSuccess(true);
res.setResult(base64);
} catch (Exception e) {
log.error(e.getMessage(), e);
res.error500("获取验证码失败,请检查redis配置!");
return res;
}
return res;
}
/**
* app端后台生成图形验证码 有效
* @param key
*/
@ApiOperation("获取验证码")
@GetMapping(value = "/mRandomImage/{key}")
public Result<String> mRandomImage(@PathVariable("key") String key){
Result<String> res = new Result<String>(); Result<String> res = new Result<String>();
try { try {
//生成验证码 //生成验证码
@ -679,6 +745,28 @@ public class LoginController {
} }
return Result.ok(); return Result.ok();
} }
/**
* app端图形验证码
* @param sysLoginModel
* @return
*/
@RequestMapping(value = "/mCheckCaptcha", method = RequestMethod.POST)
public Result<?> mCheckCaptcha(@RequestBody SysLoginModel sysLoginModel){
String captcha = sysLoginModel.getCaptcha();
String checkKey = sysLoginModel.getCheckKey();
if(captcha==null){
return Result.error("验证码无效");
}
String lowerCaseCaptcha = captcha.toLowerCase();
String realKey = Md5Util.md5Encode(lowerCaseCaptcha+checkKey, "utf-8");
Object checkCode = redisUtil.get(realKey);
if(checkCode==null || !checkCode.equals(lowerCaseCaptcha)) {
return Result.error("验证码错误");
}
return Result.ok();
}
/** /**
* 登录二维码 * 登录二维码
*/ */

View File

@ -199,13 +199,34 @@ public class SysAnnouncementSendController {
result.setSuccess(true); result.setSuccess(true);
return result; return result;
} }
/**
* @功能获取我的消息
* @return
*/
@GetMapping(value = "/getMyAnnouncementSend")
public Result<IPage<AnnouncementSendModel>> getMyAnnouncementSend(AnnouncementSendModel announcementSendModel,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
Result<IPage<AnnouncementSendModel>> result = new Result<IPage<AnnouncementSendModel>>();
LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
String userId = sysUser.getId();
announcementSendModel.setUserId(userId);
announcementSendModel.setPageNo((pageNo-1)*pageSize);
announcementSendModel.setPageSize(pageSize);
Page<AnnouncementSendModel> pageList = new Page<AnnouncementSendModel>(pageNo,pageSize);
pageList = sysAnnouncementSendService.getMyAnnouncementSendPage(pageList, announcementSendModel);
result.setResult(pageList);
result.setSuccess(true);
return result;
}
/** /**
* @功能获取我的消息 * @功能获取我的消息
* @return * @return
*/ */
@GetMapping(value = "/getMyAnnouncementSend") @GetMapping(value = "/getMyAnnouncementSendApp")
public Result<IPage<AnnouncementSendModel>> getMyAnnouncementSend(AnnouncementSendModel announcementSendModel, public Result<IPage<AnnouncementSendModel>> getMyAnnouncementSendApp(@RequestParam AnnouncementSendModel announcementSendModel,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) { @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
Result<IPage<AnnouncementSendModel>> result = new Result<IPage<AnnouncementSendModel>>(); Result<IPage<AnnouncementSendModel>> result = new Result<IPage<AnnouncementSendModel>>();