Compare commits
28 Commits
main
...
bonus-jyy-
| Author | SHA1 | Date |
|---|---|---|
|
|
a173f521a0 | |
|
|
c7c5f3c2ed | |
|
|
9eb49e1b09 | |
|
|
f34656b648 | |
|
|
3a3737a4cc | |
|
|
94b74fb40f | |
|
|
82b850a2df | |
|
|
4256c87ba1 | |
|
|
eacc7ee926 | |
|
|
d25c7d3aaf | |
|
|
0fa88c2c23 | |
|
|
1c60c16752 | |
|
|
b1c444afce | |
|
|
e9f63daae4 | |
|
|
3ad84d7e76 | |
|
|
a703e153ca | |
|
|
4726c003e6 | |
|
|
0aef68c096 | |
|
|
4017b7c9d4 | |
|
|
2ee1b059c7 | |
|
|
4f564acbaf | |
|
|
4234d37e6c | |
|
|
75a449db83 | |
|
|
4678773451 | |
|
|
72615f513f | |
|
|
d86b20c246 | |
|
|
7528fedced | |
|
|
6f0aa5efe5 |
|
|
@ -3,10 +3,7 @@ package com.bonus.system.api;
|
|||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.bonus.common.core.constant.ServiceNameConstants;
|
||||
import com.bonus.common.core.domain.R;
|
||||
|
|
@ -45,4 +42,7 @@ public interface RemoteFileService
|
|||
*/
|
||||
@PostMapping("/deleteFile")
|
||||
public AjaxResult deleteFile(@RequestParam("objectKey") String objectKey);
|
||||
|
||||
@GetMapping("/getFullFileUrl")
|
||||
public String getFullFileUrl(@RequestParam("fileUrl") String fileUrl);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,11 @@ public class SysDept extends BaseEntity {
|
|||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 部门名称(全称)
|
||||
*/
|
||||
private String deptFullName;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
|
|
@ -308,6 +313,14 @@ public class SysDept extends BaseEntity {
|
|||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
public String getDeptFullName() {
|
||||
return deptFullName;
|
||||
}
|
||||
|
||||
public void setDeptFullName(String deptFullName) {
|
||||
this.deptFullName = deptFullName;
|
||||
}
|
||||
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.bonus.common.core.annotation.Excel.Type;
|
|||
import com.bonus.common.core.annotation.Excels;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import com.bonus.common.core.xss.Xss;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
|
|
@ -45,6 +46,11 @@ public class SysUser extends BaseEntity {
|
|||
@Excel(name = "公司编号", type = Type.IMPORT)
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 用户类型 (00系统用户)
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
|
|
@ -80,6 +86,16 @@ public class SysUser extends BaseEntity {
|
|||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 人脸照片地址
|
||||
*/
|
||||
private String photoUrl;
|
||||
|
||||
/** 生日 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private String birthday;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
|
|
@ -204,6 +220,14 @@ public class SysUser extends BaseEntity {
|
|||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(String userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
@Xss(message = "用户账号不能包含脚本字符")
|
||||
@NotBlank(message = "用户账号不能为空")
|
||||
@Size(min = 0, max = 20, message = "用户账号长度不能超过20个字符")
|
||||
|
|
@ -250,6 +274,23 @@ public class SysUser extends BaseEntity {
|
|||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getPhotoUrl() {
|
||||
return photoUrl;
|
||||
}
|
||||
|
||||
public void setPhotoUrl(String photoUrl) {
|
||||
this.photoUrl = photoUrl;
|
||||
}
|
||||
|
||||
|
||||
public String getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(String birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.bonus.system.api.domain;
|
||||
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
public class SysUserFace extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 人员id */
|
||||
@ApiModelProperty(value = "人员id")
|
||||
//@NotBlank(message = "人员id必填")
|
||||
private Long userId;
|
||||
|
||||
/** 照片地址 */
|
||||
@ApiModelProperty(value = "照片地址")
|
||||
//@NotBlank(message = "照片地址必填")
|
||||
private String photoUrl;
|
||||
|
||||
}
|
||||
|
|
@ -41,6 +41,11 @@ public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileServ
|
|||
public AjaxResult deleteFile(String objectKey) {
|
||||
return AjaxResult.error("删除文件失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullFileUrl(String fileUrl) {
|
||||
return "获取文件完整路径失败";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.bonus.common.core.domain.R;
|
|||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.JwtUtils;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.redis.service.RedisService;
|
||||
import com.bonus.common.security.auth.AuthUtil;
|
||||
|
|
@ -152,8 +153,11 @@ public class TokenController {
|
|||
return R.fail("当前系统用户并发数超过系统配置,请稍后再试");
|
||||
}
|
||||
|
||||
LoginUser login = strategy.login(form.getUsername(), form.getPassword());
|
||||
logService.saveLogin(form.getUsername(), "登录", "登录成功", null, "成功");
|
||||
String username = Sm4Utils.decrypt(form.getUsername());
|
||||
String password = Sm4Utils.decrypt(form.getPassword());
|
||||
|
||||
LoginUser login = strategy.login(username, password);
|
||||
logService.saveLogin(username, "登录", "登录成功", null, "成功");
|
||||
return R.ok(tokenService.createToken(login));
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 58081
|
||||
port: 48381
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ spring:
|
|||
name: bonus-auth
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
active: jyy_canteen_local
|
||||
|
||||
#加密组件
|
||||
jasypt:
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class Sm4Utils {
|
|||
|
||||
// 测试方法,演示加密和解密过程
|
||||
public static void main(String[] args) {
|
||||
String plainText = "15398187429";
|
||||
String plainText = "admin";
|
||||
System.out.println("原文: " + plainText);
|
||||
|
||||
// 加密明文
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class TokenService {
|
|||
*/
|
||||
public Map<String, Object> createToken(LoginUser loginUser) {
|
||||
// 检查并删除已有的token
|
||||
delExistingToken(loginUser.getSysUser().getUserId());
|
||||
//delExistingToken(loginUser.getSysUser().getUserId());
|
||||
String token = IdUtils.fastUUID();
|
||||
Long userId = loginUser.getSysUser().getUserId();
|
||||
String userName = loginUser.getSysUser().getUserName();
|
||||
|
|
@ -206,8 +206,12 @@ public class TokenService {
|
|||
private Long getTokenTime(){
|
||||
long tokenTime = 20L;
|
||||
String redisResult = redisService.getCacheObject("sys_config:"+ "sys.visit.tokentime");
|
||||
if(!redisResult.isEmpty()) {
|
||||
tokenTime = Long.parseLong(redisResult);
|
||||
if(StringUtils.isNotEmpty(redisResult)) {
|
||||
try {
|
||||
tokenTime = Long.parseLong(redisResult);
|
||||
} catch (Exception e) {
|
||||
tokenTime = 43200L; //MINUTES
|
||||
}
|
||||
}else {
|
||||
Long result = systemConfig.getTokenTime();
|
||||
if (!ObjectUtil.isEmpty(result)){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.bonus.gateway.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.reactive.CorsWebFilter;
|
||||
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.util.pattern.PathPatternParser;
|
||||
|
||||
/**
|
||||
* Description: 全局跨域配置
|
||||
*/
|
||||
@Configuration
|
||||
public class GlobalCorsConfig {
|
||||
@Bean
|
||||
public CorsWebFilter corsFilter() {
|
||||
// 创建一个新的CorsConfiguration对象,用于配置跨域请求
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
// 允许所有的HTTP请求方法(GET, POST, PUT, DELETE等)
|
||||
config.addAllowedMethod("*");
|
||||
// 允许所有的域名发起的请求 比如http://localhost:8080、
|
||||
config.addAllowedOrigin("*");
|
||||
// 允许所有的域名发起的请求(支持正则表达式) 比如http://localhost:8080
|
||||
config.addAllowedOriginPattern("*");
|
||||
// 允许所有的请求头部信息 比如token、Content-Type
|
||||
config.addAllowedHeader("*");
|
||||
// 创建一个UrlBasedCorsConfigurationSource对象,并使用PathPatternParser进行路径匹配
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
|
||||
// 注册跨域配置,应用于所有的URL路径
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
return new CorsWebFilter(source);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 58080
|
||||
port: 48380
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ spring:
|
|||
name: bonus-gateway
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
active: jyy_canteen_local
|
||||
|
||||
#加密组件
|
||||
jasypt:
|
||||
|
|
|
|||
|
|
@ -102,6 +102,11 @@ public class SysFileController
|
|||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getFullFileUrl")
|
||||
public String getFullFileUrl(@RequestParam String fileUrl) throws Exception {
|
||||
return sysFileService.getFullFileUrl(fileUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件删除
|
||||
* 从各个存储平台删除文件
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ public interface ISysFileService
|
|||
*/
|
||||
public void downloadFile(HttpServletResponse response, String urlStr) throws Exception;
|
||||
|
||||
public String getFullFileUrl(String urlStr) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 从给定的URL下载文件并将其保存到指定的目标位置。
|
||||
|
|
|
|||
|
|
@ -104,6 +104,11 @@ public class FastDfsSysFileServiceImpl implements ISysFileService
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullFileUrl(String urlStr) throws Exception {
|
||||
return urlStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从给定的URL下载文件并将其保存到指定的目标位置。
|
||||
*
|
||||
|
|
|
|||
|
|
@ -78,6 +78,11 @@ public class LocalSysFileServiceImpl implements ISysFileService
|
|||
FileDownloadUtils.downloadFile(response, urlStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullFileUrl(String urlStr) throws Exception {
|
||||
return urlStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从给定的URL下载文件并将其保存到指定的目标位置。
|
||||
*
|
||||
|
|
|
|||
|
|
@ -116,6 +116,11 @@ public class MinioServiceImpl implements ISysFileService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullFileUrl(String urlStr) throws Exception {
|
||||
return minioUtil.getFullFileUrl(urlStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从给定的URL下载文件并将其保存到指定的目标位置。
|
||||
*
|
||||
|
|
|
|||
|
|
@ -113,6 +113,11 @@ public class MongodbServiceImpl implements ISysFileService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullFileUrl(String urlStr) throws Exception {
|
||||
return urlStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从给定的URL下载文件并将其保存到指定的目标位置。
|
||||
*
|
||||
|
|
|
|||
|
|
@ -102,6 +102,11 @@ public class ObsServiceImpl implements ISysFileService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullFileUrl(String urlStr) throws Exception {
|
||||
return urlStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从给定的URL下载文件并将其保存到指定的目标位置。
|
||||
*
|
||||
|
|
|
|||
|
|
@ -115,6 +115,11 @@ public class OssServiceImpl implements ISysFileService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullFileUrl(String urlStr) throws Exception {
|
||||
return urlStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从给定的URL下载文件并将其保存到指定的目标位置。
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.file.utils;
|
||||
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.file.config.MinioConfig;
|
||||
import com.bonus.file.entity.FileDetails;
|
||||
import com.bonus.system.api.domain.SysFile;
|
||||
|
|
@ -298,6 +299,18 @@ public class MinioUtil {
|
|||
return getFileUrl(bucketName, objectName, 604800);
|
||||
}
|
||||
|
||||
public String getFullFileUrl(String fileUrl) throws Exception {
|
||||
if (StringUtils.isNotEmpty(fileUrl)){
|
||||
if (fileUrl.startsWith("http://")) {
|
||||
return fileUrl;
|
||||
} else {
|
||||
return minioConfig.getEndpoint() + "/" + minioConfig.getBucketName() + "/" + fileUrl;
|
||||
}
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除指定的对象
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 59300
|
||||
port: 48383
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ spring:
|
|||
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
active: jyy_canteen_local
|
||||
|
||||
#加密组件
|
||||
jasypt:
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class SysNoticeController extends BaseController
|
|||
/**
|
||||
* 获取通知公告列表
|
||||
*/
|
||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:notice:list"))
|
||||
//@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:notice:list"))
|
||||
@GetMapping("/list")
|
||||
@SysLog(title = "通知公告", businessType = OperaType.QUERY,logType = 0,module = "系统管理->通知公告")
|
||||
public TableDataInfo list(SysNotice notice) {
|
||||
|
|
@ -59,7 +59,7 @@ public class SysNoticeController extends BaseController
|
|||
/**
|
||||
* 根据通知公告编号获取详细信息
|
||||
*/
|
||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:notice:query"))
|
||||
//@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:notice:query"))
|
||||
@GetMapping(value = "/{noticeId}")
|
||||
public AjaxResult getInfo(@PathVariable Long noticeId) {
|
||||
try{
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ public class SysProfileController extends BaseController {
|
|||
try {
|
||||
String username = SecurityUtils.getUsername();
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
user.setAvatar(remoteFileService.getFullFileUrl(user.getAvatar()));
|
||||
AjaxResult ajax = AjaxResult.success(user);
|
||||
ajax.put("roleGroup", userService.selectUserRoleGroup(username));
|
||||
ajax.put("postGroup", userService.selectUserPostGroup(username));
|
||||
|
|
@ -152,9 +153,9 @@ public class SysProfileController extends BaseController {
|
|||
String url = fileResult.getDataAs(SysFile.class).getUrl();
|
||||
if (userService.updateUserAvatar(loginUser.getUsername(), url)) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("imgUrl", url);
|
||||
ajax.put("imgUrl", remoteFileService.getFullFileUrl(url));
|
||||
// 更新缓存用户头像
|
||||
loginUser.getSysUser().setAvatar(url);
|
||||
loginUser.getSysUser().setAvatar(remoteFileService.getFullFileUrl(url));
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return ajax;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.bonus.common.security.annotation.PreventRepeatSubmit;
|
|||
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.system.api.RemoteFileService;
|
||||
import com.bonus.system.api.domain.SysDept;
|
||||
import com.bonus.system.api.domain.SysRole;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
|
|
@ -73,6 +74,9 @@ public class SysUserController extends BaseController {
|
|||
@Autowired
|
||||
private ISysLogService sysLogService;
|
||||
|
||||
@Autowired
|
||||
RemoteFileService remoteFileService;
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
|
|
@ -234,6 +238,8 @@ public class SysUserController extends BaseController {
|
|||
public AjaxResult getInfo() {
|
||||
try {
|
||||
SysUser user = userService.selectUserById(SecurityUtils.getUserId());
|
||||
user.setAvatar(remoteFileService.getFullFileUrl(user.getAvatar()));
|
||||
user.setPhotoUrl(remoteFileService.getFullFileUrl(user.getPhotoUrl()));
|
||||
user.setPassword(null);
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(user);
|
||||
|
|
@ -265,6 +271,7 @@ public class SysUserController extends BaseController {
|
|||
if (StringUtils.isNotNull(userId)) {
|
||||
SysUser sysUser = userService.selectUserById(userId);
|
||||
sysUser.setPassword(null);
|
||||
sysUser.setPhotoUrl(remoteFileService.getFullFileUrl(sysUser.getPhotoUrl()));
|
||||
ajax.put(AjaxResult.DATA_TAG, sysUser);
|
||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
||||
|
|
@ -334,8 +341,8 @@ public class SysUserController extends BaseController {
|
|||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:user:edit"))
|
||||
@PostMapping("/edit")
|
||||
//@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:user:edit"))
|
||||
@PostMapping("/edit")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.UPDATE, logType = 0, module = "系统管理->用户管理", details = "修改用户信息")
|
||||
public AjaxResult edit(@Validated @RequestBody SysUser user) {
|
||||
try {
|
||||
|
|
@ -359,6 +366,7 @@ public class SysUserController extends BaseController {
|
|||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.bonus.system.feign;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.domain.SysUserFace;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(value="bonus-smart-canteen")
|
||||
@Service
|
||||
@Component
|
||||
public interface SmartCanteenClient {
|
||||
|
||||
@ApiOperation(value = "新增账户")
|
||||
@RequestMapping(value = "/acc_info/sync",method = RequestMethod.POST)
|
||||
AjaxResult syncAccInfo(SysUser sysUser);
|
||||
|
||||
@ApiOperation(value = "删除账户")
|
||||
@RequestMapping(value = "/acc_info/deleteAccInfoByUserIds",method = RequestMethod.POST)
|
||||
AjaxResult deleteAccInfoByUserIds(List<SysUser> users);
|
||||
|
||||
@ApiOperation(value = "上传人脸特征")
|
||||
@RequestMapping(value = "/userFace/uploadUserFace",method = RequestMethod.POST)
|
||||
AjaxResult uploadUserFace(SysUserFace sysUserFace);
|
||||
}
|
||||
|
|
@ -135,6 +135,8 @@ public interface SysDeptMapper
|
|||
*/
|
||||
public int updateDeptChildren(@Param("depts") List<SysDept> depts);
|
||||
|
||||
public int updateDeptChildrenFullName(@Param("depts") List<SysDept> depts);
|
||||
|
||||
/**
|
||||
* 删除部门管理信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -310,6 +310,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
if (dept.getParentId() == null){
|
||||
dept.setParentId(0L);
|
||||
dept.setAncestors("0");
|
||||
dept.setDeptFullName(dept.getDeptName());
|
||||
dept.setStatus("0");//默认启用
|
||||
int result = deptMapper.insertDept(dept);
|
||||
if (SecurityUtils.isAdmin(SecurityUtils.getUserId()) && systemConfig.isAddRootCompany() && result > 0) {
|
||||
|
|
@ -327,6 +328,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
throw new ServiceException("部门停用,不允许新增");
|
||||
}
|
||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||
dept.setDeptFullName(info.getDeptFullName() + "/" + dept.getDeptName());
|
||||
return deptMapper.insertDept(dept);
|
||||
}
|
||||
}
|
||||
|
|
@ -350,6 +352,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
dept.setAncestors(newAncestors);
|
||||
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
||||
}
|
||||
updateDeptChildrenFullName(dept, newParentDept);
|
||||
int result = deptMapper.updateDept(dept);
|
||||
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
||||
&& !StringUtils.equals("0", dept.getAncestors()))
|
||||
|
|
@ -360,7 +363,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
//判断是否需要修改公司管理员用户信息
|
||||
if (SecurityUtils.isAdmin(SecurityUtils.getUserId()) && systemConfig.isAddRootCompany() && Objects.nonNull(dept.getParentId()) && dept.getParentId().equals(0L)){
|
||||
SysUser companyAdminUser = dept.getSysUser();
|
||||
if (Objects.nonNull(companyAdminUser.getRoleId())) {
|
||||
if (Objects.nonNull(companyAdminUser) && Objects.nonNull(companyAdminUser.getRoleId())) {
|
||||
companyAdminUser.setUpdateBy(SecurityUtils.getUsername());
|
||||
companyAdminUser.setUpdateTime(DateUtils.getNowDate());
|
||||
roleMenuMapper.deleteRoleMenuByRoleId(companyAdminUser.getRoleId());
|
||||
|
|
@ -371,6 +374,38 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
return result;
|
||||
}
|
||||
|
||||
public void updateDeptChildrenFullName(SysDept dept, SysDept newParentDept)
|
||||
{
|
||||
if (Objects.isNull(newParentDept)) {
|
||||
dept.setDeptFullName(dept.getDeptName());
|
||||
} else {
|
||||
dept.setDeptFullName(newParentDept.getDeptFullName() + "/" + dept.getDeptName());
|
||||
}
|
||||
List<SysDept> children = deptMapper.selectChildrenDeptById(dept.getDeptId());
|
||||
List<SysDept> fullDeptList = deptMapper.selectDeptList(new SysDept());
|
||||
for (SysDept innerDept : fullDeptList) {
|
||||
if (innerDept.getDeptId().equals(dept.getDeptId())) {
|
||||
innerDept.setDeptName(dept.getDeptName());
|
||||
}
|
||||
}
|
||||
for (SysDept child : children) {
|
||||
if (child.getDeptId().equals(dept.getDeptId())) {
|
||||
child.setDeptName(dept.getDeptName());
|
||||
}
|
||||
}
|
||||
for (SysDept child : children) {
|
||||
String deptAncestors = child.getAncestors();
|
||||
deptAncestors = deptAncestors.replaceFirst("0,", "").replaceAll(",", "/");
|
||||
for (SysDept innerDept : fullDeptList) {
|
||||
deptAncestors = deptAncestors.replace(String.valueOf(innerDept.getDeptId()), innerDept.getDeptName());
|
||||
}
|
||||
child.setDeptFullName(deptAncestors + "/" + child.getDeptName());
|
||||
}
|
||||
if (children.size() > 0) {
|
||||
deptMapper.updateDeptChildrenFullName(children);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改该部门的父级部门状态
|
||||
*
|
||||
|
|
|
|||
|
|
@ -15,11 +15,9 @@ import com.bonus.common.datascope.annotation.DataScope;
|
|||
import com.bonus.common.datascope.utils.CommonDataPermissionInfo;
|
||||
import com.bonus.common.security.config.VerificationCodeConfig;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.system.api.domain.SysPost;
|
||||
import com.bonus.system.api.domain.SysRole;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.domain.SysUserRole;
|
||||
import com.bonus.system.api.domain.*;
|
||||
import com.bonus.system.domain.SysUserPost;
|
||||
import com.bonus.system.feign.SmartCanteenClient;
|
||||
import com.bonus.system.mapper.*;
|
||||
import com.bonus.system.service.ISysConfigService;
|
||||
import com.bonus.system.service.ISysDeptService;
|
||||
|
|
@ -80,6 +78,9 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
@Autowired
|
||||
private JavaMailSender mailSender; // 自动注入JavaMailSender,用于发送邮件
|
||||
|
||||
@Resource
|
||||
private SmartCanteenClient smartCanteenClient;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
|
|
@ -332,6 +333,10 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
insertUserPost(user);
|
||||
// 新增用户与角色管理
|
||||
insertUserRole(user);
|
||||
// 同步创建账户数据
|
||||
smartCanteenClient.syncAccInfo(user);
|
||||
// 同步更新user face数据
|
||||
uploadUserFace(user);
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
|
@ -364,9 +369,23 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
userPostMapper.deleteUserPostByUserId(userId);
|
||||
// 新增用户与岗位管理
|
||||
insertUserPost(user);
|
||||
// 同步更新user face数据
|
||||
uploadUserFace(user);
|
||||
// 更新用户
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
private void uploadUserFace(SysUser user) {
|
||||
try {
|
||||
SysUserFace sysUserFace = new SysUserFace();
|
||||
sysUserFace.setUserId(user.getUserId());
|
||||
sysUserFace.setPhotoUrl(user.getPhotoUrl());
|
||||
smartCanteenClient.uploadUserFace(sysUserFace);
|
||||
} catch (Exception e) {
|
||||
log.error("上传人脸失败, ", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权角色
|
||||
*
|
||||
|
|
@ -519,6 +538,15 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
userRoleMapper.deleteUserRole(userIds);
|
||||
// 删除用户与岗位关联
|
||||
userPostMapper.deleteUserPost(userIds);
|
||||
// 同步删除账户信息
|
||||
List<SysUser> users = new ArrayList<>();
|
||||
for (int i = 0; i < userIds.length; i++) {
|
||||
SysUser user = new SysUser();
|
||||
user.setUserId(userIds[i]);
|
||||
users.add(user);
|
||||
}
|
||||
smartCanteenClient.deleteAccInfoByUserIds(users);
|
||||
|
||||
return userMapper.deleteUserByIds(userIds);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 58082
|
||||
port: 48382
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ spring:
|
|||
name: bonus-system
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
active: jyy_canteen_local
|
||||
task:
|
||||
scheduling:
|
||||
pool:
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="parentId" column="parent_id" />
|
||||
<result property="ancestors" column="ancestors" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
<result property="deptFullName" column="dept_full_name" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="leader" column="leader" />
|
||||
<result property="phone" column="phone" />
|
||||
|
|
@ -37,6 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
d.parent_id,
|
||||
d.ancestors,
|
||||
d.dept_name,
|
||||
d.dept_full_name,
|
||||
d.order_num,
|
||||
d.leader,
|
||||
d.phone,
|
||||
|
|
@ -53,6 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
d.parent_id,
|
||||
d.ancestors,
|
||||
d.dept_name,
|
||||
d.dept_full_name,
|
||||
d.order_num,
|
||||
d.leader,
|
||||
d.phone,
|
||||
|
|
@ -192,6 +195,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||
<if test="parentId != null and parentId != 0">parent_id,</if>
|
||||
<if test="deptName != null and deptName != ''">dept_name,</if>
|
||||
<if test="deptFullName != null and deptFullName != ''">dept_full_name,</if>
|
||||
<if test="ancestors != null and ancestors != ''">ancestors,</if>
|
||||
<if test="orderNum != null">order_num,</if>
|
||||
<if test="leader != null and leader != ''">leader,</if>
|
||||
|
|
@ -213,6 +217,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="deptId != null and deptId != 0">#{deptId},</if>
|
||||
<if test="parentId != null and parentId != 0">#{parentId},</if>
|
||||
<if test="deptName != null and deptName != ''">#{deptName},</if>
|
||||
<if test="deptFullName != null and deptFullName != ''">#{deptFullName},</if>
|
||||
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
|
||||
<if test="orderNum != null">#{orderNum},</if>
|
||||
<if test="leader != null and leader != ''">#{leader},</if>
|
||||
|
|
@ -238,6 +243,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<set>
|
||||
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
|
||||
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
|
||||
<if test="deptFullName != null and deptFullName != ''">dept_full_name = #{deptFullName},</if>
|
||||
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
|
||||
<if test="orderNum != null">order_num = #{orderNum},</if>
|
||||
<if test="leader != null">leader = #{leader},</if>
|
||||
|
|
@ -273,6 +279,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateDeptChildrenFullName" parameterType="java.util.List">
|
||||
update sys_dept set dept_full_name =
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
separator=" " open="case dept_id" close="end">
|
||||
when #{item.deptId} then #{item.deptFullName}
|
||||
</foreach>
|
||||
where dept_id in
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
separator="," open="(" close=")">
|
||||
#{item.deptId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateDeptStatusNormal" parameterType="Long">
|
||||
update sys_dept set status = '0' where dept_id in
|
||||
<foreach collection="array" item="deptId" open="(" separator="," close=")">
|
||||
|
|
|
|||
|
|
@ -8,12 +8,15 @@
|
|||
<id property="userId" column="user_id"/>
|
||||
<result property="deptId" column="dept_id"/>
|
||||
<result property="companyId" column="company_id"/>
|
||||
<result property="userType" column="user_type"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
<result property="nickName" column="nick_name"/>
|
||||
<result property="email" column="email"/>
|
||||
<result property="phonenumber" column="phonenumber"/>
|
||||
<result property="sex" column="sex"/>
|
||||
<result property="avatar" column="avatar"/>
|
||||
<result property="photoUrl" column="photo_url"/>
|
||||
<result property="birthday" column="birthday"/>
|
||||
<result property="password" column="password"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
|
|
@ -61,10 +64,13 @@
|
|||
ELSE
|
||||
SUBSTRING_INDEX(SUBSTRING_INDEX(d.ancestors, ',', 2), ',', -1)
|
||||
END as company_id,
|
||||
u.user_type,
|
||||
u.user_name,
|
||||
u.nick_name,
|
||||
u.email,
|
||||
u.avatar,
|
||||
u.photo_url,
|
||||
u.birthday,
|
||||
u.phonenumber,
|
||||
u.password,
|
||||
u.sex,
|
||||
|
|
@ -100,7 +106,7 @@
|
|||
</sql>
|
||||
|
||||
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber,u.sex, u.status,
|
||||
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber,u.sex, u.status, u.birthday,
|
||||
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.approval_status,u.is_permanent,u.is_built_in, d.dept_name,
|
||||
d.leader,r.role_id,
|
||||
r.role_name,
|
||||
|
|
@ -262,10 +268,12 @@
|
|||
insert into sys_user(
|
||||
<if test="userId != null and userId != 0">user_id,</if>
|
||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||
<if test="userType != null and userType != ''">user_type,</if>
|
||||
<if test="userName != null and userName != ''">user_name,</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name,</if>
|
||||
<if test="email != null and email != ''">email,</if>
|
||||
<if test="avatar != null and avatar != ''">avatar,</if>
|
||||
<if test="birthday != null and birthday != ''">birthday,</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
|
||||
<if test="sex != null and sex != ''">sex,</if>
|
||||
<if test="password != null and password != ''">password,</if>
|
||||
|
|
@ -276,14 +284,16 @@
|
|||
<if test="approvalStatus != null and approvalStatus!=''">approval_status,</if>
|
||||
<if test="isPermanent != null and isPermanent!=''">is_permanent,</if>
|
||||
<if test="isBuiltIn != null and isBuiltIn!=''">is_built_in,</if>
|
||||
create_time
|
||||
create_time, update_time
|
||||
)values(
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||
<if test="userType != null and userType != ''">#{userType},</if>
|
||||
<if test="userName != null and userName != ''">#{userName},</if>
|
||||
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
||||
<if test="email != null and email != ''">#{email},</if>
|
||||
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
||||
<if test="birthday != null and birthday != ''">#{birthday},</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
|
||||
<if test="sex != null and sex != ''">#{sex},</if>
|
||||
<if test="password != null and password != ''">#{password},</if>
|
||||
|
|
@ -294,7 +304,7 @@
|
|||
<if test="approvalStatus != null and approvalStatus!=''">#{approvalStatus},</if>
|
||||
<if test="isPermanent != null and isPermanent!=''">#{isPermanent},</if>
|
||||
<if test="isBuiltIn != null and isBuiltIn!=''">#{isBuiltIn},</if>
|
||||
sysdate()
|
||||
sysdate(), sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
|
@ -302,12 +312,15 @@
|
|||
update sys_user
|
||||
<set>
|
||||
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
||||
<if test="userType != null and userType != ''">user_type = #{userType},</if>
|
||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||
<if test="email != null ">email = #{email},</if>
|
||||
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
||||
<if test="sex != null and sex != ''">sex = #{sex},</if>
|
||||
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
||||
<if test="photoUrl != null and photoUrl != ''">photo_url = #{photoUrl},</if>
|
||||
<if test="birthday != null and birthday != ''">birthday = #{birthday},</if>
|
||||
<if test="password != null and password != ''">password = #{password},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
-- 照片地址
|
||||
alter table sys_user
|
||||
add photo_url varchar(255) null comment '照片地址';
|
||||
|
||||
-- 生日
|
||||
alter table sys_user
|
||||
add birthday date null comment '生日';
|
||||
|
||||
-- 组织全称
|
||||
alter table sys_dept
|
||||
add dept_full_name varchar(1000) null comment '组织全称';
|
||||
Loading…
Reference in New Issue