@@ -64,6 +64,8 @@ | |||
<artifactId>easyexcel</artifactId> | |||
<version>1.1.2-beat1</version> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@@ -0,0 +1,71 @@ | |||
package com.tuoheng.common.core.config; | |||
import lombok.Data; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.context.annotation.Configuration; | |||
@Configuration | |||
@Data | |||
public class CommonConfig { | |||
/** | |||
* 图片域名 | |||
*/ | |||
public static String imageURL; | |||
/** | |||
* OSS域名 | |||
*/ | |||
public static String ossURL; | |||
/** | |||
* 视频域名 | |||
*/ | |||
public static String videoURL; | |||
/** | |||
* 高德KEY | |||
*/ | |||
public static String gaodeKey; | |||
/** | |||
* 图片域名赋值 | |||
* | |||
* @param url 域名地址 | |||
*/ | |||
@Value("${tuoheng.image-url}") | |||
public void setImageURL(String url) { | |||
imageURL = url; | |||
} | |||
/** | |||
* 阿里云OSS域名 | |||
* | |||
* @param url 图片地址 | |||
*/ | |||
@Value("${tuoheng.oss-url}") | |||
public void setOssURL(String url) { | |||
ossURL = url; | |||
} | |||
/** | |||
* 视频域名赋值 | |||
* | |||
* @param url 域名地址 | |||
*/ | |||
@Value("${tuoheng.video-url}") | |||
public void setVideoURL(String url) { | |||
videoURL = url; | |||
} | |||
/** | |||
* 高德KEY赋值 | |||
* | |||
* @param key 高德KEY | |||
*/ | |||
@Value("${tuoheng.gaodeKey}") | |||
public void setGaodeKey(String key) { | |||
gaodeKey = key; | |||
} | |||
} |
@@ -0,0 +1,68 @@ | |||
package com.tuoheng.common.core.enums; | |||
/** | |||
* 日志类型 | |||
*/ | |||
public enum LogType { | |||
/** | |||
* 其它 | |||
*/ | |||
OTHER, | |||
/** | |||
* 新增 | |||
*/ | |||
INSERT, | |||
/** | |||
* 修改 | |||
*/ | |||
UPDATE, | |||
/** | |||
* 删除 | |||
*/ | |||
DELETE, | |||
/** | |||
* 授权 | |||
*/ | |||
GRANT, | |||
/** | |||
* 导出 | |||
*/ | |||
EXPORT, | |||
/** | |||
* 导入 | |||
*/ | |||
IMPORT, | |||
/** | |||
* 强退 | |||
*/ | |||
FORCE, | |||
/** | |||
* 生成代码 | |||
*/ | |||
GENCODE, | |||
/** | |||
* 清空数据 | |||
*/ | |||
CLEAN, | |||
/** | |||
* 状态 | |||
*/ | |||
STATUS, | |||
/** | |||
* 重置密码 | |||
*/ | |||
RESETPWD, | |||
} |
@@ -0,0 +1,297 @@ | |||
package com.tuoheng.common.core.utils; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.common.core.config.CommonConfig; | |||
import org.springframework.util.CollectionUtils; | |||
import java.lang.reflect.Field; | |||
import java.security.MessageDigest; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.function.Consumer; | |||
import java.util.regex.Matcher; | |||
import java.util.regex.Pattern; | |||
import java.util.stream.Collectors; | |||
/** | |||
* 公共函数类 | |||
*/ | |||
public class CommonUtils { | |||
/** | |||
* 获取到图片域名的地址 | |||
* | |||
* @param imageUrl | |||
* @return | |||
*/ | |||
public static String getImageURL(String imageUrl) { | |||
return CommonConfig.imageURL + imageUrl; | |||
} | |||
/** | |||
* 正则匹配富文本图片 | |||
* | |||
* @param htmlStr 富文本内容 | |||
* @return | |||
*/ | |||
public static List<String> getImgStr(String htmlStr) { | |||
Pattern p_image = Pattern.compile("<img.*src\\s*=\\s*(.*?)[^>]*?>", Pattern.CASE_INSENSITIVE); | |||
Pattern r_image = Pattern.compile("src\\s*=\\s*\"?(.*?)(\"|>|\\s+)"); | |||
List<String> list = new ArrayList<>(); | |||
Matcher m_image = p_image.matcher(htmlStr); | |||
while (m_image.find()) { | |||
// 得到<img />数据 | |||
String img = m_image.group(); | |||
System.out.println(img); | |||
// 匹配<img>中的src数据 | |||
Matcher m = r_image.matcher(img); | |||
while (m.find()) { | |||
list.add(m.group(1)); | |||
} | |||
} | |||
return list; | |||
} | |||
/** | |||
* 验证邮箱是否正确 | |||
* | |||
* @param email | |||
* @return | |||
*/ | |||
public static boolean isEmail(String email) { | |||
boolean flag = false; | |||
try { | |||
String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; | |||
Pattern regex = Pattern.compile(check); | |||
Matcher matcher = regex.matcher(email); | |||
flag = matcher.matches(); | |||
} catch (Exception e) { | |||
flag = false; | |||
} | |||
return flag; | |||
} | |||
/** | |||
* 验证手机号是否正确 | |||
* | |||
* @param mobile | |||
* @return | |||
*/ | |||
public static boolean isMobile(String mobile) { | |||
boolean flag = false; | |||
try { | |||
Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"); | |||
Matcher m = p.matcher(mobile); | |||
flag = m.matches(); | |||
} catch (Exception e) { | |||
flag = false; | |||
} | |||
return flag; | |||
} | |||
/** | |||
* 生成指定位数的随机字符串 | |||
* | |||
* @param isNum 是否是纯数字 | |||
* @param length 长度 | |||
* @return | |||
*/ | |||
public static String getRandomStr(boolean isNum, int length) { | |||
String resultStr = ""; | |||
String str = isNum ? "1234567890" : "1234567890abcdefghijkmnpqrstuvwxyz"; | |||
int len = str.length(); | |||
boolean isStop = true; | |||
do { | |||
resultStr = ""; | |||
int count = 0; | |||
for (int i = 0; i < length; i++) { | |||
double dblR = Math.random() * len; | |||
int intR = (int) Math.floor(dblR); | |||
char c = str.charAt(intR); | |||
if (('0' <= c) && (c <= '9')) { | |||
count++; | |||
} | |||
resultStr += str.charAt(intR); | |||
} | |||
if (count >= 2) { | |||
isStop = false; | |||
} | |||
} while (isStop); | |||
return resultStr; | |||
} | |||
/** | |||
* 判断是否在数组中 | |||
* | |||
* @param s | |||
* @param array | |||
* @return | |||
*/ | |||
public static boolean inArray(final String s, final String[] array) { | |||
for (String item : array) { | |||
if (item != null && item.equals(s)) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
/** | |||
* 从html中提取纯文本 | |||
* | |||
* @param strHtml | |||
* @return | |||
*/ | |||
public static String stripHtml(String strHtml) { | |||
String content = strHtml.replaceAll("</?[^>]+>", ""); //剔出<html>的标签 | |||
content = content.replaceAll("\\s*|\t|\r|\n", "");//去除字符串中的空格,回车,换行符,制表符 | |||
return content; | |||
} | |||
/** | |||
* 去除字符串中的空格、回车、换行符、制表符等 | |||
* | |||
* @param str 原始字符串 | |||
* @return | |||
*/ | |||
public static String replaceSpecialStr(String str) { | |||
String repl = ""; | |||
if (str != null) { | |||
Pattern p = Pattern.compile("\\s*|\t|\r|\n"); | |||
Matcher m = p.matcher(str); | |||
repl = m.replaceAll(""); | |||
} | |||
return repl; | |||
} | |||
/** | |||
* 判断某个元素是否在数组中 | |||
* | |||
* @param key 元素 | |||
* @param map 数组 | |||
* @return | |||
*/ | |||
public static boolean inArray(String key, Map<String, String> map) { | |||
boolean flag = false; | |||
for (String k : map.keySet()) { | |||
if (k.equals(key)) { | |||
flag = true; | |||
} | |||
} | |||
return flag; | |||
} | |||
/** | |||
* 对象转Map | |||
* | |||
* @param obj 对象 | |||
* @return | |||
* @throws IllegalAccessException | |||
*/ | |||
public static Map<String, Object> objectToMap(Object obj) throws IllegalAccessException { | |||
Map<String, Object> map = new HashMap<>(); | |||
Class<?> clazz = obj.getClass(); | |||
for (Field field : clazz.getDeclaredFields()) { | |||
field.setAccessible(true); | |||
String fieldName = field.getName(); | |||
Object value = field.get(obj); | |||
map.put(fieldName, value); | |||
} | |||
return map; | |||
} | |||
/** | |||
* 判断是否是JSON格式 | |||
* | |||
* @param str JSON字符串 | |||
* @return | |||
*/ | |||
private boolean isJson(String str) { | |||
try { | |||
JSONObject jsonStr = JSONObject.parseObject(str); | |||
return true; | |||
} catch (Exception e) { | |||
return false; | |||
} | |||
} | |||
/** | |||
* MD5方法 | |||
* | |||
* @param source | |||
* @return | |||
*/ | |||
public static String md5(byte[] source) { | |||
try { | |||
MessageDigest md = MessageDigest.getInstance("MD5"); | |||
md.update(source); | |||
StringBuffer buf = new StringBuffer(); | |||
for (byte b : md.digest()) { | |||
buf.append(String.format("%02x", b & 0xff)); | |||
} | |||
return buf.toString(); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return null; | |||
} | |||
} | |||
/** | |||
* 密码加密 | |||
* | |||
* @param password 密码 | |||
* @return | |||
*/ | |||
public static String password(String password) { | |||
String md51 = md5(password.getBytes()); | |||
String pwd = md5((md51 + "IgtUdEQJyVevaCxQnY").getBytes()); | |||
return pwd; | |||
} | |||
/** | |||
* 对数组进行分组 | |||
* | |||
* @param list 数据源 | |||
* @param size 每组几个 | |||
* @param <T> | |||
* @return | |||
*/ | |||
public static <T> List<List<T>> split(List<T> list, Integer size) { | |||
if (CollectionUtils.isEmpty(list)) { | |||
return new ArrayList<>(); | |||
} | |||
Integer count = list.size() / size; | |||
List<List<T>> arrayList = new ArrayList<>(); | |||
for (int i = 0; i < count; i++) { | |||
List<T> temp = list.subList(i * size, (i + 1) * size); | |||
arrayList.add(temp); | |||
} | |||
Integer extra = list.size() % size; | |||
if (extra != 0) { | |||
List<T> temp = list.subList(count * size, count * size + extra); | |||
arrayList.add(temp); | |||
} | |||
return arrayList; | |||
} | |||
/** | |||
* 批量处理方法 | |||
* | |||
* @param operater 回调方法,有入参无返回值 | |||
* @param sourceList 批量处理list对象 | |||
* @param threshold 阀值,比如有5000个对象,阀值设置1000,就是1000执行一次 | |||
* @param <T> 对象类型 | |||
*/ | |||
public static <T> void batchOperate(Consumer<List<T>> operater, List<T> sourceList, Integer threshold) { | |||
int size = sourceList.size(); | |||
int fromIndex = 0; | |||
List<T> list = null; | |||
while (size > fromIndex){ | |||
list = sourceList.stream().skip(fromIndex).limit(threshold).collect(Collectors.toList()); | |||
operater.accept(list); | |||
fromIndex += threshold; | |||
} | |||
} | |||
} |
@@ -2,7 +2,11 @@ | |||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | |||
<component name="FacetManager"> | |||
<facet type="Spring" name="Spring"> | |||
<configuration /> | |||
<configuration> | |||
<fileset id="fileset" name="Spring 应用程序上下文" removed="false"> | |||
<file>file://$MODULE_DIR$/src/main/java/com/tuoheng/common/core/config/CommonConfig.java</file> | |||
</fileset> | |||
</configuration> | |||
</facet> | |||
</component> | |||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> |
@@ -90,6 +90,23 @@ | |||
<artifactId>lombok</artifactId> | |||
<optional>true</optional> | |||
</dependency> | |||
<!--Swagger--> | |||
<dependency> | |||
<groupId>io.springfox</groupId> | |||
<artifactId>springfox-swagger2</artifactId> | |||
<version>3.0.0</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>io.springfox</groupId> | |||
<artifactId>springfox-swagger-ui</artifactId> | |||
<version>3.0.0</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>io.springfox</groupId> | |||
<artifactId>springfox-boot-starter</artifactId> | |||
<version>3.0.0</version> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@@ -0,0 +1,55 @@ | |||
package com.tuoheng.manage.config; | |||
import org.springframework.context.annotation.Bean; | |||
import org.springframework.context.annotation.Configuration; | |||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | |||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; | |||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | |||
import springfox.documentation.builders.ApiInfoBuilder; | |||
import springfox.documentation.builders.PathSelectors; | |||
import springfox.documentation.builders.RequestHandlerSelectors; | |||
import springfox.documentation.oas.annotations.EnableOpenApi; | |||
import springfox.documentation.service.ApiInfo; | |||
import springfox.documentation.service.Contact; | |||
import springfox.documentation.spi.DocumentationType; | |||
import springfox.documentation.spring.web.plugins.Docket; | |||
/** | |||
* Swagger配置类 | |||
*/ | |||
@Configuration | |||
@EnableOpenApi | |||
public class SwaggerConfig implements WebMvcConfigurer { | |||
@Bean | |||
public Docket createRestApi() { | |||
ApiInfo apiInfo = | |||
new ApiInfoBuilder() | |||
.title("日志管理系统API") | |||
.description("日志管理系统采用SpringBoot开发,API文档集成Swagger") | |||
.version("1.0") | |||
.contact(new Contact("tuoheng", "https://github.com/yutils", "3373217@qq.com")) | |||
.license("我的首页") | |||
.licenseUrl("https://weibo.com/32005200") | |||
.build(); | |||
return new Docket(DocumentationType.SWAGGER_2) | |||
.apiInfo(apiInfo) | |||
.select() | |||
.apis(RequestHandlerSelectors.basePackage("com.hn.logmanage.Controller")) | |||
.paths(PathSelectors.any()) | |||
.build(); | |||
} | |||
@Override | |||
public void addResourceHandlers(ResourceHandlerRegistry registry) { | |||
registry. | |||
addResourceHandler( "/swagger-ui/**") | |||
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/") | |||
.resourceChain(false); | |||
} | |||
@Override | |||
public void addViewControllers(ViewControllerRegistry registry) { | |||
registry.addViewController( "/swagger-ui/") | |||
.setViewName("forward:" + "/swagger-ui/index.html"); | |||
} | |||
} |
@@ -0,0 +1,129 @@ | |||
package com.tuoheng.manage.controller; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.api.R; | |||
import com.sun.javaws.CacheUtil; | |||
import com.tuoheng.common.core.common.BaseController; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.manage.dto.ResetPwdDto; | |||
import com.tuoheng.manage.dto.UpdateUserInfoDto; | |||
import com.tuoheng.manage.entity.User; | |||
import com.tuoheng.manage.service.IUserService; | |||
import com.tuoheng.manage.vo.UserVO; | |||
import io.swagger.annotations.ApiImplicitParam; | |||
import io.swagger.annotations.ApiImplicitParams; | |||
import io.swagger.annotations.ApiOperation; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
import springfox.documentation.annotations.ApiIgnore; | |||
import java.util.Map; | |||
/** | |||
* 用户相关代码 | |||
*/ | |||
@RestController | |||
@RequestMapping("/user-service") | |||
public class UserController extends BaseController { | |||
@Autowired | |||
private IUserService userService; | |||
/** | |||
* 查询单条 | |||
*/ | |||
@ApiOperation(value = "查看详情", notes = "传入id") | |||
@GetMapping("/user/{userId}") | |||
public R<UserVO> detail(@PathVariable("userId") String userId) { | |||
User detail = userService.getOne(Condition.getQueryWrapper(user)); | |||
return JsonResult.success(UserWrapper.build().entityVO(detail)); | |||
} | |||
/** | |||
* 查询单条 | |||
*/ | |||
@ApiOperation(value = "查看详情", notes = "传入id") | |||
@GetMapping("/info") | |||
public R<UserVO> info(User user) { | |||
User detail = userService.getById(user.getUserId()); | |||
return R.data(UserWrapper.build().entityVO(detail)); | |||
} | |||
/** | |||
* 用户列表 | |||
*/ | |||
@GetMapping("/list") | |||
@ApiImplicitParams({ | |||
@ApiImplicitParam(name = "account", value = "账号名", paramType = "query", dataType = "string"), | |||
@ApiImplicitParam(name = "realName", value = "姓名", paramType = "query", dataType = "string") | |||
}) | |||
//@ApiOperationSupport(order = 3) | |||
@ApiOperation(value = "列表", notes = "传入account和realName") | |||
public R<IPage<UserVO>> list(@ApiIgnore @RequestParam Map<String, Object> user, Query query, BladeUser bladeUser) { | |||
QueryWrapper<User> queryWrapper = Condition.getQueryWrapper(user, User.class); | |||
IPage<User> pages = userService.page(Condition.getPage(query), (!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(User::getTenantId, bladeUser.getTenantId()) : queryWrapper); | |||
return R.data(UserWrapper.build().pageVO(pages)); | |||
} | |||
/** | |||
* 新增或修改 | |||
*/ | |||
@PostMapping("/submit") | |||
@ApiOperation(value = "新增或修改", notes = "传入User") | |||
@PreAuth(RoleConstant.HAS_ROLE_ADMIN) | |||
public R submit(@Valid @RequestBody User user) { | |||
CacheUtil.clear(USER_CACHE); | |||
return R.status(userService.submit(user)); | |||
} | |||
/** | |||
* 编辑用户 | |||
* | |||
* @param entity 实体对象 | |||
* @return | |||
*/ | |||
@PutMapping("/edit") | |||
public JsonResult edit(@RequestBody UpdateUserInfoDto entity) { | |||
return userService.edit(entity); | |||
} | |||
/** | |||
* 设置状态 | |||
* | |||
* @param entity 实体对象 | |||
* @return | |||
*/ | |||
@PutMapping("/status") | |||
public JsonResult status(@RequestBody User entity) { | |||
return userService.setStatus(entity); | |||
} | |||
/** | |||
* 删除 | |||
*/ | |||
@PostMapping("/remove") | |||
@ApiOperation(value = "删除", notes = "传入id集合") | |||
@DeleteMapping("/{userIds}") | |||
public JsonResult delete(@PathVariable("userIds") Integer[] userIds) { | |||
return userService.deleteByIds(userIds); | |||
} | |||
/** | |||
* 重置密码 | |||
* | |||
* @param resetPwdDto 参数 | |||
* @return | |||
*/ | |||
@PutMapping("/reset-password") | |||
@ApiOperation(value = "初始化密码", notes = "传入userId") | |||
@ApiImplicitParam(name = "id", value = "用户Id", paramType = "query", dataType = "string") | |||
public JsonResult resetPwd(@RequestBody ResetPwdDto resetPwdDto) { | |||
return userService.resetPwd(resetPwdDto); | |||
} | |||
} |
@@ -0,0 +1,31 @@ | |||
package com.tuoheng.manage.dto; | |||
import lombok.Data; | |||
/** | |||
* 登录Dto | |||
*/ | |||
@Data | |||
public class LoginDto { | |||
/** | |||
* 登录用户名 | |||
*/ | |||
private String username; | |||
/** | |||
* 登录密码 | |||
*/ | |||
private String password; | |||
/** | |||
* 验证码 | |||
*/ | |||
private String captcha; | |||
/** | |||
* 验证码KEY | |||
*/ | |||
private String key; | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.tuoheng.manage.dto; | |||
import lombok.Data; | |||
/** | |||
* 重置密码 | |||
*/ | |||
@Data | |||
public class ResetPwdDto { | |||
/** | |||
* 用户ID | |||
*/ | |||
private Integer id; | |||
} |
@@ -0,0 +1,21 @@ | |||
package com.tuoheng.manage.dto; | |||
import lombok.Data; | |||
/** | |||
* 角色菜单Dto | |||
*/ | |||
@Data | |||
public class RoleMenuDto { | |||
/** | |||
* 角色ID | |||
*/ | |||
private Integer roleId; | |||
/** | |||
* 菜单ID | |||
*/ | |||
private Integer[] menuIds; | |||
} |
@@ -0,0 +1,21 @@ | |||
package com.tuoheng.manage.dto; | |||
import lombok.Data; | |||
/** | |||
* 修改密码Dto | |||
*/ | |||
@Data | |||
public class UpdatePwdDto { | |||
/** | |||
* 旧密码 | |||
*/ | |||
private String oldPassword; | |||
/** | |||
* 新密码 | |||
*/ | |||
private String newPassword; | |||
} |
@@ -0,0 +1,46 @@ | |||
package com.tuoheng.manage.dto; | |||
import lombok.Data; | |||
/** | |||
* 更新个人资料 | |||
*/ | |||
@Data | |||
public class UpdateUserInfoDto { | |||
/** | |||
* 个人头像 | |||
*/ | |||
private String avatar; | |||
/** | |||
* 真实姓名 | |||
*/ | |||
private String realname; | |||
/** | |||
* 昵称 | |||
*/ | |||
private String nickname; | |||
/** | |||
* 性别 | |||
*/ | |||
private String gender; | |||
/** | |||
* 手机号码 | |||
*/ | |||
private String mobile; | |||
/** | |||
* 个人简介 | |||
*/ | |||
private String intro; | |||
/** | |||
* 个性签名 | |||
*/ | |||
private String signature; | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.tuoheng.manage.entity; | |||
import com.tuoheng.common.core.common.BaseEntity; | |||
import io.swagger.annotations.ApiModelProperty; | |||
/** | |||
* @User qiujinyang | |||
* @Description | |||
* @Date Created by 2022/6/30 20:11 | |||
*/ | |||
public class TenantEntity extends BaseEntity { | |||
@ApiModelProperty("租户ID") | |||
private String tenantId; | |||
} |
@@ -0,0 +1,235 @@ | |||
package com.tuoheng.manage.entity; | |||
import com.baomidou.mybatisplus.annotation.IdType; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* <p> | |||
* 后台用户管理表 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2020-10-30 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("sys_user") | |||
public class User extends TenantEntity implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 用户ID | |||
*/ | |||
@TableId(value = "id", type = IdType.AUTO) | |||
private Integer id; | |||
/** | |||
* 用户编号 | |||
*/ | |||
private String code; | |||
/** | |||
* 真实姓名 | |||
*/ | |||
private String realname; | |||
/** | |||
* 昵称 | |||
*/ | |||
private String nickname; | |||
/** | |||
* 性别:1男 2女 3保密 | |||
*/ | |||
private Integer gender; | |||
/** | |||
* 头像 | |||
*/ | |||
private String avatar; | |||
/** | |||
* 手机号码 | |||
*/ | |||
private String mobile; | |||
/** | |||
* 邮箱地址 | |||
*/ | |||
private String email; | |||
/** | |||
* 出生日期 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | |||
private Date birthday; | |||
/** | |||
* 部门ID | |||
*/ | |||
private Integer deptId; | |||
/** | |||
* 职级ID | |||
*/ | |||
private Integer levelId; | |||
/** | |||
* 岗位ID | |||
*/ | |||
private Integer positionId; | |||
/** | |||
* 省份编码 | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 城市编码 | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县编码 | |||
*/ | |||
private String districtCode; | |||
/** | |||
* 街道编码 | |||
*/ | |||
private String streetCode; | |||
/** | |||
* 详细地址 | |||
*/ | |||
private String address; | |||
/** | |||
* 所属城市 | |||
*/ | |||
private String cityName; | |||
/** | |||
* 登录用户名 | |||
*/ | |||
private String username; | |||
/** | |||
* 登录密码 | |||
*/ | |||
private String password; | |||
/** | |||
* 用户类型:1普通用户 2飞手 | |||
*/ | |||
private Integer type; | |||
/** | |||
* 驾照类型:1飞行执照 2飞行许可证 | |||
*/ | |||
private Integer driverType; | |||
/** | |||
* 驾照编号 | |||
*/ | |||
private String driverCode; | |||
/** | |||
* 盐加密 | |||
*/ | |||
private String salt; | |||
/** | |||
* 个人简介 | |||
*/ | |||
private String intro; | |||
/** | |||
* 状态:1正常 2禁用 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
/** | |||
* 显示顺序 | |||
*/ | |||
private Integer sort; | |||
/** | |||
* 登录次数 | |||
*/ | |||
private Integer loginNum; | |||
/** | |||
* 最近登录IP | |||
*/ | |||
private String loginIp; | |||
/** | |||
* 最近登录时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date loginTime; | |||
/** | |||
* 添加人 | |||
*/ | |||
private Integer createUser; | |||
/** | |||
* 创建时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date createTime; | |||
/** | |||
* 更新人 | |||
*/ | |||
private Integer updateUser; | |||
/** | |||
* 更新时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date updateTime; | |||
/** | |||
* 有效标识 | |||
*/ | |||
private Integer mark; | |||
/** | |||
*是否有问题分派人权限(1是 0否) | |||
*/ | |||
private Integer isAssignAuth; | |||
/** | |||
* 角色ID | |||
*/ | |||
@TableField(exist = false) | |||
private Integer[] roleIds; | |||
/** | |||
* 城市集合 | |||
*/ | |||
@TableField(exist = false) | |||
private String[] city; | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.tuoheng.manage.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.manage.entity.User; | |||
/** | |||
* <p> | |||
* 后台用户管理表 Mapper 接口 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2020-10-30 | |||
*/ | |||
public interface UserMapper extends BaseMapper<User> { | |||
} |
@@ -0,0 +1,22 @@ | |||
package com.tuoheng.manage.query; | |||
import com.tuoheng.common.core.common.BaseQuery; | |||
import lombok.Data; | |||
/** | |||
* 用户查询条件 | |||
*/ | |||
@Data | |||
public class UserQuery extends BaseQuery { | |||
/** | |||
* 客户姓名 | |||
*/ | |||
private String username; | |||
/** | |||
* 客户单位 | |||
*/ | |||
private String realname; | |||
} |
@@ -0,0 +1,91 @@ | |||
package com.tuoheng.manage.service; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.manage.dto.ResetPwdDto; | |||
import com.tuoheng.manage.dto.UpdateUserInfoDto; | |||
import com.tuoheng.manage.entity.User; | |||
import com.tuoheng.system.query.UserQuery; | |||
/** | |||
* <p> | |||
* 后台用户管理表 服务类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2020-10-30 | |||
*/ | |||
public interface IUserService extends IService<User> { | |||
/** | |||
* 根据查询条件获取数据列表 | |||
* | |||
* @param userQuery 查询条件 | |||
* @return | |||
*/ | |||
JsonResult getList(UserQuery userQuery); | |||
/** | |||
* 获取用户详情 | |||
* | |||
* @param userId 用户ID | |||
* @return | |||
*/ | |||
JsonResult detail(Integer userId); | |||
/** | |||
* 根据实体对象添加、编辑记录 | |||
* | |||
* @param entity 实体对象 | |||
* @return | |||
*/ | |||
JsonResult edit(UpdateUserInfoDto entity); | |||
/** | |||
* 根据ID删除记录 | |||
* | |||
* @param ids 记录ID | |||
* @return | |||
*/ | |||
JsonResult deleteByIds(Integer[] ids); | |||
/** | |||
* 设置状态 | |||
* | |||
* @param entity 实体对象 | |||
* @return | |||
*/ | |||
JsonResult setStatus(User entity); | |||
/** | |||
* 获取用户信息 | |||
* | |||
* @return | |||
*/ | |||
JsonResult getUserInfo(); | |||
/** | |||
* 更新个人资料 | |||
* | |||
* @param updateUserInfoDto 参数 | |||
* @return | |||
*/ | |||
JsonResult updateUserInfo(UpdateUserInfoDto updateUserInfoDto); | |||
/** | |||
* 重置密码 | |||
* | |||
* @param resetPwdDto 参数 | |||
* @return | |||
*/ | |||
JsonResult resetPwd(ResetPwdDto resetPwdDto); | |||
/** | |||
* 获取用户列表 | |||
* | |||
* @param type 用户类型:1普通用户 2飞手 | |||
* @return | |||
*/ | |||
JsonResult getUserList(Integer type); | |||
} |
@@ -0,0 +1,473 @@ | |||
package com.tuoheng.manage.service.impl; | |||
import cn.hutool.core.convert.Convert; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.tuoheng.common.core.config.CommonConfig; | |||
import com.tuoheng.common.core.utils.CommonUtils; | |||
import com.tuoheng.common.core.utils.DateUtils; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import com.tuoheng.common.utils.*; | |||
import com.tuoheng.manage.dto.ResetPwdDto; | |||
import com.tuoheng.manage.dto.UpdatePwdDto; | |||
import com.tuoheng.manage.dto.UpdateUserInfoDto; | |||
import com.tuoheng.manage.entity.User; | |||
import com.tuoheng.manage.mapper.UserMapper; | |||
import com.tuoheng.manage.service.IUserService; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 后台用户管理表 服务实现类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2020-10-30 | |||
*/ | |||
@Service | |||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService { | |||
@Autowired | |||
private UserMapper userMapper; | |||
@Autowired | |||
private UserRoleMapper userRoleMapper; | |||
@Autowired | |||
private IMenuService menuService; | |||
@Autowired | |||
private RoleMapper roleMapper; | |||
@Autowired | |||
private IUserRoleService userRoleService; | |||
@Autowired | |||
private LevelMapper levelMapper; | |||
@Autowired | |||
private PositionMapper positionMapper; | |||
@Autowired | |||
private DeptMapper deptMapper; | |||
@Autowired | |||
private CityMapper cityMapper; | |||
/** | |||
* 获取用户列表 | |||
* | |||
* @param userQuery 查询条件 | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getList(UserQuery userQuery) { | |||
// 查询条件 | |||
QueryWrapper<User> queryWrapper = new QueryWrapper<>(); | |||
// 真实姓名 | |||
if (!StringUtils.isEmpty(userQuery.getRealname())) { | |||
queryWrapper.like("realname", userQuery.getRealname()); | |||
} | |||
// 用户账号 | |||
if (!StringUtils.isEmpty(userQuery.getUsername())) { | |||
queryWrapper.eq("username", userQuery.getUsername()); | |||
} | |||
// 性别 | |||
if (StringUtils.isNotNull(userQuery.getGender())) { | |||
queryWrapper.eq("gender", userQuery.getGender()); | |||
} | |||
queryWrapper.eq("mark", 1); | |||
//判断是否终端用户 修改查询 | |||
if (StringUtils.isNotNull(userQuery.getTerminalType()) && userQuery.getTerminalType() == 1) { | |||
queryWrapper.and(wrapper -> wrapper.eq("type", 1) | |||
.or().eq("type", 2)); | |||
} else { | |||
queryWrapper.and(wrapper -> wrapper.eq("type", 3) | |||
.or().eq("type", 4).or().eq("type", 5).or().eq("type", 6)); | |||
} | |||
// 用户类型筛选 | |||
if (StringUtils.isNotNull(userQuery.getType())) { | |||
queryWrapper.eq("type", userQuery.getType()); | |||
} | |||
// 状态筛选 | |||
if (StringUtils.isNotNull(userQuery.getStatus())) { | |||
queryWrapper.eq("status", userQuery.getStatus()); | |||
} | |||
// 角色ID | |||
if (StringUtils.isNotNull(userQuery.getRoleId())) { | |||
List<Integer> integerList = userRoleMapper.getUsersByURoleId(userQuery.getRoleId()); | |||
Integer[] userIds = integerList.toArray(new Integer[integerList.size()]); | |||
if (userIds.length >= 1) { | |||
queryWrapper.in("id", userIds); | |||
} else { | |||
queryWrapper.in("id", 0); | |||
} | |||
} | |||
//end 判断是否终端用户 修改查询 2021 11 15 | |||
queryWrapper.orderByAsc("sort"); | |||
// 查询分页数据 | |||
IPage<User> page = new Page<>(userQuery.getPage(), userQuery.getLimit()); | |||
IPage<User> pageData = userMapper.selectPage(page, queryWrapper); | |||
pageData.convert(x -> { | |||
UserListVo userListVo = Convert.convert(UserListVo.class, x); | |||
// 用户头像 | |||
if (!StringUtils.isEmpty(x.getAvatar())) { | |||
userListVo.setAvatar(CommonUtils.getImageURL(x.getAvatar())); | |||
} | |||
// 性别描述 | |||
if (x.getGender() != null && x.getGender() > 0) { | |||
userListVo.setGenderName(UserConstant.USER_GENDER_LIST.get(x.getGender())); | |||
} | |||
// 职级 | |||
if (StringUtils.isNotNull(x.getLevelId())) { | |||
Level levelInfo = levelMapper.selectById(x.getLevelId()); | |||
if (StringUtils.isNotNull(levelInfo)) { | |||
userListVo.setLevelName(levelInfo.getName()); | |||
} | |||
} | |||
// 岗位 | |||
if (StringUtils.isNotNull(x.getPositionId())) { | |||
Position positionInfo = positionMapper.selectById(x.getPositionId()); | |||
if (StringUtils.isNotNull(positionInfo)) { | |||
userListVo.setPositionName(positionInfo.getName()); | |||
} | |||
} | |||
// 部门 | |||
if (StringUtils.isNotNull(x.getDeptId())) { | |||
Dept dept = deptMapper.selectById(x.getDeptId()); | |||
if (StringUtils.isNotNull(dept)) { | |||
userListVo.setDeptName(dept.getName()); | |||
} | |||
} | |||
// 城市数据处理 | |||
if (StringUtils.isNotNull(x.getProvinceCode()) && | |||
StringUtils.isNotNull(x.getCityCode()) && | |||
StringUtils.isNotNull(x.getDistrictCode())) { | |||
// 初始化数组 | |||
String[] strings = new String[3]; | |||
strings[0] = x.getProvinceCode(); | |||
strings[1] = x.getCityCode(); | |||
strings[2] = x.getDistrictCode(); | |||
userListVo.setCity(strings); | |||
} | |||
// 获取角色信息 | |||
List<Role> roleList = roleMapper.getRolesByUserId(x.getId()); | |||
userListVo.setRoles(roleList); | |||
return userListVo; | |||
}); | |||
return JsonResult.success(pageData); | |||
} | |||
/** | |||
* 用于新增修改终端用户 回显所管辖区域名称 | |||
* | |||
* @param x type | |||
* @return | |||
*/ | |||
private String selectCityName(User x) { | |||
QueryWrapper<City> queryWrapper = new QueryWrapper<>(); | |||
String userCityCode = ""; | |||
if (!StringUtils.isEmpty(x.getStreetCode()) && (x.getType() == 6 || x.getType() == 1 || x.getType() == 2 || x.getType() == 3)) { | |||
String citys = ""; | |||
String[] s = x.getStreetCode().split(","); | |||
for (String scode : s) { | |||
queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("citycode", scode); | |||
queryWrapper.eq("mark", 1); | |||
List<City> listStreet = cityMapper.selectList(queryWrapper); | |||
if (listStreet.size() > 0) { | |||
for (City cityone : listStreet) { | |||
citys += cityone.getName() + ","; | |||
} | |||
} | |||
} | |||
return citys.substring(0, citys.length() - 1); | |||
} else if (!StringUtils.isEmpty(x.getDistrictCode()) && (x.getType() == 5 || x.getType() == 1 || x.getType() == 2 || x.getType() == 3)) { | |||
userCityCode = x.getDistrictCode(); | |||
} else if (!StringUtils.isEmpty(x.getCityCode()) && (x.getType() == 4 || x.getType() == 1 || x.getType() == 2 || x.getType() == 3)) { | |||
userCityCode = x.getCityCode(); | |||
} else if (!StringUtils.isEmpty(x.getProvinceCode())) { | |||
userCityCode = x.getProvinceCode(); | |||
} | |||
queryWrapper.eq("citycode", userCityCode); | |||
List<City> list = cityMapper.selectList(queryWrapper); | |||
if (list.size() > 0) { | |||
return list.get(0).getName(); | |||
} else { | |||
return null; | |||
} | |||
} | |||
/** | |||
* 获取用户详情 | |||
* | |||
* @param userId 用户ID | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult detail(Integer userId) { | |||
User info = userMapper.selectById(userId); | |||
if (info == null) { | |||
return JsonResult.error("用户不存在"); | |||
} | |||
// 获取用户详细信息 | |||
UserListVo userInfo = new UserListVo(); | |||
BeanUtils.copyProperties(info, userInfo); | |||
// 用户头像 | |||
if (!StringUtils.isEmpty(info.getAvatar())) { | |||
userInfo.setAvatar(CommonUtils.getImageURL(info.getAvatar())); | |||
} | |||
// 性别描述 | |||
if (info.getGender() != null && info.getGender() > 0) { | |||
userInfo.setGenderName(UserConstant.USER_GENDER_LIST.get(info.getGender())); | |||
} | |||
// 职级 | |||
if (StringUtils.isNotNull(info.getLevelId())) { | |||
Level levelInfo = levelMapper.selectById(info.getLevelId()); | |||
if (StringUtils.isNotNull(levelInfo)) { | |||
userInfo.setLevelName(levelInfo.getName()); | |||
} | |||
} | |||
// 岗位 | |||
if (StringUtils.isNotNull(info.getPositionId())) { | |||
Position positionInfo = positionMapper.selectById(info.getPositionId()); | |||
if (StringUtils.isNotNull(positionInfo)) { | |||
userInfo.setPositionName(positionInfo.getName()); | |||
} | |||
} | |||
// 城市数据处理 | |||
if (StringUtils.isNotNull(info.getProvinceCode()) && | |||
StringUtils.isNotNull(info.getCityCode()) && | |||
StringUtils.isNotNull(info.getDistrictCode())) { | |||
// 初始化数组 | |||
String[] strings = new String[3]; | |||
strings[0] = info.getProvinceCode(); | |||
strings[1] = info.getCityCode(); | |||
strings[2] = info.getDistrictCode(); | |||
userInfo.setCity(strings); | |||
} | |||
// 获取角色信息 | |||
List<Role> roleList = roleMapper.getRolesByUserId(info.getId()); | |||
userInfo.setRoles(roleList); | |||
return JsonResult.success(userInfo); | |||
} | |||
/** | |||
* 添加或编辑 | |||
* | |||
* @param entity 实体对象 | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult edit(UpdateUserInfoDto entity) { | |||
User user=new User(); | |||
BeanUtils.copyProperties(entity,user); | |||
// 头像处理 | |||
if (StringUtils.isEmpty(entity.getAvatar())) { | |||
return JsonResult.error("请上传头像"); | |||
} | |||
if (StringUtils.isNotNull(entity.getAvatar()) && entity.getAvatar().contains(CommonConfig.imageURL)) { | |||
entity.setAvatar(entity.getAvatar().replaceAll(CommonConfig.imageURL, "")); | |||
} | |||
// 设置密码 | |||
// if (StringUtils.isNotEmpty(entity.getPassword())) { | |||
// entity.setPassword(CommonUtils.password(entity.getPassword())); | |||
// } else { | |||
// entity.setPassword(null); | |||
// } | |||
// // 省市区处理 | |||
// if (entity.getCity().length != 3) { | |||
// return JsonResult.error("请选择省市区"); | |||
// } | |||
// // 省份 | |||
// entity.setProvinceCode(entity.getCity()[0]); | |||
// // 城市 | |||
// entity.setCityCode(entity.getCity()[1]); | |||
// // 省份 | |||
// entity.setDistrictCode(entity.getCity()[2]); | |||
entity.setCityName(selectCityName(entity)); | |||
boolean result = this.saveOrUpdate(entity); | |||
if (!result) { | |||
return JsonResult.error(); | |||
} | |||
// 删除已存在的用户角色关系数据 | |||
userRoleService.deleteUserRole(entity.getId()); | |||
// 插入用户角色关系数据 | |||
userRoleService.insertUserRole(entity.getId(), entity.getRoleIds()); | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 根据用户ID删除用户 | |||
* | |||
* @param ids 记录ID | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult deleteByIds(Integer[] ids) { | |||
if (StringUtils.isNull(ids)) { | |||
return JsonResult.error("记录ID不能为空"); | |||
} | |||
// 设置Mark=0 | |||
Integer totalNum = 0; | |||
for (Integer id : ids) { | |||
UpdateWrapper updateWrapper = new UpdateWrapper(); | |||
updateWrapper.set("mark", 0); | |||
updateWrapper.eq("id", id); | |||
boolean result = update(updateWrapper); | |||
if (result) { | |||
totalNum++; | |||
} | |||
} | |||
if (totalNum != ids.length) { | |||
return JsonResult.error(); | |||
} | |||
return JsonResult.success("删除成功"); | |||
} | |||
/** | |||
* 设置状态 | |||
* | |||
* @param entity 实体对象 | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult setStatus(User entity) { | |||
//todo 更新用户,从用户那边获取 | |||
//entity.setUpdateUser(ShiroUtils.getUserId()); | |||
entity.setUpdateTime(DateUtils.now()); | |||
boolean result = this.updateById(entity); | |||
if (!result) { | |||
return JsonResult.error(); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 获取用户信息 | |||
* | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getUserInfo() { | |||
//Integer userId = ShiroUtils.getUserId(); | |||
User user = userMapper.selectById(userId); | |||
// 拷贝属性 | |||
UserInfoVo userInfoVo = new UserInfoVo(); | |||
BeanUtils.copyProperties(user, userInfoVo); | |||
// 会员头像 | |||
// if (StringUtils.isNotNull(user.getAvatar())) { | |||
// userInfoVo.setAvatar(CommonUtils.getImageURL(user.getAvatar())); | |||
// } | |||
// // 获取角色列表 | |||
// List<Role> roleList = userRoleMapper.getRolesByUserId(userId); | |||
// userInfoVo.setRoles(roleList); | |||
// // 获取权限菜单 | |||
// List<Menu> menuList = menuService.getMenuList(userId); | |||
// userInfoVo.setAuthorities(menuList); | |||
// 获取节点权限 | |||
// List<String> permissionList = menuService.getPermissionList(userId); | |||
// userInfoVo.setPermissionList(permissionList); | |||
return JsonResult.success(userInfoVo); | |||
} | |||
/** | |||
* 修改密码 | |||
* | |||
* @param updatePwdDto 参数 | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult updatePwd(UpdatePwdDto updatePwdDto) { | |||
User user = userMapper.selectById(ShiroUtils.getUserId()); | |||
if (user == null) { | |||
return JsonResult.error("用户信息不存在"); | |||
} | |||
// 校验旧密码是否正确 | |||
if (!CommonUtils.password(updatePwdDto.getOldPassword()).equals(user.getPassword())) { | |||
return JsonResult.error("原始密码不正确"); | |||
} | |||
// 设置新密码 | |||
user.setPassword(CommonUtils.password(updatePwdDto.getNewPassword())); | |||
Integer result = userMapper.updateById(user); | |||
if (result == 0) { | |||
return JsonResult.error("修改密码失败"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 更新个人资料 | |||
* | |||
* @param updateUserInfoDto 参数 | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult updateUserInfo(UpdateUserInfoDto updateUserInfoDto) { | |||
// 用户ID验证 | |||
if (StringUtils.isNull(ShiroUtils.getUserId()) || ShiroUtils.getUserId() <= 0) { | |||
return JsonResult.error("用户ID不能为空"); | |||
} | |||
// 实例化用户对象 | |||
User user = new User(); | |||
BeanUtils.copyProperties(updateUserInfoDto, user); | |||
user.setId(ShiroUtils.getUserId()); | |||
// 头像处理 | |||
if (!StringUtils.isEmpty(updateUserInfoDto.getAvatar()) && updateUserInfoDto.getAvatar().contains(CommonConfig.imageURL)) { | |||
user.setAvatar(updateUserInfoDto.getAvatar().replaceAll(CommonConfig.imageURL, "")); | |||
} | |||
int result = userMapper.updateById(user); | |||
if (result == 0) { | |||
return JsonResult.error("更新失败"); | |||
} | |||
return JsonResult.success("更新成功"); | |||
} | |||
/** | |||
* 重置密码 | |||
* | |||
* @param resetPwdDto 参数 | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult resetPwd(ResetPwdDto resetPwdDto) { | |||
// 用户ID验证 | |||
if (StringUtils.isNull(resetPwdDto.getId())) { | |||
return JsonResult.error("用户ID不能为空"); | |||
} | |||
User user = userMapper.selectById(resetPwdDto.getId()); | |||
if (StringUtils.isNull(user)) { | |||
return JsonResult.error("用户信息不存在"); | |||
} | |||
// 设置新密码 | |||
user.setPassword(CommonUtils.password("123456")); | |||
int reuslt = userMapper.updateById(user); | |||
if (reuslt == 0) { | |||
return JsonResult.error(null, "密码重置失败"); | |||
} | |||
return JsonResult.success(null, "密码重置成功"); | |||
} | |||
/** | |||
* 获取用户列表 | |||
* | |||
* @param type 用户类型:1普通用户 2飞手 | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getUserList(Integer type) { | |||
QueryWrapper<User> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("type", type); | |||
queryWrapper.eq("mark", 1); | |||
queryWrapper.orderByAsc("sort"); | |||
List<User> userList = list(queryWrapper); | |||
return JsonResult.success(userList); | |||
} | |||
} |
@@ -0,0 +1,227 @@ | |||
package com.tuoheng.manage.vo; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.system.entity.Menu; | |||
import com.tuoheng.system.entity.Role; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
import java.util.List; | |||
/** | |||
* 用户信息Vo | |||
*/ | |||
@Data | |||
public class UserInfoVo { | |||
/** | |||
* 主键ID | |||
*/ | |||
private Integer id; | |||
/** | |||
* 用户编号 | |||
*/ | |||
private String code; | |||
/** | |||
* 真实姓名 | |||
*/ | |||
private String realname; | |||
/** | |||
* 昵称 | |||
*/ | |||
private String nickname; | |||
/** | |||
* 性别:1男 2女 3保密 | |||
*/ | |||
private Integer gender; | |||
/** | |||
* 头像 | |||
*/ | |||
private String avatar; | |||
/** | |||
* 手机号码 | |||
*/ | |||
private String mobile; | |||
/** | |||
* 邮箱地址 | |||
*/ | |||
private String email; | |||
/** | |||
* 出生日期 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | |||
private Date birthday; | |||
/** | |||
* 部门ID | |||
*/ | |||
private Integer deptId; | |||
/** | |||
* 部门名称 | |||
*/ | |||
private String deptName; | |||
/** | |||
* 职级ID | |||
*/ | |||
private Integer levelId; | |||
/** | |||
* 岗位ID | |||
*/ | |||
private Integer positionId; | |||
/** | |||
* 省份ID | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 市区ID | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县ID | |||
*/ | |||
private String districtCode; | |||
/** | |||
* 街道ID | |||
*/ | |||
private String streetCode; | |||
/** | |||
* 详细地址 | |||
*/ | |||
private String address; | |||
/** | |||
* 所属城市 | |||
*/ | |||
private String cityName; | |||
/** | |||
* 登录用户名 | |||
*/ | |||
private String username; | |||
/** | |||
* 登录密码 | |||
*/ | |||
private String password; | |||
/** | |||
* 用户类型:1普通用户 2飞手 | |||
*/ | |||
private Integer type; | |||
/** | |||
* 驾照类型:1飞行执照 2飞行许可证 | |||
*/ | |||
private Integer driverType; | |||
/** | |||
* 驾照编号 | |||
*/ | |||
private String driverCode; | |||
/** | |||
* 盐加密 | |||
*/ | |||
private String salt; | |||
/** | |||
* 个人简介 | |||
*/ | |||
private String intro; | |||
/** | |||
* 状态:1正常 2禁用 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
/** | |||
* 显示顺序 | |||
*/ | |||
private Integer sort; | |||
/** | |||
* 登录次数 | |||
*/ | |||
private Integer loginNum; | |||
/** | |||
* 最近登录IP | |||
*/ | |||
private String loginIp; | |||
/** | |||
* 最近登录时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date loginTime; | |||
/** | |||
* 添加人 | |||
*/ | |||
private Integer createUser; | |||
/** | |||
* 创建时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date createTime; | |||
/** | |||
* 更新人 | |||
*/ | |||
private Integer updateUser; | |||
/** | |||
* 更新时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date updateTime; | |||
/** | |||
* 有效标识(1正常 0删除) | |||
*/ | |||
private Integer mark; | |||
/** | |||
* 角色列表 | |||
*/ | |||
private List<Role> roles; | |||
/** | |||
* 菜单权限 | |||
*/ | |||
private List<Menu> authorities; | |||
/** | |||
* 获取节点权限列表 | |||
*/ | |||
private List<String> permissionList; | |||
/** | |||
*是否有问题分派人权限(1是 0否) | |||
*/ | |||
private Integer isAssignAuth; | |||
} |
@@ -0,0 +1,41 @@ | |||
/* | |||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. | |||
* | |||
* Redistribution and use in source and binary forms, with or without | |||
* modification, are permitted provided that the following conditions are met: | |||
* | |||
* Redistributions of source code must retain the above copyright notice, | |||
* this list of conditions and the following disclaimer. | |||
* Redistributions in binary form must reproduce the above copyright | |||
* notice, this list of conditions and the following disclaimer in the | |||
* documentation and/or other materials provided with the distribution. | |||
* Neither the name of the dreamlu.net developer nor the names of its | |||
* contributors may be used to endorse or promote products derived from | |||
* this software without specific prior written permission. | |||
* Author: Chill 庄骞 (smallchill@163.com) | |||
*/ | |||
package com.tuoheng.manage.vo; | |||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | |||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; | |||
import io.swagger.annotations.ApiModel; | |||
import lombok.Data; | |||
/** | |||
* 视图实体类 | |||
* | |||
* @author Chill | |||
*/ | |||
@Data | |||
@ApiModel(value = "UserVO对象", description = "UserVO对象") | |||
public class UserVO { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 主键ID | |||
*/ | |||
@JsonSerialize(using = ToStringSerializer.class) | |||
private Long id; | |||
} |
@@ -135,6 +135,28 @@ | |||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.36" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.7.0" level="project" /> | |||
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.24" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:3.0.0" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:3.0.0" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-core:3.0.0" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:3.0.0" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:3.0.0" level="project" /> | |||
<orderEntry type="library" name="Maven: io.swagger.core.v3:swagger-annotations:2.1.2" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:3.0.0" level="project" /> | |||
<orderEntry type="library" name="Maven: io.github.classgraph:classgraph:4.8.83" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-webmvc:3.0.0" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-webflux:3.0.0" level="project" /> | |||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:2.0.0.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.20" level="project" /> | |||
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.20" level="project" /> | |||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.mapstruct:mapstruct:1.3.1.Final" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:3.0.0" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-boot-starter:3.0.0" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-oas:3.0.0" level="project" /> | |||
<orderEntry type="library" name="Maven: io.swagger.core.v3:swagger-models:2.1.2" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-data-rest:3.0.0" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-bean-validators:3.0.0" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.7.0" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.7.0" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.7.0" level="project" /> | |||
@@ -154,7 +176,7 @@ | |||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.8.2" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.8.2" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:4.5.1" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.12.10" level="project" /> | |||
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.12.10" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.12.10" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:3.2" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:4.5.1" level="project" /> |