Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
|
3ba81682da | |
|
d5d07a6388 | |
|
47571b1f06 |
|
@ -34,7 +34,8 @@ public class TokenController {
|
|||
@PostMapping("login")
|
||||
public Result<?> login (@RequestBody LoginBody form) {
|
||||
// 用户登录
|
||||
LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
||||
// LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
||||
LoginUser userInfo = sysLoginService.login(form.getEmail(), form.getPassword());
|
||||
// 获取登录token
|
||||
return Result.success(tokenService.createToken(userInfo));
|
||||
}
|
||||
|
@ -66,7 +67,7 @@ public class TokenController {
|
|||
@PostMapping("register")
|
||||
public Result<?> register (@RequestBody RegisterBody registerBody) {
|
||||
// 用户注册
|
||||
sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
|
||||
sysLoginService.register(registerBody.getEmail(), registerBody.getPassword());
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +1,51 @@
|
|||
package com.muyu.auth.form;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户登录对象
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Data
|
||||
public class LoginBody {
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
// public LoginBody() {
|
||||
// }
|
||||
|
||||
// public LoginBody(String email) {
|
||||
// this.email = email;
|
||||
// }
|
||||
// -----------------------
|
||||
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
public String getUsername () {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername (String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword () {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword (String password) {
|
||||
this.password = password;
|
||||
}
|
||||
// public String getUsername () {
|
||||
// return username;
|
||||
// }
|
||||
//
|
||||
// public void setUsername (String username) {
|
||||
// this.username = username;
|
||||
// }
|
||||
//
|
||||
// public String getPassword () {
|
||||
// return password;
|
||||
// }
|
||||
//
|
||||
// public void setPassword (String password) {
|
||||
// this.password = password;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -40,36 +40,43 @@ public class SysLoginService {
|
|||
/**
|
||||
* 登录
|
||||
*/
|
||||
public LoginUser login (String username, String password) {
|
||||
public LoginUser login (String email, String password) {
|
||||
// public LoginUser login (String username, String password) {
|
||||
// 用户名或密码为空 错误
|
||||
if (StringUtils.isAnyBlank(username, password)) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
||||
throw new ServiceException("用户/密码必须填写");
|
||||
// if (StringUtils.isAnyBlank(username, password)) {
|
||||
if (StringUtils.isAnyBlank(email, password)) {
|
||||
// recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
||||
recordLogService.recordLogininfor(email, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
||||
throw new ServiceException("用户/邮箱 密码必须填写");
|
||||
}
|
||||
// 密码如果不在指定范围内 错误
|
||||
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围");
|
||||
// recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围");
|
||||
recordLogService.recordLogininfor(email, Constants.LOGIN_FAIL, "用户密码不在指定范围");
|
||||
throw new ServiceException("用户密码不在指定范围");
|
||||
}
|
||||
// 用户名不在指定范围内 错误
|
||||
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围");
|
||||
if (email.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||
|| email.length() > UserConstants.USERNAME_MAX_LENGTH) {
|
||||
recordLogService.recordLogininfor(email, Constants.LOGIN_FAIL, "用户名不在指定范围");
|
||||
throw new ServiceException("用户名不在指定范围");
|
||||
}
|
||||
// IP黑名单校验
|
||||
String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST));
|
||||
if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "很遗憾,访问IP已被列入系统黑名单");
|
||||
recordLogService.recordLogininfor(email, Constants.LOGIN_FAIL, "很遗憾,访问IP已被列入系统黑名单");
|
||||
throw new ServiceException("很遗憾,访问IP已被列入系统黑名单");
|
||||
}
|
||||
// 查询用户信息
|
||||
Result<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
||||
// Result<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
||||
Result<LoginUser> userResult = remoteUserService.getUserInfo(email, SecurityConstants.INNER);
|
||||
|
||||
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||
throw new ServiceException("登录用户:" + username + " 不存在");
|
||||
// recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||
recordLogService.recordLogininfor(email, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||
// throw new ServiceException("登录用户:" + username + " 不存在");
|
||||
throw new ServiceException("登录用户:" + email + " 不存在");
|
||||
}
|
||||
|
||||
if (Result.FAIL == userResult.getCode()) {
|
||||
|
@ -79,15 +86,19 @@ public class SysLoginService {
|
|||
LoginUser userInfo = userResult.getData();
|
||||
SysUser user = userResult.getData().getSysUser();
|
||||
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
||||
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
||||
// recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
||||
recordLogService.recordLogininfor(email, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
||||
// throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
||||
throw new ServiceException("对不起,您的账号:" + email + " 已被删除");
|
||||
}
|
||||
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
||||
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
||||
// recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
||||
recordLogService.recordLogininfor(email, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
||||
throw new ServiceException("对不起,您的账号:" + email + " 已停用");
|
||||
}
|
||||
passwordService.validate(user, password);
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
||||
// recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
||||
recordLogService.recordLogininfor(email, Constants.LOGIN_SUCCESS, "登录成功");
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
|
@ -98,13 +109,15 @@ public class SysLoginService {
|
|||
/**
|
||||
* 注册
|
||||
*/
|
||||
public void register (String username, String password) {
|
||||
// public void register (String username, String password) {
|
||||
public void register (String email, String password) {
|
||||
// 用户名或密码为空 错误
|
||||
if (StringUtils.isAnyBlank(username, password)) {
|
||||
// if (StringUtils.isAnyBlank(username, password)) {
|
||||
if (StringUtils.isAnyBlank(email, password)) {
|
||||
throw new ServiceException("用户/密码必须填写");
|
||||
}
|
||||
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH) {
|
||||
if (email.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||
|| email.length() > UserConstants.USERNAME_MAX_LENGTH) {
|
||||
throw new ServiceException("账户长度必须在2到20个字符之间");
|
||||
}
|
||||
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||
|
@ -114,14 +127,15 @@ public class SysLoginService {
|
|||
|
||||
// 注册用户信息
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserName(username);
|
||||
sysUser.setNickName(username);
|
||||
sysUser.setUserName(email);
|
||||
sysUser.setNickName(email);
|
||||
sysUser.setPassword(SecurityUtils.encryptPassword(password));
|
||||
Result<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
|
||||
|
||||
if (Result.FAIL == registerResult.getCode()) {
|
||||
throw new ServiceException(registerResult.getMsg());
|
||||
}
|
||||
recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
|
||||
// recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
|
||||
recordLogService.recordLogininfor(email, Constants.REGISTER, "注册成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,11 @@ public class SysRecordLogService {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public void recordLogininfor (String username, String status, String message) {
|
||||
// public void recordLogininfor (String username, String status, String message) {
|
||||
public void recordLogininfor (String email, String status, String message) {
|
||||
SysLogininfor logininfor = new SysLogininfor();
|
||||
logininfor.setUserName(username);
|
||||
// logininfor.setUserName(username);
|
||||
logininfor.setUserName(email);
|
||||
logininfor.setIpaddr(IpUtils.getIpAddr());
|
||||
logininfor.setMsg(message);
|
||||
// 日志状态
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package com.muyu.common.system.domain;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -9,6 +14,10 @@ import java.util.Set;
|
|||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class LoginUser implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -26,6 +35,12 @@ public class LoginUser implements Serializable {
|
|||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
//----------------------
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
// ------------------
|
||||
|
||||
/**
|
||||
* 登录时间
|
||||
|
|
|
@ -37,6 +37,8 @@ public class SysLogininfor extends BaseEntity {
|
|||
@Excel(name = "用户账号")
|
||||
private String userName;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 状态 0成功 1失败
|
||||
*/
|
||||
|
|
|
@ -16,16 +16,19 @@ import org.springframework.web.bind.annotation.*;
|
|||
*/
|
||||
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
|
||||
public interface RemoteUserService {
|
||||
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param email 用户名
|
||||
* @param source 请求来源
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@GetMapping("/user/info/{username}")
|
||||
public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
// @GetMapping("/user/info/{username}")
|
||||
@GetMapping("/user/info/{email}")
|
||||
public Result<LoginUser> getUserInfo (@PathVariable("email") String email, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
|
|
|
@ -23,7 +23,8 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
log.error("用户服务调用失败:{}", throwable.getMessage());
|
||||
return new RemoteUserService() {
|
||||
@Override
|
||||
public Result<LoginUser> getUserInfo (String username, String source) {
|
||||
// public Result<LoginUser> getUserInfo (String username, String source) {
|
||||
public Result<LoginUser> getUserInfo (String email, String source) {
|
||||
return Result.error("获取用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9203
|
||||
port: 9206
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
package com.muyu.system.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.system.domain.AsUserDept;
|
||||
import com.muyu.system.domain.resp.AsUserDeptNumResponse;
|
||||
import com.muyu.system.service.AsUserDeptService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@Author:ShenJiaFeng
|
||||
*@Package:com.muyu.system.controller
|
||||
*@Project:zg6_cloud
|
||||
*@name:AsUserController
|
||||
*@Date:2024/4/14 10:14
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/userDept")
|
||||
public class AsUserDeptController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private AsUserDeptService asUserDeptService;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*/
|
||||
@RequiresPermissions("system:dept:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<AsUserDept>> list(AsUserDept asUserDept)
|
||||
{
|
||||
startPage();
|
||||
List<AsUserDept> list = asUserDeptService.selectAsUserDeptList(asUserDept);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/UpdateAsUserDept")
|
||||
public Result list(@RequestParam("id") Long id)
|
||||
{
|
||||
return asUserDeptService.updateAsUserDeptRead(id);
|
||||
}
|
||||
|
||||
@GetMapping("/GetNum")
|
||||
public Result<AsUserDeptNumResponse> getNum(@RequestParam("noticeId") Long noticeId)
|
||||
{
|
||||
return asUserDeptService.getNum(noticeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出【请填写功能名称】列表
|
||||
*/
|
||||
@RequiresPermissions("system:dept:export")
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, AsUserDept asUserDept)
|
||||
{
|
||||
List<AsUserDept> list = asUserDeptService.selectAsUserDeptList(asUserDept);
|
||||
ExcelUtil<AsUserDept> util = new ExcelUtil<AsUserDept>(AsUserDept.class);
|
||||
util.exportExcel(response, list, "【请填写功能名称】数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取【请填写功能名称】详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:dept:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(asUserDeptService.selectAsUserDeptById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*/
|
||||
@RequiresPermissions("system:dept:add")
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add(@RequestBody AsUserDept asUserDept)
|
||||
{
|
||||
return toAjax(asUserDeptService.insertAsUserDept(asUserDept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*/
|
||||
@RequiresPermissions("system:dept:edit")
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result edit(@RequestBody AsUserDept asUserDept)
|
||||
{
|
||||
return toAjax(asUserDeptService.updateAsUserDept(asUserDept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】
|
||||
*/
|
||||
@RequiresPermissions("system:dept:remove")
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(asUserDeptService.deleteAsUserDeptByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -8,6 +8,8 @@ import com.muyu.common.log.enums.BusinessType;
|
|||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.system.domain.SysNotice;
|
||||
import com.muyu.system.domain.req.SysNoticeRequest;
|
||||
import com.muyu.system.domain.resp.SysNoticeResponse;
|
||||
import com.muyu.system.service.SysNoticeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -37,6 +39,15 @@ public class SysNoticeController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* ---
|
||||
* @param sysNoticeRequest
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/GetNoticeList")
|
||||
public Result<List<SysNoticeResponse>> getNoticeList (@RequestBody SysNoticeRequest sysNoticeRequest){
|
||||
return noticeService.getNoticeList(sysNoticeRequest);
|
||||
}
|
||||
/**
|
||||
* 根据通知公告编号获取详细信息
|
||||
*/
|
||||
|
|
|
@ -9,10 +9,10 @@ import com.muyu.common.log.annotation.Log;
|
|||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.service.TokenService;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.remote.RemoteFileService;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.domain.SysFile;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.remote.RemoteFileService;
|
||||
import com.muyu.system.domain.resp.ProfileResp;
|
||||
import com.muyu.system.service.SysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -44,7 +44,8 @@ public class SysProfileController extends BaseController {
|
|||
@GetMapping
|
||||
public Result profile () {
|
||||
String username = SecurityUtils.getUsername();
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
// SysUser user = userService.selectUserByUserName(username);
|
||||
SysUser user = userService.selectUserByUserEmail(username);
|
||||
return Result.success(
|
||||
ProfileResp.builder()
|
||||
.roleGroup( userService.selectUserRoleGroup(username) )
|
||||
|
@ -87,7 +88,8 @@ public class SysProfileController extends BaseController {
|
|||
@PutMapping("/updatePwd")
|
||||
public Result updatePwd (String oldPassword, String newPassword) {
|
||||
String username = SecurityUtils.getUsername();
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
// SysUser user = userService.selectUserByUserName(username);
|
||||
SysUser user = userService.selectUserByUserEmail(username);
|
||||
String password = user.getPassword();
|
||||
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
|
||||
return error("修改密码失败,旧密码错误");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.system.controller;
|
||||
|
||||
import com.muyu.common.core.constant.CacheConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
|
@ -7,6 +8,7 @@ import com.muyu.common.core.web.controller.BaseController;
|
|||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.common.security.annotation.InnerAuth;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
|
@ -97,9 +99,12 @@ public class SysUserController extends BaseController {
|
|||
* 获取当前用户信息
|
||||
*/
|
||||
@InnerAuth
|
||||
@GetMapping("/info/{username}")
|
||||
public Result<LoginUser> info (@PathVariable("username") String username) {
|
||||
SysUser sysUser = userService.selectUserByUserName(username);
|
||||
// @GetMapping("/info/{username}")
|
||||
@GetMapping("/info/{email}")
|
||||
// public Result<LoginUser> info (@PathVariable("username") String username) {
|
||||
public Result<LoginUser> info (@PathVariable("email") String email) {
|
||||
// SysUser sysUser = userService.selectUserByUserName(username);
|
||||
SysUser sysUser = userService.selectUserByUserEmail(email);
|
||||
if (StringUtils.isNull(sysUser)) {
|
||||
return Result.error("用户名或密码错误");
|
||||
}
|
||||
|
@ -120,12 +125,14 @@ public class SysUserController extends BaseController {
|
|||
@InnerAuth
|
||||
@PostMapping("/register")
|
||||
public Result<Boolean> register (@RequestBody SysUser sysUser) {
|
||||
String username = sysUser.getUserName();
|
||||
// String username = sysUser.getUserName();
|
||||
String email = sysUser.getUserName();
|
||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
|
||||
return Result.error("当前系统没有开启注册功能!");
|
||||
}
|
||||
if (!userService.checkUserNameUnique(sysUser)) {
|
||||
return Result.error("保存用户'" + username + "'失败,注册账号已存在");
|
||||
// return Result.error("保存用户'" + username + "'失败,注册账号已存在");
|
||||
return Result.error("保存用户'" + email + "'失败,注册账号已存在");
|
||||
}
|
||||
return Result.success(userService.registerUser(sysUser));
|
||||
}
|
||||
|
@ -238,9 +245,13 @@ public class SysUserController extends BaseController {
|
|||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
user.setUpdateBy(SecurityUtils.getUsername());
|
||||
|
||||
// redisService.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + user.getUserId());
|
||||
|
||||
return toAjax(userService.resetPwd(user));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
/**
|
||||
* @Author:ShenJiaFeng
|
||||
* @Package:com.muyu.system.domain
|
||||
* @Project:zg6_cloud
|
||||
* @name:AsUserD俄pt
|
||||
* @Date:2024/4/14 9:53
|
||||
*/
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 用户部门中间表
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AsUserDept extends BaseEntity {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 公告id
|
||||
*/
|
||||
private Long noticeId;
|
||||
/**
|
||||
* 是否已读
|
||||
*/
|
||||
private String isRead;
|
||||
}
|
|
@ -12,6 +12,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通知公告表 sys_notice
|
||||
|
@ -51,6 +52,18 @@ public class SysNotice extends BaseEntity {
|
|||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 部门id集合--
|
||||
* @return
|
||||
*/
|
||||
private List<List<Long>> sectionList;
|
||||
|
||||
/**--
|
||||
* 用户id集合
|
||||
* @return
|
||||
*/
|
||||
private List<Long> persomelList;
|
||||
|
||||
public Long getNoticeId () {
|
||||
return noticeId;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package com.muyu.system.domain.req;
|
||||
|
||||
/**
|
||||
* @Author:ShenJiaFeng
|
||||
* @Package:com.muyu.system.domain.req
|
||||
* @Project:zg6_cloud
|
||||
* @name:SysNoticeRequest
|
||||
* @Date:2024/4/14 9:59
|
||||
*/
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* SysNoticeRequest
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SysNoticeRequest {
|
||||
private Long noticeId;
|
||||
private Long userId;
|
||||
private String noticeType;
|
||||
private String isRead;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.muyu.system.domain.resp;
|
||||
|
||||
/**
|
||||
* @Author:ShenJiaFeng
|
||||
* @Package:com.muyu.system.domain.resp
|
||||
* @Project:zg6_cloud
|
||||
* @name:AsUserDeptNumResponse
|
||||
* @Date:2024/4/14 10:02
|
||||
*/
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 部门中间响应
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class AsUserDeptNumResponse {
|
||||
private Long num;
|
||||
private Long redNum;
|
||||
private Long noReadNum;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.system.domain.resp;
|
||||
|
||||
/**
|
||||
* @Author:ShenJiaFeng
|
||||
* @Package:com.muyu.system.domain.resp
|
||||
* @Project:zg6_cloud
|
||||
* @name:SysNoticeResponse
|
||||
* @Date:2024/4/14 10:03
|
||||
*/
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* SysNoticeResponse
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysNoticeResponse {
|
||||
private Date createTime;
|
||||
private String createBy;
|
||||
private String noticeType;
|
||||
private String isRead;
|
||||
private String noticeTitle;
|
||||
private String noticeContent;
|
||||
private Long noticeId;
|
||||
private Long id;
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.muyu.system.mapper;
|
||||
|
||||
import com.muyu.system.domain.AsUserDept;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:ShenJiaFeng
|
||||
* @Package:com.muyu.system.mapper
|
||||
* @Project:zg6_cloud
|
||||
* @name:AsUserDeptMapper
|
||||
* @Date:2024/4/14 10:08
|
||||
*/
|
||||
public interface AsUserDeptMapper {
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
public AsUserDept selectAsUserDeptById(Long id);
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 【请填写功能名称】集合
|
||||
*/
|
||||
public List<AsUserDept> selectAsUserDeptList(AsUserDept asUserDept);
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAsUserDept(AsUserDept asUserDept);
|
||||
public int insertBachAsUserDept(@Param("asUserDepts") List<AsUserDept> asUserDepts);
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAsUserDept(AsUserDept asUserDept);
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAsUserDeptById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAsUserDeptByIds(Long[] ids);
|
||||
|
||||
void updateAsUserDeptRead(@Param("id") Long id);
|
||||
Long selectAsUserDeptNum(@Param("noticeId") Long noticeId);
|
||||
Long selectAsUserDeptReadNum(@Param("noticeId") Long noticeId);
|
||||
}
|
|
@ -21,6 +21,19 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
|||
*/
|
||||
public List<SysMenu> selectMenuList (SysMenu menu);
|
||||
|
||||
/**
|
||||
* 搜索系统
|
||||
* @return
|
||||
*/
|
||||
public List<SysMenu> selectSysMenList(@Param("longs") List<Long> longs);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param longs
|
||||
* @return
|
||||
*/
|
||||
public List<SysMenu> selectSysChdMenuList(@Param("longs") List<Long> longs);
|
||||
|
||||
/**
|
||||
* 根据用户所有权限
|
||||
*
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.muyu.system.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.system.domain.SysNotice;
|
||||
import com.muyu.system.domain.req.SysNoticeRequest;
|
||||
import com.muyu.system.domain.resp.SysNoticeResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -64,4 +66,13 @@ public interface SysNoticeMapper extends BaseMapper<SysNotice> {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteNoticeByIds (Long[] noticeIds);
|
||||
|
||||
/**
|
||||
* --
|
||||
* @param sysNoticeRequest
|
||||
* @return
|
||||
*/
|
||||
List<SysNoticeResponse> getNoticeList(SysNoticeRequest sysNoticeRequest);
|
||||
|
||||
List<Long> selectUser();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,8 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||
*
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByUserName (String userName);
|
||||
// public SysUser selectUserByUserName (String userName);
|
||||
public SysUser selectUserByUserEmail (String email);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
|
@ -139,4 +140,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique (String email);
|
||||
|
||||
List<Long> selectDeptUser(@Param("sectionIds") List<Long> sectionIds);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package com.muyu.system.service;
|
||||
|
||||
/**
|
||||
* @Author:ShenJiaFeng
|
||||
* @Package:com.muyu.system.service
|
||||
* @Project:zg6_cloud
|
||||
* @name:AsUserDeptService
|
||||
* @Date:2024/4/14 10:12
|
||||
*/
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.system.domain.AsUserDept;
|
||||
import com.muyu.system.domain.resp.AsUserDeptNumResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 中间service
|
||||
*/
|
||||
public interface AsUserDeptService {
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
public AsUserDept selectAsUserDeptById(Long id);
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 【请填写功能名称】集合
|
||||
*/
|
||||
public List<AsUserDept> selectAsUserDeptList(AsUserDept asUserDept);
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAsUserDept(AsUserDept asUserDept);
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAsUserDept(AsUserDept asUserDept);
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 需要删除的【请填写功能名称】主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAsUserDeptByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】信息
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAsUserDeptById(Long id);
|
||||
|
||||
Result updateAsUserDeptRead(Long id);
|
||||
|
||||
Result<AsUserDeptNumResponse> getNum(Long noticeId);
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
package com.muyu.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.system.domain.SysNotice;
|
||||
import com.muyu.system.domain.req.SysNoticeRequest;
|
||||
import com.muyu.system.domain.resp.SysNoticeResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -64,4 +67,9 @@ public interface SysNoticeService extends IService<SysNotice> {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteNoticeByIds (Long[] noticeIds);
|
||||
|
||||
|
||||
Result<List<SysNoticeResponse> > getNoticeList(SysNoticeRequest sysNoticeRequest);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -41,11 +41,12 @@ public interface SysUserService extends IService<SysUser> {
|
|||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param email 用户名
|
||||
*
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByUserName (String userName);
|
||||
// public SysUser selectUserByUserName (String userName);
|
||||
public SysUser selectUserByUserEmail (String email);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.system.domain.AsUserDept;
|
||||
import com.muyu.system.domain.resp.AsUserDeptNumResponse;
|
||||
import com.muyu.system.mapper.AsUserDeptMapper;
|
||||
import com.muyu.system.service.AsUserDeptService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:ShenJiaFeng
|
||||
* @Package:com.muyu.system.service.impl
|
||||
* @Project:zg6_cloud
|
||||
* @name:AsUserDeptServiceImpl
|
||||
* @Date:2024/4/14 10:13
|
||||
*/
|
||||
@Service
|
||||
public class AsUserDeptServiceImpl implements AsUserDeptService {
|
||||
@Autowired
|
||||
private AsUserDeptMapper asUserDeptMapper;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public AsUserDept selectAsUserDeptById(Long id)
|
||||
{
|
||||
return asUserDeptMapper.selectAsUserDeptById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public List<AsUserDept> selectAsUserDeptList(AsUserDept asUserDept)
|
||||
{
|
||||
return asUserDeptMapper.selectAsUserDeptList(asUserDept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertAsUserDept(AsUserDept asUserDept)
|
||||
{
|
||||
asUserDept.setCreateTime(DateUtils.getNowDate());
|
||||
return asUserDeptMapper.insertAsUserDept(asUserDept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateAsUserDept(AsUserDept asUserDept)
|
||||
{
|
||||
asUserDept.setUpdateTime(DateUtils.getNowDate());
|
||||
return asUserDeptMapper.updateAsUserDept(asUserDept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 需要删除的【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAsUserDeptByIds(Long[] ids)
|
||||
{
|
||||
return asUserDeptMapper.deleteAsUserDeptByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】信息
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAsUserDeptById(Long id)
|
||||
{
|
||||
return asUserDeptMapper.deleteAsUserDeptById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result updateAsUserDeptRead(Long id) {
|
||||
asUserDeptMapper.updateAsUserDeptRead(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<AsUserDeptNumResponse> getNum(Long noticeId) {
|
||||
Long num = asUserDeptMapper.selectAsUserDeptNum(noticeId);
|
||||
Long readNum = asUserDeptMapper.selectAsUserDeptReadNum(noticeId);
|
||||
long noReadNum = num-readNum;
|
||||
return Result.success(AsUserDeptNumResponse.builder()
|
||||
.num(num)
|
||||
.redNum(readNum)
|
||||
.noReadNum(noReadNum)
|
||||
.build());
|
||||
}
|
||||
}
|
|
@ -43,31 +43,96 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 根据用户查询系统菜单列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*
|
||||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> selectMenuList (Long userId) {
|
||||
public List<SysMenu> selectMenuList(Long userId) {
|
||||
return selectMenuList(new SysMenu(), userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统搜索 递归调用 向上查找每个采单对应父级
|
||||
*
|
||||
* @param menuList
|
||||
* @return
|
||||
*/
|
||||
public List<SysMenu> selectSysMenList(List<SysMenu> menuList) {
|
||||
// 获取父级ID 返回 流 id去重
|
||||
List<Long> longs = menuList.stream()
|
||||
.map(SysMenu::getParentId)
|
||||
.filter(parentId -> parentId != 0)
|
||||
.distinct()
|
||||
.toList();
|
||||
// 没有找到直接返回null
|
||||
if (longs.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
// 递归调用自身
|
||||
List<SysMenu> sysMenus = menuMapper.selectSysMenList(longs);
|
||||
// 自己调自己
|
||||
List<SysMenu> sysMenus1 = selectSysMenList(sysMenus);
|
||||
if (sysMenus1 != null) {
|
||||
sysMenus.addAll(sysMenus1);
|
||||
}
|
||||
|
||||
return sysMenus;
|
||||
}
|
||||
|
||||
|
||||
public List<SysMenu> selectSysChdMenuList(List<SysMenu> menuList) {
|
||||
// stream流 获取id
|
||||
List<Long> longs = menuList.stream()
|
||||
.map(SysMenu::getMenuId)
|
||||
.toList();
|
||||
// 跟进parentId 值查询数据库终结对应的子菜单信息
|
||||
List<SysMenu> sysMenus = menuMapper.selectSysChdMenuList(longs);
|
||||
if (sysMenus != null && sysMenus.size() != 0) {
|
||||
// 如果有 调用selectSysMenList 继续递归查询 子菜单
|
||||
List<SysMenu> sysMenus1 = selectSysChdMenuList(sysMenus);
|
||||
if (sysMenus1 != null) {
|
||||
// 不为空 添加原始数据
|
||||
sysMenus.addAll(sysMenus1);
|
||||
}
|
||||
} else {
|
||||
// 没有查到任何条件的信息
|
||||
return null;
|
||||
}
|
||||
return sysMenus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询系统菜单列表
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
*
|
||||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> selectMenuList (SysMenu menu, Long userId) {
|
||||
public List<SysMenu> selectMenuList(SysMenu menu, Long userId) {
|
||||
List<SysMenu> menuList = null;
|
||||
// 管理员显示所有菜单信息
|
||||
if (SysUser.isAdmin(userId)) {
|
||||
menuList = menuMapper.selectMenuList(menu);
|
||||
// 调用秭归
|
||||
List<SysMenu> sysMenus1 = selectSysMenList(menuList);
|
||||
if (sysMenus1 != null && sysMenus1.size() != 0) {
|
||||
menuList.addAll(sysMenus1);
|
||||
}
|
||||
|
||||
List<SysMenu> sysMenus = selectSysChdMenuList(menuMapper.selectMenuList(menu));
|
||||
// --------------
|
||||
if (sysMenus != null && sysMenus.size() != 0) {
|
||||
menuList.addAll(sysMenus);
|
||||
}
|
||||
|
||||
} else {
|
||||
menu.getParams().put("userId", userId);
|
||||
menuList = menuMapper.selectMenuListByUserId(menu);
|
||||
}
|
||||
// -----
|
||||
menuList = menuList.stream()
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
return menuList;
|
||||
}
|
||||
|
||||
|
@ -75,11 +140,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*
|
||||
* @return 权限列表
|
||||
*/
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByUserId (Long userId) {
|
||||
public Set<String> selectMenuPermsByUserId(Long userId) {
|
||||
List<String> perms = menuMapper.selectMenuPermsByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms) {
|
||||
|
@ -94,11 +158,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 根据角色ID查询权限
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
*
|
||||
* @return 权限列表
|
||||
*/
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByRoleId (Long roleId) {
|
||||
public Set<String> selectMenuPermsByRoleId(Long roleId) {
|
||||
List<String> perms = menuMapper.selectMenuPermsByRoleId(roleId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms) {
|
||||
|
@ -113,11 +176,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 根据用户ID查询菜单
|
||||
*
|
||||
* @param userId 用户名称
|
||||
*
|
||||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> selectMenuTreeByUserId (Long userId) {
|
||||
public List<SysMenu> selectMenuTreeByUserId(Long userId) {
|
||||
List<SysMenu> menus = null;
|
||||
if (SecurityUtils.isAdmin(userId)) {
|
||||
menus = menuMapper.selectMenuTreeAll();
|
||||
|
@ -131,11 +193,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 根据角色ID查询菜单树信息
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
*
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<Long> selectMenuListByRoleId (Long roleId) {
|
||||
public List<Long> selectMenuListByRoleId(Long roleId) {
|
||||
SysRole role = roleMapper.selectRoleById(roleId);
|
||||
return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
|
||||
}
|
||||
|
@ -144,11 +205,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 构建前端路由所需要的菜单
|
||||
*
|
||||
* @param menus 菜单列表
|
||||
*
|
||||
* @return 路由列表
|
||||
*/
|
||||
@Override
|
||||
public List<RouterVo> buildMenus (List<SysMenu> menus) {
|
||||
public List<RouterVo> buildMenus(List<SysMenu> menus) {
|
||||
List<RouterVo> routers = new LinkedList<RouterVo>();
|
||||
for (SysMenu menu : menus) {
|
||||
RouterVo router = new RouterVo();
|
||||
|
@ -196,14 +256,13 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 构建前端所需要树结构
|
||||
*
|
||||
* @param menus 菜单列表
|
||||
*
|
||||
* @return 树结构列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> buildMenuTree (List<SysMenu> menus) {
|
||||
public List<SysMenu> buildMenuTree(List<SysMenu> menus) {
|
||||
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
||||
List<Long> tempList = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList());
|
||||
for (Iterator<SysMenu> iterator = menus.iterator() ; iterator.hasNext() ; ) {
|
||||
for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext(); ) {
|
||||
SysMenu menu = (SysMenu) iterator.next();
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.contains(menu.getParentId())) {
|
||||
|
@ -221,11 +280,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 构建前端所需要下拉树结构
|
||||
*
|
||||
* @param menus 菜单列表
|
||||
*
|
||||
* @return 下拉树结构列表
|
||||
*/
|
||||
@Override
|
||||
public List<TreeSelect> buildMenuTreeSelect (List<SysMenu> menus) {
|
||||
public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus) {
|
||||
List<SysMenu> menuTrees = buildMenuTree(menus);
|
||||
return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
@ -234,11 +292,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 根据菜单ID查询信息
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
*
|
||||
* @return 菜单信息
|
||||
*/
|
||||
@Override
|
||||
public SysMenu selectMenuById (Long menuId) {
|
||||
public SysMenu selectMenuById(Long menuId) {
|
||||
return menuMapper.selectMenuById(menuId);
|
||||
}
|
||||
|
||||
|
@ -246,11 +303,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 是否存在菜单子节点
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildByMenuId (Long menuId) {
|
||||
public boolean hasChildByMenuId(Long menuId) {
|
||||
int result = menuMapper.hasChildByMenuId(menuId);
|
||||
return result > 0;
|
||||
}
|
||||
|
@ -259,11 +315,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 查询菜单使用数量
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkMenuExistRole (Long menuId) {
|
||||
public boolean checkMenuExistRole(Long menuId) {
|
||||
int result = roleMenuMapper.checkMenuExistRole(menuId);
|
||||
return result > 0;
|
||||
}
|
||||
|
@ -272,11 +327,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 新增保存菜单信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertMenu (SysMenu menu) {
|
||||
public int insertMenu(SysMenu menu) {
|
||||
return menuMapper.insertMenu(menu);
|
||||
}
|
||||
|
||||
|
@ -284,11 +338,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 修改保存菜单信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateMenu (SysMenu menu) {
|
||||
public int updateMenu(SysMenu menu) {
|
||||
return menuMapper.updateMenu(menu);
|
||||
}
|
||||
|
||||
|
@ -296,11 +349,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 删除菜单管理信息
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMenuById (Long menuId) {
|
||||
public int deleteMenuById(Long menuId) {
|
||||
return menuMapper.deleteMenuById(menuId);
|
||||
}
|
||||
|
||||
|
@ -308,11 +360,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 校验菜单名称是否唯一
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkMenuNameUnique (SysMenu menu) {
|
||||
public boolean checkMenuNameUnique(SysMenu menu) {
|
||||
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
||||
SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
|
||||
if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) {
|
||||
|
@ -325,10 +376,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 获取路由名称
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
*
|
||||
* @return 路由名称
|
||||
*/
|
||||
public String getRouteName (SysMenu menu) {
|
||||
public String getRouteName(SysMenu menu) {
|
||||
String routerName = StringUtils.capitalize(menu.getPath());
|
||||
// 非外链并且是一级目录(类型为目录)
|
||||
if (isMenuFrame(menu)) {
|
||||
|
@ -341,10 +391,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 获取路由地址
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
*
|
||||
* @return 路由地址
|
||||
*/
|
||||
public String getRouterPath (SysMenu menu) {
|
||||
public String getRouterPath(SysMenu menu) {
|
||||
String routerPath = menu.getPath();
|
||||
// 内链打开外网方式
|
||||
if (menu.getParentId().intValue() != 0 && isInnerLink(menu)) {
|
||||
|
@ -366,10 +415,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 获取组件信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
*
|
||||
* @return 组件信息
|
||||
*/
|
||||
public String getComponent (SysMenu menu) {
|
||||
public String getComponent(SysMenu menu) {
|
||||
String component = UserConstants.LAYOUT;
|
||||
if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu)) {
|
||||
component = menu.getComponent();
|
||||
|
@ -385,10 +433,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 是否为菜单内部跳转
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean isMenuFrame (SysMenu menu) {
|
||||
public boolean isMenuFrame(SysMenu menu) {
|
||||
return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType())
|
||||
&& menu.getIsFrame().equals(UserConstants.NO_FRAME);
|
||||
}
|
||||
|
@ -397,10 +444,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 是否为内链组件
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean isInnerLink (SysMenu menu) {
|
||||
public boolean isInnerLink(SysMenu menu) {
|
||||
return menu.getIsFrame().equals(UserConstants.NO_FRAME) && StringUtils.ishttp(menu.getPath());
|
||||
}
|
||||
|
||||
|
@ -408,10 +454,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 是否为parent_view组件
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean isParentView (SysMenu menu) {
|
||||
public boolean isParentView(SysMenu menu) {
|
||||
return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType());
|
||||
}
|
||||
|
||||
|
@ -420,12 +465,11 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
*
|
||||
* @param list 分类表
|
||||
* @param parentId 传入的父节点ID
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public List<SysMenu> getChildPerms (List<SysMenu> list, int parentId) {
|
||||
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) {
|
||||
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
||||
for (Iterator<SysMenu> iterator = list.iterator() ; iterator.hasNext() ; ) {
|
||||
for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext(); ) {
|
||||
SysMenu t = (SysMenu) iterator.next();
|
||||
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
|
||||
if (t.getParentId() == parentId) {
|
||||
|
@ -442,7 +486,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* @param list 分类表
|
||||
* @param t 子节点
|
||||
*/
|
||||
private void recursionFn (List<SysMenu> list, SysMenu t) {
|
||||
private void recursionFn(List<SysMenu> list, SysMenu t) {
|
||||
// 得到子节点列表
|
||||
List<SysMenu> childList = getChildList(list, t);
|
||||
t.setChildren(childList);
|
||||
|
@ -456,7 +500,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
/**
|
||||
* 得到子节点列表
|
||||
*/
|
||||
private List<SysMenu> getChildList (List<SysMenu> list, SysMenu t) {
|
||||
private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t) {
|
||||
List<SysMenu> tlist = new ArrayList<SysMenu>();
|
||||
Iterator<SysMenu> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
|
@ -471,7 +515,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
/**
|
||||
* 判断是否有子节点
|
||||
*/
|
||||
private boolean hasChild (List<SysMenu> list, SysMenu t) {
|
||||
private boolean hasChild(List<SysMenu> list, SysMenu t) {
|
||||
return getChildList(list, t).size() > 0;
|
||||
}
|
||||
|
||||
|
@ -480,7 +524,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
*
|
||||
* @return 替换后的内链域名
|
||||
*/
|
||||
public String innerLinkReplaceEach (String path) {
|
||||
public String innerLinkReplaceEach(String path) {
|
||||
return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":"},
|
||||
new String[]{"", "", "", "/", "/"});
|
||||
}
|
||||
|
|
|
@ -1,13 +1,24 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.system.domain.AsUserDept;
|
||||
import com.muyu.system.domain.SysNotice;
|
||||
import com.muyu.system.domain.req.SysNoticeRequest;
|
||||
import com.muyu.system.domain.resp.SysNoticeResponse;
|
||||
import com.muyu.system.mapper.AsUserDeptMapper;
|
||||
import com.muyu.system.mapper.SysNoticeMapper;
|
||||
import com.muyu.system.mapper.SysUserMapper;
|
||||
import com.muyu.system.service.SysNoticeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 公告 服务层实现
|
||||
|
@ -19,6 +30,11 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||
@Autowired
|
||||
private SysNoticeMapper noticeMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
@Autowired
|
||||
private AsUserDeptMapper asUserDeptMapper;
|
||||
|
||||
/**
|
||||
* 查询公告信息
|
||||
*
|
||||
|
@ -43,6 +59,37 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||
return noticeMapper.selectNoticeList(notice);
|
||||
}
|
||||
|
||||
public List<AsUserDept> handleList(List<Long> personnelList,List<List<Long>> sectionList,Long noticeId){
|
||||
List<Long> lons = new ArrayList<>();
|
||||
if (sectionList!=null && sectionList.size()!=0){
|
||||
sectionList.stream()
|
||||
.map(section -> {
|
||||
for (Long aLong : section) {
|
||||
lons.add(aLong);
|
||||
}
|
||||
return null;
|
||||
}).collect(Collectors.toList());
|
||||
List<Long> sectionIds = lons.stream().distinct().toList();
|
||||
List<Long> userIds=sysUserMapper.selectDeptUser(sectionIds);
|
||||
if (userIds!=null){
|
||||
personnelList.addAll(userIds);
|
||||
}
|
||||
}
|
||||
personnelList = personnelList.stream().distinct().toList();
|
||||
System.out.println(personnelList);
|
||||
List<AsUserDept> asUserDepts = personnelList.stream()
|
||||
.map(personne1 -> {
|
||||
AsUserDept asUserDept = new AsUserDept();
|
||||
asUserDept.setUserId(personne1);
|
||||
asUserDept.setNoticeId(noticeId);
|
||||
asUserDept.setCreateBy(SecurityUtils.getUsername());
|
||||
asUserDept.setCreateTime(new Date());
|
||||
return asUserDept;
|
||||
}).toList();
|
||||
return asUserDepts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增公告
|
||||
*
|
||||
|
@ -51,8 +98,31 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertNotice (SysNotice notice) {
|
||||
return noticeMapper.insertNotice(notice);
|
||||
// return noticeMapper.insertNotice(notice);
|
||||
int i = noticeMapper.insertNotice(notice);
|
||||
|
||||
if (notice.getNoticeType() .equals("1")){
|
||||
Long noticeId = notice.getNoticeId();
|
||||
List<Long> personnelList = notice.getPersomelList();
|
||||
List<List<Long>> sectionList = notice.getSectionList();
|
||||
List<AsUserDept> asUserDepts = handleList(personnelList, sectionList, noticeId);
|
||||
asUserDeptMapper.insertBachAsUserDept(asUserDepts);
|
||||
}else {
|
||||
List<Long> userIds = noticeMapper.selectUser();
|
||||
List<AsUserDept> asUserDepts = userIds.stream()
|
||||
.map(id -> {
|
||||
AsUserDept asUserDept = new AsUserDept();
|
||||
asUserDept.setNoticeId(notice.getNoticeId());
|
||||
asUserDept.setCreateTime(new Date());
|
||||
asUserDept.setUserId(id);
|
||||
asUserDept.setCreateBy(SecurityUtils.getUsername());
|
||||
return asUserDept;
|
||||
}).toList();
|
||||
asUserDeptMapper.insertBachAsUserDept(asUserDepts);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,4 +160,12 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||
public int deleteNoticeByIds (Long[] noticeIds) {
|
||||
return noticeMapper.deleteNoticeByIds(noticeIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<SysNoticeResponse>> getNoticeList(SysNoticeRequest sysNoticeRequest) {
|
||||
sysNoticeRequest.setUserId(SecurityUtils.getUserId());
|
||||
List<SysNoticeResponse> noticeList = noticeMapper.getNoticeList(sysNoticeRequest);
|
||||
return Result.success(noticeList);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -97,9 +97,15 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
*
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
// @Override
|
||||
// public SysUser selectUserByUserName (String userName) {
|
||||
// return userMapper.selectUserByUserName(userName);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public SysUser selectUserByUserName (String userName) {
|
||||
return userMapper.selectUserByUserName(userName);
|
||||
public SysUser selectUserByUserEmail (String email) {
|
||||
// public SysUser selectUserByUserEmail (String userName) {
|
||||
return userMapper.selectUserByUserEmail(email);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -463,7 +469,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
for (SysUser user : userList) {
|
||||
try {
|
||||
// 验证是否存在这个用户
|
||||
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
||||
// SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
||||
SysUser u = userMapper.selectUserByUserEmail(user.getUserName());
|
||||
if (StringUtils.isNull(u)) {
|
||||
BeanValidators.validateWithException(validator, user);
|
||||
user.setPassword(SecurityUtils.encryptPassword(password));
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<!--
|
||||
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||||
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||||
-->
|
||||
<mapper namespace="com.muyu.system.mapper.AsUserDeptMapper">
|
||||
<!-- 添加 -->
|
||||
<resultMap type="com.muyu.system.domain.AsUserDept" id="AsUserDeptResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="noticeId" column="notice_id" />
|
||||
<result property="isRead" column="is_read" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAsUserDeptVo">
|
||||
select id, user_id, notice_id, is_read, create_by, create_time, update_by, update_time, remark from as_user_dept
|
||||
</sql>
|
||||
|
||||
<select id="selectAsUserDeptList" parameterType="com.muyu.system.domain.AsUserDept" resultMap="AsUserDeptResult">
|
||||
<include refid="selectAsUserDeptVo"/>
|
||||
<where>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="noticeId != null "> and notice_id = #{noticeId}</if>
|
||||
<if test="isRead != null and isRead != ''"> and is_read = #{isRead}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectAsUserDeptById" parameterType="Long" resultMap="AsUserDeptResult">
|
||||
<include refid="selectAsUserDeptVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectAsUserDeptNum" resultType="java.lang.Long">
|
||||
select count(*) from as_user_dept where notice_id=#{noticeId}
|
||||
</select>
|
||||
<select id="selectAsUserDeptReadNum" resultType="java.lang.Long">
|
||||
select count(*) from as_user_dept where notice_id=#{noticeId} and is_read = '0'
|
||||
</select>
|
||||
|
||||
<insert id="insertAsUserDept" parameterType="com.muyu.system.domain.AsUserDept" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into as_user_dept
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="noticeId != null">notice_id,</if>
|
||||
<if test="isRead != null">is_read,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="noticeId != null">#{noticeId},</if>
|
||||
<if test="isRead != null">#{isRead},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<insert id="insertBachAsUserDept">
|
||||
INSERT INTO `as_user_dept` (`user_id`, `notice_id`, `create_by`, `create_time`)
|
||||
VALUES
|
||||
<foreach collection="asUserDepts" separator="," item="asUserDept">
|
||||
(#{asUserDept.userId}, #{asUserDept.noticeId}, #{asUserDept.createBy}, #{asUserDept.createTime})
|
||||
</foreach>
|
||||
|
||||
|
||||
</insert>
|
||||
|
||||
<update id="updateAsUserDept" parameterType="com.muyu.system.domain.AsUserDept">
|
||||
update as_user_dept
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="noticeId != null">notice_id = #{noticeId},</if>
|
||||
<if test="isRead != null">is_read = #{isRead},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updateAsUserDeptRead">
|
||||
update as_user_dept set is_read = 0 where id=#{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAsUserDeptById" parameterType="Long">
|
||||
delete from as_user_dept where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAsUserDeptByIds" parameterType="String">
|
||||
delete from as_user_dept where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
|
@ -186,6 +186,30 @@
|
|||
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectSysMenList" resultType="com.muyu.system.domain.SysMenu">
|
||||
<include refid="selectMenuVo"/>
|
||||
<where>
|
||||
menu_id in(
|
||||
<foreach collection="longs" separator="," item="id">
|
||||
#{id}
|
||||
</foreach>
|
||||
)
|
||||
</where>
|
||||
order by parent_id,order_num
|
||||
</select>
|
||||
|
||||
<select id="selectSysChdMenuList" resultType="com.muyu.system.domain.SysMenu">
|
||||
<include refid="selectMenuVo"/>
|
||||
<where>
|
||||
parent_id in(
|
||||
<foreach collection="longs" separator="," item="id">
|
||||
#{id}
|
||||
</foreach>
|
||||
)
|
||||
</where>
|
||||
order by parent_id,order_num
|
||||
</select>
|
||||
|
||||
<update id="updateMenu" parameterType="com.muyu.system.domain.SysMenu">
|
||||
update sys_menu
|
||||
<set>
|
||||
|
|
|
@ -50,6 +50,23 @@
|
|||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getNoticeList" resultType="com.muyu.system.domain.resp.SysNoticeResponse">
|
||||
select id,a.notice_id,is_read,a.create_by,a.create_time,notice_title,notice_content,notice_type
|
||||
from as_user_dept a join sys_notice n on a.notice_id=n.notice_id\
|
||||
where a.user_id=#{userId}
|
||||
<if test="isRead !=null and isRead!=''">
|
||||
and is_read = #{isRead}
|
||||
</if>
|
||||
<if test="noticeType !=null and noticeType!=''">
|
||||
and n.notice_type = #{noticeType}
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
<select id="selectUser" resultType="java.lang.Long">
|
||||
select user_id from sys_user
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertNotice" parameterType="com.muyu.system.domain.SysNotice">
|
||||
insert into sys_notice (
|
||||
|
|
|
@ -149,10 +149,11 @@
|
|||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
</select>
|
||||
<!-- where u.user_name = #{userName} and u.del_flag = '0'-->
|
||||
|
||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||
<select id="selectUserByUserEmail" parameterType="String" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_name = #{userName} and u.del_flag = '0'
|
||||
where u.user_name = #{email} or u.email =#{email} and u.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
||||
|
@ -183,6 +184,13 @@
|
|||
and del_flag = '0'
|
||||
limit 1
|
||||
</select>
|
||||
<select id="selectDeptUser" resultType="java.lang.Long">
|
||||
select user_id from sys_user where dept_id in (
|
||||
<foreach collection="sectionIds" separator="," item="id">
|
||||
#{id}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<insert id="insertUser" parameterType="com.muyu.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||
insert into sys_user(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9100
|
||||
port: 9105
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
Loading…
Reference in New Issue