用户注册与登录功能开发
This commit is contained in:
parent
2916a37052
commit
0e80995a7e
23
pom.xml
23
pom.xml
@ -119,6 +119,10 @@
|
||||
<artifactId>commons-text</artifactId>
|
||||
<version>1.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
@ -135,6 +139,25 @@
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.nekohtml</groupId>
|
||||
<artifactId>nekohtml</artifactId>
|
||||
<version>1.9.22</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -12,6 +12,7 @@ import com.rymcu.vertical.service.UserService;
|
||||
import com.rymcu.vertical.util.Encodes;
|
||||
import com.rymcu.vertical.util.Utils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.exceptions.TooManyResultsException;
|
||||
import org.apache.shiro.authc.*;
|
||||
import org.apache.shiro.authz.AuthorizationInfo;
|
||||
import org.apache.shiro.authz.SimpleAuthorizationInfo;
|
||||
@ -85,8 +86,8 @@ public class HpeisShiroRealm extends AuthorizingRealm {
|
||||
throw new CaptchaException();
|
||||
}
|
||||
try {
|
||||
user = userService.findByLoginName(username);
|
||||
} catch (ServiceException e) {
|
||||
user = userService.findByAccount(username);
|
||||
} catch (TooManyResultsException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (user == null) {
|
||||
@ -117,7 +118,7 @@ public class HpeisShiroRealm extends AuthorizingRealm {
|
||||
public Principal(User user, boolean mobileLogin) {
|
||||
this.id = user.getIdUser();
|
||||
this.account = user.getAccount();
|
||||
this.name = user.getNickName();
|
||||
this.name = user.getNickname();
|
||||
this.mobileLogin = mobileLogin;
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,14 @@ public class ShiroConfig implements EnvironmentAware {
|
||||
filterChainDefinitionMap.put("/js/**", "anon");
|
||||
filterChainDefinitionMap.put("/uploadFile/**", "anon");
|
||||
filterChainDefinitionMap.put("/login", "anon");
|
||||
|
||||
filterChainDefinitionMap.put("/swagger-ui.html", "anon");
|
||||
filterChainDefinitionMap.put("/swagger-resources", "anon");
|
||||
filterChainDefinitionMap.put("/swagger-resources/configuration/security", "anon");
|
||||
filterChainDefinitionMap.put("/swagger-resources/configuration/ui", "anon");
|
||||
filterChainDefinitionMap.put("/v2/api-docs", "anon");
|
||||
filterChainDefinitionMap.put("/webjars/springfox-swagger-ui/**", "anon");
|
||||
|
||||
filterChainDefinitionMap.put("/api/**", "anon");
|
||||
// filterChainDefinitionMap.put("/**", "authc");
|
||||
filterChainDefinitionMap.put("/**", "authc");
|
||||
|
@ -0,0 +1,37 @@
|
||||
package com.rymcu.vertical.config;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class Swagger2Configuration {
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.rymcu.vertical.web.api"))//这是注意的代码
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("Vertical项目接口文档")
|
||||
.description("Vertical项目相关接口的文档")
|
||||
.termsOfServiceUrl("http://www.rymcu.com")
|
||||
.version("1.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
@ -71,9 +71,7 @@ public class WebMvcConfigurer extends WebMvcConfigurationSupport {
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// TODO 先不拦截接口,进行测试
|
||||
registry.addInterceptor(restAuthTokenInterceptor()).addPathPatterns("/api/**")
|
||||
.excludePathPatterns("/api/login/**", "/api/logout","/api/member/*",
|
||||
"/api/home/*","/api/item/**","/api/searchHistory/**", "/api/pay/payNotify",
|
||||
"/api/mall/oauth/**","/api/express/**","/api/person/**");
|
||||
.excludePathPatterns("/api/v1/**");
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.rymcu.vertical.core.result;
|
||||
|
||||
public enum GlobalResultMessage {
|
||||
|
||||
SUCCESS("操作成功!"),
|
||||
FAIL("操作失败!"),
|
||||
SEND_FAIL("发送失败,请稍后再试!"),
|
||||
SEND_SUCCESS("发送成功!");
|
||||
|
||||
private String message;
|
||||
|
||||
GlobalResultMessage(String message){
|
||||
this.message = message;
|
||||
}
|
||||
}
|
@ -12,14 +12,8 @@ public class RoleDTO {
|
||||
private String name;
|
||||
|
||||
// 英文名称
|
||||
private String enname;
|
||||
|
||||
// 用户类别
|
||||
private String roleType;
|
||||
private String inputCode;
|
||||
|
||||
// 角色授权菜单ids
|
||||
private String menuIds;
|
||||
|
||||
// 备注
|
||||
private String remarks;
|
||||
}
|
||||
|
18
src/main/java/com/rymcu/vertical/dto/TUser.java
Normal file
18
src/main/java/com/rymcu/vertical/dto/TUser.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.rymcu.vertical.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TUser {
|
||||
|
||||
private String account;
|
||||
|
||||
private String nickname;
|
||||
|
||||
private String token;
|
||||
|
||||
private String avatarType;
|
||||
|
||||
private String avatarUrl;
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.rymcu.vertical.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserExportDTO {
|
||||
|
||||
private String officeName;
|
||||
|
||||
private String name;
|
||||
|
||||
private String sex;
|
||||
|
||||
private String loginName;
|
||||
|
||||
private String storePerm;
|
||||
|
||||
private String departPerm;
|
||||
}
|
@ -14,13 +14,13 @@ import java.util.Date;
|
||||
public class Menu {
|
||||
|
||||
@Id
|
||||
@Column(name = "ID_MENU")
|
||||
@Column(name = "id")
|
||||
private Integer idMenu;
|
||||
|
||||
/**
|
||||
* 上级菜单ID
|
||||
* */
|
||||
@Column(name = "PARENT_ID")
|
||||
@Column(name = "parent_id")
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
@ -57,12 +57,12 @@ public class Menu {
|
||||
/**
|
||||
* 创建时间
|
||||
* */
|
||||
@Column(name = "CREATED_TIME")
|
||||
@Column(name = "created_time")
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* */
|
||||
@Column(name = "STATUS")
|
||||
@Column(name = "status")
|
||||
private String status;
|
||||
}
|
@ -8,33 +8,39 @@ import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Table(name = "SYS_ROLE")
|
||||
@Table(name = "sys_role")
|
||||
public class Role {
|
||||
@Id
|
||||
@Column(name = "ID_ROLE")
|
||||
private String idRole;
|
||||
@Column(name = "id")
|
||||
private Integer idRole;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
* */
|
||||
@Column(name = "NAME")
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 拼音码
|
||||
* */
|
||||
@Column(name = "INPUT_CODE")
|
||||
@Column(name = "input_code")
|
||||
private String inputCode;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* */
|
||||
@Column(name = "STATUS")
|
||||
private Integer status;
|
||||
@Column(name = "status")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
* */
|
||||
@Column(name = "CREATED_TIME")
|
||||
@Column(name = "created_time")
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
* */
|
||||
@Column(name = "updated_time")
|
||||
private Date updatedTime;
|
||||
}
|
@ -9,97 +9,97 @@ import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
@Table(name = "SYS_USER")
|
||||
@Table(name = "sys_user")
|
||||
@Data
|
||||
public class User {
|
||||
@Id
|
||||
@Column(name = "ID_USER")
|
||||
@Column(name = "id")
|
||||
private Integer idUser;
|
||||
|
||||
/**
|
||||
* 应用ID
|
||||
* */
|
||||
@Column(name = "APP_ID")
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 登录账号
|
||||
* */
|
||||
@Column(name = "ACCOUNT")
|
||||
@Column(name = "account")
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
* */
|
||||
@Column(name = "PASSWORD")
|
||||
@Column(name = "password")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
* */
|
||||
@Column(name = "NICK_NAME")
|
||||
private String nickName;
|
||||
@Column(name = "nickname")
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 真实姓名
|
||||
* */
|
||||
@Column(name = "REAL_NAME")
|
||||
@Column(name = "real_name")
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 性别 1:男性 2:女性
|
||||
* */
|
||||
@Column(name = "SEX")
|
||||
private Integer sex;
|
||||
@Column(name = "sex")
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 头像文件类型
|
||||
* */
|
||||
@Column(name = "AVATAR_TYPE")
|
||||
private Integer avatarType;
|
||||
@Column(name = "avatar_type")
|
||||
private String avatarType;
|
||||
|
||||
/**
|
||||
* 头像路径
|
||||
* */
|
||||
@Column(name = "AVATAR_URL")
|
||||
@Column(name = "avatar_url")
|
||||
private String avatarUrl;
|
||||
|
||||
/**
|
||||
* 邮箱地址
|
||||
* */
|
||||
@ColumnType(column = "EMAIL",
|
||||
@ColumnType(column = "email",
|
||||
jdbcType = JdbcType.VARCHAR)
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
* */
|
||||
@ColumnType(column = "PHONE",
|
||||
@ColumnType(column = "phone",
|
||||
jdbcType = JdbcType.VARCHAR)
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 签名
|
||||
* */
|
||||
@ColumnType(column = "SIGNATURE",
|
||||
@ColumnType(column = "signature",
|
||||
jdbcType = JdbcType.VARCHAR)
|
||||
private String signature;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* */
|
||||
@Column(name = "STATUS")
|
||||
private Integer status;
|
||||
@Column(name = "status")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 最后登录时间
|
||||
* */
|
||||
@Column(name = "LAST_LOGIN_TIME")
|
||||
@Column(name = "last_login_time")
|
||||
private Date lastLoginTime;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
* */
|
||||
@Column(name = "CREATED_TIME")
|
||||
@Column(name = "created_time")
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
* */
|
||||
@Column(name = "updated_time")
|
||||
private Date updatedTime;
|
||||
}
|
@ -10,15 +10,5 @@ import java.util.List;
|
||||
|
||||
public interface MenuMapper extends Mapper<Menu> {
|
||||
|
||||
List<Menu> selectMenuByRole(@Param("role") Role role);
|
||||
|
||||
List<MenuDTO> findByParentId(@Param("parentId") String parentId);
|
||||
|
||||
MenuDTO findMenuDTOById(@Param("id") String id);
|
||||
|
||||
void deleteRoleMenu(@Param("menuId") String id);
|
||||
|
||||
List<MenuDTO> findByParentIdAndUserId(@Param("parentId") String parentId, @Param("userId") String userId);
|
||||
|
||||
void deleteMenu(@Param("id") String id);
|
||||
List<Menu> selectMenuByIdRole(@Param("role") Integer role);
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package com.rymcu.vertical.mapper;
|
||||
|
||||
import com.rymcu.vertical.core.mapper.Mapper;
|
||||
import com.rymcu.vertical.dto.RoleDTO;
|
||||
import com.rymcu.vertical.dto.UserDTO;
|
||||
import com.rymcu.vertical.entity.Role;
|
||||
import com.rymcu.vertical.entity.User;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -10,25 +8,8 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
public interface RoleMapper extends Mapper<Role> {
|
||||
List<RoleDTO> findAllDTO(@Param("role") RoleDTO roleDTO);
|
||||
|
||||
List<Role> selectRoleByUser(@Param("sysUser") User sysUser);
|
||||
List<Role> selectRoleByIdUser(@Param("id") Integer id);
|
||||
|
||||
void insertRoleMenu(@Param("roleId") String id, @Param("menuId") String menuId);
|
||||
|
||||
void deleteRoleMenuByRoleId(@Param("roleId") String roleId);
|
||||
|
||||
void deleteUserRoleByRoleId(@Param("roleId") String roleId);
|
||||
|
||||
RoleDTO findRoleDTOById(@Param("roleId") String roleId);
|
||||
|
||||
String selectRoleIdsByUser(@Param("user") User user);
|
||||
|
||||
List<UserDTO> findUserOfRoleListData(@Param("user") UserDTO userDTO);
|
||||
|
||||
void deleteUser(@Param("userId") String userId, @Param("roleId") String roleId);
|
||||
|
||||
List<UserDTO> findUnAddUserOfRole(@Param("userName") String userName, @Param("roleId") String roleId);
|
||||
|
||||
void insertUserRole(@Param("userId") String userId, @Param("roleId") String roleId);
|
||||
Role selectRoleByInputCode(@Param("inputCode") String inputCode);
|
||||
}
|
@ -1,35 +1,15 @@
|
||||
package com.rymcu.vertical.mapper;
|
||||
|
||||
import com.rymcu.vertical.core.mapper.Mapper;
|
||||
import com.rymcu.vertical.dto.RoleDTO;
|
||||
import com.rymcu.vertical.dto.UserDTO;
|
||||
import com.rymcu.vertical.dto.UserExportDTO;
|
||||
import com.rymcu.vertical.dto.UserInfoDTO;
|
||||
import com.rymcu.vertical.entity.User;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface UserMapper extends Mapper<User> {
|
||||
List<UserDTO> findAllDTO(@Param("user") UserDTO userDTO);
|
||||
|
||||
UserDTO findUserDTOById(@Param("idUser") Integer idUser);
|
||||
User findByAccount(@Param("account") String account);
|
||||
|
||||
void insertUserRole(@Param("idUser") Integer idUser, @Param("idRole") Integer idRole);
|
||||
Integer insertUserRole(@Param("idUser") Integer idUser, @Param("idRole") Integer idRole);
|
||||
|
||||
void deleteUserRoleByUserId(@Param("idUser") Integer idUser);
|
||||
|
||||
void deleteUserById(@Param("idUser") Integer idUser);
|
||||
|
||||
void resetPassword(@Param("idUser") Integer idUser, @Param("password") String password);
|
||||
|
||||
void updateLastLoginTime(@Param("idUser") Integer idUser, @Param("date") Date date);
|
||||
|
||||
User findByLoginName(@Param("loginName") String loginName);
|
||||
|
||||
List<UserDTO> queryUserByInputCode(@Param("eName") String eName);
|
||||
|
||||
List<UserExportDTO> findUserExportData(@Param("user") UserDTO userDTO);
|
||||
|
||||
List<RoleDTO> findRoleOfUser(@Param("idUser") Integer idUser);
|
||||
UserInfoDTO findUserInfoByAccount(@Param("account") String account);
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.rymcu.vertical.service;
|
||||
|
||||
public interface JavaMailService {
|
||||
Integer sendEmailCode(String email);
|
||||
}
|
@ -14,20 +14,4 @@ import java.util.List;
|
||||
public interface MenuService extends Service<Menu> {
|
||||
|
||||
List<Menu> selectMenuByUser(User sysUser);
|
||||
|
||||
Menu getParent(Menu e);
|
||||
|
||||
List<MenuDTO> findByParentId(String roleId);
|
||||
|
||||
MenuDTO findMenuDTOById(String id);
|
||||
|
||||
void saveMenu(MenuDTO menuDTO);
|
||||
|
||||
void deleteMenuById(String id);
|
||||
|
||||
void updateMenu(MenuDTO menuDTO);
|
||||
|
||||
List<MenuDTO> findByParentIdAndUserId(String parentId, String userId);
|
||||
|
||||
void updateUserStatus(String id, String flag);
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
package com.rymcu.vertical.service;
|
||||
|
||||
import com.rymcu.vertical.core.service.Service;
|
||||
import com.rymcu.vertical.dto.RoleDTO;
|
||||
import com.rymcu.vertical.dto.UserDTO;
|
||||
import com.rymcu.vertical.entity.Role;
|
||||
import com.rymcu.vertical.entity.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -16,24 +13,4 @@ import java.util.List;
|
||||
public interface RoleService extends Service<Role> {
|
||||
|
||||
List<Role> selectRoleByUser(User sysUser);
|
||||
|
||||
List<RoleDTO> findAllDTO(HttpServletRequest request);
|
||||
|
||||
void saveRole(RoleDTO roleDTO);
|
||||
|
||||
void deleteAssociatedItemsForRole(String id);
|
||||
|
||||
RoleDTO findRoleDTOById(String id);
|
||||
|
||||
void updateRole(RoleDTO roleDTO);
|
||||
|
||||
List<UserDTO> findUserOfRoleListData(HttpServletRequest request);
|
||||
|
||||
void deleteUser(String userId, String roleId);
|
||||
|
||||
List<UserDTO> findUnAddUserOfRole(HttpServletRequest request);
|
||||
|
||||
String addUserOfRole(String roleId, String ids);
|
||||
|
||||
void updateMenu(RoleDTO roleDTO);
|
||||
}
|
||||
|
@ -1,15 +1,10 @@
|
||||
package com.rymcu.vertical.service;
|
||||
|
||||
import com.rymcu.vertical.core.exception.ServiceException;
|
||||
import com.rymcu.vertical.core.service.Service;
|
||||
import com.rymcu.vertical.dto.RoleDTO;
|
||||
import com.rymcu.vertical.dto.UserDTO;
|
||||
import com.rymcu.vertical.dto.UserExportDTO;
|
||||
import com.rymcu.vertical.entity.User;
|
||||
import org.apache.ibatis.exceptions.TooManyResultsException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@ -17,29 +12,10 @@ import java.util.List;
|
||||
*/
|
||||
public interface UserService extends Service<User> {
|
||||
|
||||
List<UserDTO> findAllDTO(HttpServletRequest request);
|
||||
|
||||
UserDTO findUserDTOById(Integer id);
|
||||
User findByAccount(String account) throws TooManyResultsException;
|
||||
|
||||
void saveUser(UserDTO userDTO);
|
||||
Map register(String email, String password, String code);
|
||||
|
||||
void updateUser(UserDTO userDTO);
|
||||
|
||||
void deleteUserById(Integer id);
|
||||
|
||||
Boolean checkLoginName(String loginName);
|
||||
|
||||
void updateUserStatus(Integer id, Integer flag);
|
||||
|
||||
void resetPassword(Integer userId, String password);
|
||||
|
||||
User findByLoginName(String loginName) throws TooManyResultsException, ServiceException;
|
||||
|
||||
List<UserDTO> queryUserByInputCode(String eName);
|
||||
|
||||
void updateLastLoginTime(Integer id);
|
||||
|
||||
List<UserExportDTO> exportExcel(HttpServletRequest request);
|
||||
|
||||
List<RoleDTO> findRoleOfUser(HttpServletRequest request);
|
||||
Map login(String account, String password);
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package com.rymcu.vertical.service.impl;
|
||||
|
||||
import com.rymcu.vertical.core.service.redis.RedisService;
|
||||
import com.rymcu.vertical.service.JavaMailService;
|
||||
import com.rymcu.vertical.util.Utils;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class JavaMailServiceImpl implements JavaMailService {
|
||||
|
||||
@Resource
|
||||
private JavaMailSenderImpl mailSender;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public Integer sendEmailCode(String email) {
|
||||
return sendCode(email,0);
|
||||
}
|
||||
|
||||
private Integer sendCode(String to, Integer type) {
|
||||
Integer code = Utils.genCode();
|
||||
redisService.set(to,code,5*60);
|
||||
if(type == 0) {
|
||||
SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
|
||||
simpleMailMessage.setFrom("service@rymcu.com");
|
||||
simpleMailMessage.setTo(to);
|
||||
simpleMailMessage.setSubject("新用户注册邮箱验证");
|
||||
simpleMailMessage.setText("【RYMCU】您的校验码是 " + code + ",有效时间 5 分钟,请不要泄露验证码给其他人。如非本人操作,请忽略!");
|
||||
mailSender.send(simpleMailMessage);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -36,72 +36,10 @@ public class MenuServiceImpl extends AbstractService<Menu> implements MenuServic
|
||||
public List<Menu> selectMenuByUser(User sysUser) {
|
||||
List<Menu> list = new ArrayList<Menu>();
|
||||
List<Role> roles = roleService.selectRoleByUser(sysUser);
|
||||
roles.forEach(role -> list.addAll(menuMapper.selectMenuByRole(role)));
|
||||
roles.forEach(role -> list.addAll(menuMapper.selectMenuByIdRole(role.getIdRole())));
|
||||
HashSet hashSet = new HashSet(list);
|
||||
list.clear();
|
||||
list.addAll(hashSet);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Menu getParent(Menu e) {
|
||||
String parentId = "0";
|
||||
if(e != null){
|
||||
if(StringUtils.isNotBlank(e.getParentId())){
|
||||
parentId = e.getParentId();
|
||||
}
|
||||
}
|
||||
return menuMapper.selectByPrimaryKey(parentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuDTO> findByParentId(String parentId) {
|
||||
List<MenuDTO> list = menuMapper.findByParentId(parentId);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuDTO findMenuDTOById(String id) {
|
||||
return menuMapper.findMenuDTOById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveMenu(MenuDTO menuDTO) {
|
||||
Menu menu = new Menu();
|
||||
BeanCopierUtil.copy(menuDTO,menu);
|
||||
//Utils.createBase(menu);
|
||||
menuMapper.insert(menu);
|
||||
//Utils.removeAllMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMenuById(String id) {
|
||||
menuMapper.deleteRoleMenu(id);
|
||||
menuMapper.deleteMenu(id);
|
||||
//Utils.removeAllMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMenu(MenuDTO menuDTO) {
|
||||
Menu menu = menuMapper.selectByPrimaryKey(menuDTO.getId());
|
||||
BeanCopierUtil.copy(menuDTO,menu);
|
||||
//Utils.updateBase(menu);
|
||||
menuMapper.updateByPrimaryKey(menu);
|
||||
//Utils.removeAllMenu();
|
||||
//UserUtils.removeMenuList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuDTO> findByParentIdAndUserId(String parentId, String userId) {
|
||||
return menuMapper.findByParentIdAndUserId(parentId, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserStatus(String id, String flag) {
|
||||
Menu menu = menuMapper.selectByPrimaryKey(id);
|
||||
menu.setStatus(flag);
|
||||
//Utils.updateBase(menu);
|
||||
menuMapper.updateByPrimaryKey(menu);
|
||||
//Utils.removeAllMenu();
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,15 @@
|
||||
package com.rymcu.vertical.service.impl;
|
||||
|
||||
import com.rymcu.vertical.core.service.AbstractService;
|
||||
import com.rymcu.vertical.dto.RoleDTO;
|
||||
import com.rymcu.vertical.dto.UserDTO;
|
||||
import com.rymcu.vertical.entity.Role;
|
||||
import com.rymcu.vertical.entity.User;
|
||||
import com.rymcu.vertical.mapper.RoleMapper;
|
||||
import com.rymcu.vertical.service.RoleService;
|
||||
import com.rymcu.vertical.util.BeanCopierUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
/**
|
||||
@ -29,119 +23,8 @@ public class RoleServiceImpl extends AbstractService<Role> implements RoleServic
|
||||
|
||||
@Override
|
||||
public List<Role> selectRoleByUser(User sysUser) {
|
||||
List<Role> roles = roleMapper.selectRoleByUser(sysUser);
|
||||
List<Role> roles = roleMapper.selectRoleByIdUser(sysUser.getIdUser());
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleDTO> findAllDTO(HttpServletRequest request) {
|
||||
RoleDTO roleDTO = new RoleDTO();
|
||||
roleDTO.setName(request.getParameter("name"));
|
||||
roleDTO.setEnname(request.getParameter("enName"));
|
||||
return roleMapper.findAllDTO(roleDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveRole(RoleDTO roleDTO) {
|
||||
Role role = new Role();
|
||||
BeanCopierUtil.copy(roleDTO,role);
|
||||
//Utils.createBase(role);
|
||||
roleMapper.insert(role);
|
||||
|
||||
String menuIds = roleDTO.getMenuIds();
|
||||
String[] m = menuIds.split(",");
|
||||
for (int i = 0,len = m.length; i < len; i++) {
|
||||
roleMapper.insertRoleMenu(role.getIdRole(),m[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAssociatedItemsForRole(String roleId) {
|
||||
|
||||
roleMapper.deleteUserRoleByRoleId(roleId);
|
||||
|
||||
roleMapper.deleteByPrimaryKey(roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleDTO findRoleDTOById(String id) {
|
||||
return roleMapper.findRoleDTOById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRole(RoleDTO roleDTO) {
|
||||
String menuIds = "";
|
||||
Role role = roleMapper.selectByPrimaryKey(roleDTO.getId());
|
||||
|
||||
BeanCopierUtil.copy(roleDTO,role);
|
||||
//Utils.updateBase(role);
|
||||
roleMapper.updateByPrimaryKey(role);
|
||||
|
||||
if("0".equals(roleDTO.getMenuIds())){
|
||||
menuIds = roleMapper.findRoleDTOById(roleDTO.getId()).getMenuIds();
|
||||
}else {
|
||||
menuIds = roleDTO.getMenuIds();
|
||||
}
|
||||
|
||||
roleMapper.deleteRoleMenuByRoleId(role.getIdRole());
|
||||
|
||||
String[] m = menuIds.split(",");
|
||||
for (int i = 0,len = m.length; i < len; i++) {
|
||||
roleMapper.insertRoleMenu(role.getIdRole(),m[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> findUserOfRoleListData(HttpServletRequest request) {
|
||||
UserDTO userDTO = new UserDTO();
|
||||
userDTO.setLoginName(request.getParameter("loginName"));
|
||||
userDTO.setInputCode(request.getParameter("inputCode"));
|
||||
userDTO.setName(request.getParameter("name"));
|
||||
userDTO.setStatus(request.getParameter("status"));
|
||||
userDTO.setOfficeId(request.getParameter("officeId"));
|
||||
userDTO.setRemarks(request.getParameter("roleId"));// 为不创建多余字段,此处使用 Remark 字段存放 roleId 数据
|
||||
return roleMapper.findUserOfRoleListData(userDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUser(String userId, String roleId) {
|
||||
roleMapper.deleteUser(userId,roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> findUnAddUserOfRole(HttpServletRequest request) {
|
||||
String roleId = request.getParameter("roleId");
|
||||
String userName = request.getParameter("userName");
|
||||
return roleMapper.findUnAddUserOfRole(userName,roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addUserOfRole(String roleId, String ids) {
|
||||
String message = "";
|
||||
String[] userIds = ids.split(",");
|
||||
for (String userId:userIds) {
|
||||
if(!(",".equals(userId) || StringUtils.isBlank(userId))){
|
||||
roleMapper.insertUserRole(userId,roleId);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMenu(RoleDTO roleDTO) {
|
||||
String menuIds;
|
||||
if("0".equals(roleDTO.getMenuIds())){
|
||||
menuIds = roleMapper.findRoleDTOById(roleDTO.getId()).getMenuIds();
|
||||
}else {
|
||||
menuIds = roleDTO.getMenuIds();
|
||||
}
|
||||
|
||||
roleMapper.deleteRoleMenuByRoleId(roleDTO.getId());
|
||||
|
||||
String[] m = menuIds.split(",");
|
||||
for (int i = 0,len = m.length; i < len; i++) {
|
||||
roleMapper.insertRoleMenu(roleDTO.getId(),m[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.rymcu.vertical.service.impl;
|
||||
|
||||
import com.rymcu.vertical.core.exception.ServiceException;
|
||||
import com.rymcu.vertical.core.service.AbstractService;
|
||||
import com.rymcu.vertical.dto.RoleDTO;
|
||||
import com.rymcu.vertical.dto.UserDTO;
|
||||
import com.rymcu.vertical.dto.UserExportDTO;
|
||||
import com.rymcu.vertical.core.service.redis.RedisService;
|
||||
import com.rymcu.vertical.dto.TUser;
|
||||
import com.rymcu.vertical.dto.UserInfoDTO;
|
||||
import com.rymcu.vertical.entity.Role;
|
||||
import com.rymcu.vertical.entity.User;
|
||||
import com.rymcu.vertical.jwt.service.TokenManager;
|
||||
import com.rymcu.vertical.mapper.RoleMapper;
|
||||
import com.rymcu.vertical.mapper.UserMapper;
|
||||
import com.rymcu.vertical.service.UserService;
|
||||
import com.rymcu.vertical.util.BeanCopierUtil;
|
||||
@ -14,12 +16,11 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.ibatis.exceptions.TooManyResultsException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import tk.mybatis.mapper.entity.Condition;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@ -29,139 +30,69 @@ import java.util.List;
|
||||
public class UserServiceImpl extends AbstractService<User> implements UserService {
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
@Resource
|
||||
private RoleMapper roleMapper;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
@Resource
|
||||
private TokenManager tokenManager;
|
||||
|
||||
@Override
|
||||
public List<UserDTO> findAllDTO(HttpServletRequest request) {
|
||||
UserDTO userDTO = new UserDTO();
|
||||
userDTO.setLoginName(request.getParameter("loginName"));
|
||||
userDTO.setInputCode(request.getParameter("inputCode"));
|
||||
userDTO.setName(request.getParameter("name"));
|
||||
userDTO.setStatus(request.getParameter("status"));
|
||||
userDTO.setOfficeId(request.getParameter("officeId"));// 为不创建多余字段,此处使用 Remark 字段存放 nodeId 数据
|
||||
return userMapper.findAllDTO(userDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDTO findUserDTOById(Integer id) {
|
||||
return userMapper.findUserDTOById(id);
|
||||
public User findByAccount(String account) throws TooManyResultsException{
|
||||
return userMapper.findByAccount(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveUser(UserDTO userDTO) {
|
||||
public Map register(String email, String password, String code) {
|
||||
Map map = new HashMap();
|
||||
map.put("message","验证码无效!");
|
||||
String vcode = redisService.get(email);
|
||||
if(StringUtils.isNotBlank(vcode)){
|
||||
if(vcode.equals(code)){
|
||||
User user = userMapper.findByAccount(email);
|
||||
if(user != null){
|
||||
map.put("message","该邮箱已被注册!");
|
||||
} else {
|
||||
user = new User();
|
||||
user.setAccount(email);
|
||||
user.setNickname(email);
|
||||
user.setEmail(email);
|
||||
user.setPassword(Utils.entryptPassword(password));
|
||||
user.setCreatedTime(new Date());
|
||||
user.setUpdatedTime(user.getCreatedTime());
|
||||
userMapper.insertSelective(user);
|
||||
user = userMapper.findByAccount(email);
|
||||
Role role = roleMapper.selectRoleByInputCode("user");
|
||||
userMapper.insertUserRole(user.getIdUser(), role.getIdRole());
|
||||
map.put("message","注册成功!");
|
||||
redisService.delete(email);
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map login(String account, String password) {
|
||||
Map map = new HashMap();
|
||||
User user = new User();
|
||||
BeanCopierUtil.copy(userDTO, user);
|
||||
//user.setPassword(Utils.entryptPassword("123456"));
|
||||
//Utils.createBase(user);
|
||||
//所有字符转为小写
|
||||
user.setAccount(user.getAccount().toLowerCase());
|
||||
userMapper.insertSelective(user);
|
||||
|
||||
String roleIds = userDTO.getRoleIds();
|
||||
if(StringUtils.isNotBlank(roleIds)){
|
||||
String[] r = roleIds.split(",");
|
||||
for(int i=0,len=r.length;i<len;i++){
|
||||
userMapper.insertUserRole(user.getIdUser(), Integer.parseInt(r[i]));
|
||||
user.setAccount(account);
|
||||
user = userMapper.selectOne(user);
|
||||
if(user != null){
|
||||
if(Utils.comparePwd(password, user.getPassword())){
|
||||
user.setLastLoginTime(new Date());
|
||||
userMapper.updateByPrimaryKeySelective(user);
|
||||
TUser tUser = new TUser();
|
||||
BeanCopierUtil.copy(user,tUser);
|
||||
tUser.setToken(tokenManager.createToken(account));
|
||||
map.put("user",user);
|
||||
} else {
|
||||
map.put("message","密码错误!");
|
||||
}
|
||||
} else {
|
||||
map.put("message","该账号不存在!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateUser(UserDTO userDTO) {
|
||||
User user = userMapper.selectByPrimaryKey(userDTO.getId());
|
||||
String password = user.getPassword();
|
||||
userDTO.setLastLoginTime(user.getLastLoginTime());
|
||||
BeanCopierUtil.copy(userDTO,user);
|
||||
// 如果密码为空,则不更换密码
|
||||
if (StringUtils.isNotBlank(user.getPassword())) {
|
||||
user.setPassword(Utils.entryptPassword(user.getPassword()));
|
||||
}else {
|
||||
user.setPassword(password);
|
||||
}
|
||||
if(user.getCreatedTime() == null){
|
||||
user.setCreatedTime(new Date());
|
||||
}
|
||||
userMapper.updateByPrimaryKeySelective(user);
|
||||
|
||||
String roleIds = userDTO.getRoleIds();
|
||||
|
||||
userMapper.deleteUserRoleByUserId(user.getIdUser());
|
||||
if(!"0".equals(roleIds) && StringUtils.isNotBlank(roleIds)){
|
||||
String[] r = roleIds.split(",");
|
||||
for(int i=0,len=r.length;i<len;i++){
|
||||
userMapper.insertUserRole(user.getIdUser(), Integer.parseInt(r[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteUserById(Integer idUser) {
|
||||
if(idUser.equals(Utils.getCurrentUser().getIdUser())){
|
||||
|
||||
}else{
|
||||
userMapper.deleteUserById(idUser);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean checkLoginName(String loginName){
|
||||
Condition userCondition = new Condition(User.class);
|
||||
userCondition.createCriteria().andCondition("LOGIN_NAME =",loginName.toLowerCase());
|
||||
List<User> user = userMapper.selectByCondition(userCondition);
|
||||
Boolean b = false;
|
||||
if (user.size() == 0){
|
||||
b = true;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateUserStatus(Integer id, Integer flag) {
|
||||
User user = userMapper.selectByPrimaryKey(id);
|
||||
user.setStatus(flag);
|
||||
userMapper.updateByPrimaryKey(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void resetPassword(Integer userId, String password) {
|
||||
userMapper.resetPassword(userId,password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User findByLoginName(String loginName) throws TooManyResultsException, ServiceException{
|
||||
return userMapper.findByLoginName(loginName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> queryUserByInputCode(String eName) {
|
||||
return userMapper.queryUserByInputCode(eName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateLastLoginTime(Integer id) {
|
||||
userMapper.updateLastLoginTime(id,new Date());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserExportDTO> exportExcel(HttpServletRequest request) {
|
||||
UserDTO userDTO = new UserDTO();
|
||||
userDTO.setLoginName(request.getParameter("loginName"));
|
||||
userDTO.setInputCode(request.getParameter("inputCode"));
|
||||
userDTO.setName(request.getParameter("name"));
|
||||
userDTO.setStatus(request.getParameter("status"));
|
||||
userDTO.setOfficeId(request.getParameter("officeId"));
|
||||
return userMapper.findUserExportData(userDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleDTO> findRoleOfUser(HttpServletRequest request) {
|
||||
String userId = request.getParameter("userId");
|
||||
return userMapper.findRoleOfUser(Integer.parseInt(userId));
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
@ -52,4 +52,9 @@ public class Utils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Integer genCode() {
|
||||
Integer code = (int)((Math.random()*9+1)*100000);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.rymcu.vertical.web.api.common;
|
||||
|
||||
import com.rymcu.vertical.core.exception.ServiceException;
|
||||
import com.rymcu.vertical.core.result.GlobalResult;
|
||||
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
||||
import com.rymcu.vertical.core.result.GlobalResultMessage;
|
||||
import com.rymcu.vertical.entity.User;
|
||||
import com.rymcu.vertical.service.JavaMailService;
|
||||
import com.rymcu.vertical.service.UserService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1")
|
||||
public class CommonApiController {
|
||||
|
||||
@Resource
|
||||
private JavaMailService javaMailService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@ApiOperation(value = "获取邮件验证码")
|
||||
@PostMapping("/get-email-code")
|
||||
public GlobalResult getEmailCode(@RequestParam("email") String email) throws ServiceException {
|
||||
Map map = new HashMap();
|
||||
map.put("message",GlobalResultMessage.SEND_SUCCESS);
|
||||
User user = userService.findByAccount(email);
|
||||
if (user != null) {
|
||||
map.put("message","该邮箱已被注册!");
|
||||
} else {
|
||||
Integer result = javaMailService.sendEmailCode(email);
|
||||
if(result == 0){
|
||||
map.put("message",GlobalResultMessage.SEND_FAIL);
|
||||
}
|
||||
}
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
||||
@PostMapping("/register")
|
||||
public GlobalResult register(@RequestParam("email") String email, @RequestParam("password") String password, @RequestParam("code") String code){
|
||||
Map map = userService.register(email,password,code);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public GlobalResult login(@RequestParam("account") String account, @RequestParam("password") String password){
|
||||
Map map = userService.login(account,password);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
}
|
@ -5,83 +5,18 @@
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
-->
|
||||
<id column="ID" jdbcType="VARCHAR" property="idMenu"/>
|
||||
<result column="PARENT_ID" jdbcType="VARCHAR" property="parentId"/>
|
||||
<result column="NAME" jdbcType="OTHER" property="name"/>
|
||||
<result column="SORT" jdbcType="DECIMAL" property="sort"/>
|
||||
<result column="HREF" jdbcType="VARCHAR" property="href"/>
|
||||
<result column="MENU_TYPE" jdbcType="CHAR" property="menuType"/>
|
||||
<result column="PERMISSION" jdbcType="VARCHAR" property="permission"/>
|
||||
<result column="CREATED_TIME" jdbcType="TIMESTAMP" property="createdTime"/>
|
||||
<result column="STATUS" jdbcType="CHAR" property="status"/>
|
||||
<id column="id" jdbcType="INTEGER" property="idMenu"/>
|
||||
<result column="parent_id" jdbcType="VARCHAR" property="parentId"/>
|
||||
<result column="name" jdbcType="OTHER" property="name"/>
|
||||
<result column="sort" jdbcType="INTEGER" property="sort"/>
|
||||
<result column="href" jdbcType="VARCHAR" property="href"/>
|
||||
<result column="menu_type" jdbcType="CHAR" property="menuType"/>
|
||||
<result column="permission" jdbcType="VARCHAR" property="permission"/>
|
||||
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
|
||||
<result column="status" jdbcType="CHAR" property="status"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="select">
|
||||
ID,
|
||||
PARENT_ID parentId,
|
||||
(select NAME
|
||||
from SYS_MENU
|
||||
where ID = #{parentId}) parentName,
|
||||
NAME,
|
||||
SORT,
|
||||
HREF,
|
||||
MENU_TYPE menuType,
|
||||
PERMISSION,
|
||||
REMARKS,
|
||||
STATUS
|
||||
</sql>
|
||||
|
||||
<sql id="selectOne">
|
||||
ID,
|
||||
PARENT_ID parentId,
|
||||
(select NAME
|
||||
from SYS_MENU
|
||||
where ID = m.PARENT_ID) parentName,
|
||||
NAME,
|
||||
SORT,
|
||||
HREF,
|
||||
MENU_TYPE menuType,
|
||||
PERMISSION,
|
||||
REMARKS,
|
||||
STATUS
|
||||
</sql>
|
||||
|
||||
<delete id="deleteRoleMenu">
|
||||
delete SYS_ROLE_MENU
|
||||
where MENU_ID = #{menuId}
|
||||
</delete>
|
||||
<update id="deleteMenu">
|
||||
update SYS_MENU set STATUS = '2' where ID = #{id}
|
||||
</update>
|
||||
|
||||
<select id="selectMenuByRole" resultType="com.rymcu.vertical.entity.Menu">
|
||||
select *
|
||||
from SYS_MENU
|
||||
where STATUS = '0' and ID in (select MENU_ID
|
||||
from SYS_ROLE_MENU
|
||||
where ROLE_ID = #{role.id}) order by SORT
|
||||
<select id="selectMenuByIdRole" resultMap="BaseResultMap">
|
||||
select * from sys_role_menu srm left join sys_menu sm on srm.id_menu = sm.id where status = '0' order by sort
|
||||
</select>
|
||||
|
||||
<select id="findByParentId" resultType="com.rymcu.vertical.dto.MenuDTO">
|
||||
select
|
||||
<include refid="select"/>
|
||||
from SYS_MENU
|
||||
where PARENT_ID = #{parentId} and STATUS != '2' order by SORT
|
||||
</select>
|
||||
|
||||
<select id="findMenuDTOById" resultType="com.rymcu.vertical.dto.MenuDTO">
|
||||
select
|
||||
<include refid="selectOne"/>
|
||||
from SYS_MENU m
|
||||
where ID = #{id} order by SORT
|
||||
</select>
|
||||
|
||||
<select id="findByParentIdAndUserId" resultType="com.rymcu.vertical.dto.MenuDTO">
|
||||
select
|
||||
<include refid="selectOne"/>
|
||||
from SYS_MENU m where PARENT_ID = #{parentId} and MENU_TYPE = '0' and STATUS = '0'
|
||||
and ID in (select MENU_ID from SYS_ROLE_MENU where ROLE_ID in (SELECT ROLE_ID from SYS_USER_ROLE where USER_ID = #{userId}))
|
||||
order by SORT
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -5,143 +5,25 @@
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
-->
|
||||
<id column="ID" jdbcType="VARCHAR" property="idRole"/>
|
||||
<result column="NAME" jdbcType="OTHER" property="name"/>
|
||||
<result column="ENNAME" jdbcType="VARCHAR" property="inputCode"/>
|
||||
<result column="CREATED_DATE" jdbcType="TIMESTAMP" property="createdTime"/>
|
||||
<result column="STATUS" jdbcType="CHAR" property="status"/>
|
||||
<id column="id" jdbcType="INTEGER" property="idRole"/>
|
||||
<result column="name" jdbcType="VARCHAR" property="name"/>
|
||||
<result column="input_code" jdbcType="VARCHAR" property="inputCode"/>
|
||||
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
|
||||
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
|
||||
<result column="status" jdbcType="INTEGER" property="status"/>
|
||||
</resultMap>
|
||||
<resultMap id="RoleDTOResultMap" type="com.rymcu.vertical.dto.RoleDTO">
|
||||
<id column="ID" property="id"></id>
|
||||
<result column="NAME" property="name"/>
|
||||
<result column="ENNAME" property="enname"/>
|
||||
<result column="ROLE_TYPE" property="roleType"/>
|
||||
<result column="REMARKS" property="remarks"/>
|
||||
<result column="MENU_IDS" property="menuIds"/>
|
||||
<id column="id" property="id"></id>
|
||||
<result column="name" property="name"/>
|
||||
<result column="input_code" property="inputCode"/>
|
||||
<result column="menu_ids" property="menuIds"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="select">
|
||||
r.ID,
|
||||
r.NAME,
|
||||
r.ROLE_TYPE,
|
||||
r.ENNAME,
|
||||
r.REMARKS
|
||||
</sql>
|
||||
|
||||
<insert id="insertRoleMenu">
|
||||
insert into SYS_ROLE_MENU (ROLE_ID, MENU_ID) VALUES (#{roleId}, #{menuId})
|
||||
</insert>
|
||||
<insert id="insertUserRole">
|
||||
insert into SYS_USER_ROLE (USER_ID, ROLE_ID) VALUES (#{userId}, #{roleId})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteRoleMenuByRoleId">
|
||||
delete SYS_ROLE_MENU where ROLE_ID = #{roleId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteUserRoleByRoleId">
|
||||
delete SYS_USER_ROLE where ROLE_ID = #{roleId}
|
||||
</delete>
|
||||
<delete id="deleteUser">
|
||||
delete SYS_USER_ROLE where ROLE_ID = #{roleId} AND USER_ID = #{userId}
|
||||
</delete>
|
||||
|
||||
<select id="findAllDTO" resultMap="RoleDTOResultMap">
|
||||
select
|
||||
<include refid="select"/>,
|
||||
(select rtrim(XMLAGG(XMLELEMENT(E, MENU_ID || ',')).EXTRACT('//text()').getclobval(),',') from SYS_ROLE_MENU where ROLE_ID = r.ID) MENU_IDS
|
||||
from SYS_ROLE r
|
||||
where 1 = 1
|
||||
<if test="role.name != null and role.name != ''">
|
||||
and r.NAME like '%'||#{role.name}||'%'
|
||||
</if>
|
||||
<if test="role.enname != null and role.enname != ''">
|
||||
and r.ENNAME like '%'||#{role.enname}||'%'
|
||||
</if>
|
||||
ORDER BY r.CREATE_DATE DESC
|
||||
<select id="selectRoleByIdUser" resultMap="BaseResultMap">
|
||||
select sr.* from sys_user_role sur left join sys_role sr on sur.id_role = sr.id where id_user = #{id}
|
||||
</select>
|
||||
<select id="selectRoleByInputCode" resultMap="BaseResultMap">
|
||||
select * from sys_role where input_code = #{inputCode}
|
||||
</select>
|
||||
|
||||
<select id="selectRoleByUser" resultMap="BaseResultMap">
|
||||
select *
|
||||
from SYS_ROLE
|
||||
where ID in (select ROLE_ID
|
||||
from SYS_USER_ROLE
|
||||
where USER_ID = #{sysUser.id})
|
||||
</select>
|
||||
<select id="findRoleDTOById" resultMap="RoleDTOResultMap">
|
||||
select
|
||||
<include refid="select"/>,
|
||||
(select rtrim(XMLAGG(XMLELEMENT(E, MENU_ID || ',')).EXTRACT('//text()').getclobval(),',') from SYS_ROLE_MENU where ROLE_ID = #{roleId}) MENU_IDS
|
||||
from SYS_ROLE r where r.id = #{roleId}
|
||||
</select>
|
||||
<select id="selectRoleIdsByUser" resultType="java.lang.String">
|
||||
SELECT wm_concat(ROLE_ID) from SYS_USER_ROLE where USER_ID = #{user.id}
|
||||
</select>
|
||||
<select id="findUserOfRoleListData" resultType="com.rymcu.vertical.dto.UserDTO">
|
||||
select
|
||||
u.ID,
|
||||
u.NO,
|
||||
u.LOGIN_NAME loginName,
|
||||
u.SEX,
|
||||
u.NAME,
|
||||
u.EMAIL,
|
||||
u.MOBILE,
|
||||
u.PHONE,
|
||||
u.OFFICE_ID officeId,
|
||||
u.LAST_LOGIN_TIME lastLoginTime,
|
||||
u.STATUS,
|
||||
u.REMARKS,
|
||||
u.INPUT_CODE inputCode,
|
||||
(
|
||||
select NAME from SYS_OFFICE o2 where o2.ID = u.OFFICE_ID
|
||||
<if test="user.office != null and user.office != ''">
|
||||
and o2.NAME = #{user.office}
|
||||
</if>
|
||||
) office,
|
||||
(select wm_concat(ROLE_ID) from SYS_USER_ROLE where USER_ID = u.ID) roleIds
|
||||
from SYS_USER u
|
||||
left join SYS_USER_ROLE sur
|
||||
on u.ID = sur.USER_ID
|
||||
where sur.ROLE_ID = #{user.remarks} and u.STATUS != 2
|
||||
<if test="user.officeId != null and user.officeId != ''">
|
||||
and ( u.OFFICE_ID in (select id from SYS_OFFICE where status = 0 start with id = #{user.officeId} connect by prior id = parent_id))
|
||||
</if>
|
||||
<if test="user.name != null and user.name != ''">
|
||||
and u.NAME like '%'||#{user.name}||'%'
|
||||
</if>
|
||||
<if test="user.loginName != null and user.loginName != ''">
|
||||
and u.LOGIN_NAME like '%'||#{user.loginName}||'%'
|
||||
</if>
|
||||
<if test="user.inputCode != null and user.inputCode != ''">
|
||||
and u.INPUT_CODE like '%'||#{user.inputCode}||'%'
|
||||
</if>
|
||||
<if test="user.status != null and user.status != ''">
|
||||
and u.STATUS like '%'||#{user.status}||'%'
|
||||
</if>
|
||||
ORDER BY CREATE_DATE
|
||||
</select>
|
||||
<select id="findUnAddUserOfRole" resultType="com.rymcu.vertical.dto.UserDTO">
|
||||
select
|
||||
u.ID,
|
||||
u.NO,
|
||||
u.LOGIN_NAME loginName,
|
||||
u.SEX,
|
||||
u.NAME,
|
||||
u.EMAIL,
|
||||
u.MOBILE,
|
||||
u.PHONE,
|
||||
u.OFFICE_ID officeId,
|
||||
u.LAST_LOGIN_TIME lastLoginTime,
|
||||
u.STATUS,
|
||||
u.REMARKS,
|
||||
u.INPUT_CODE inputCode,
|
||||
(
|
||||
select NAME from SYS_OFFICE o2 where o2.ID = u.OFFICE_ID
|
||||
) office
|
||||
from SYS_USER u
|
||||
where #{roleId} not in (select ROLE_ID from SYS_USER_ROLE where USER_ID = u.ID) and u.STATUS = 0
|
||||
<if test="userName != null and userName != ''">
|
||||
and u.NAME like '%'||#{userName}||'%'
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
@ -5,165 +5,41 @@
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
-->
|
||||
<id column="ID_USER" jdbcType="VARCHAR" property="idUser"/>
|
||||
<result column="APP_ID" jdbcType="VARCHAR" property="appId"/>
|
||||
<result column="ACCOUNT" jdbcType="VARCHAR" property="account"/>
|
||||
<result column="PASSWORD" jdbcType="VARCHAR" property="password"/>
|
||||
<result column="NICK_NAME" jdbcType="VARCHAR" property="nickName"/>
|
||||
<result column="REAL_NAME" jdbcType="VARCHAR" property="realName"/>
|
||||
<result column="SEX" jdbcType="VARCHAR" property="sex"/>
|
||||
<result column="AVATAR_TYPE" jdbcType="VARCHAR" property="avatarType"/>
|
||||
<result column="AVATAR_URL" jdbcType="VARCHAR" property="avatarUrl"/>
|
||||
<result column="EMAIL" jdbcType="VARCHAR" property="email"/>
|
||||
<result column="PHONE" jdbcType="VARCHAR" property="phone"/>
|
||||
<result column="STATUS" jdbcType="NUMBER" property="status"/>
|
||||
<result column="LAST_LOGIN_TIME" jdbcType="TIMESTAMP" property="lastLoginTime"/>
|
||||
<result column="CREATED_TIME" jdbcType="TIMESTAMP" property="createdTime"/>
|
||||
<id column="id" jdbcType="INTEGER" property="idUser"/>
|
||||
<result column="account" jdbcType="VARCHAR" property="account"/>
|
||||
<result column="password" jdbcType="VARCHAR" property="password"/>
|
||||
<result column="nickname" jdbcType="VARCHAR" property="nickname"/>
|
||||
<result column="real_name" jdbcType="VARCHAR" property="realName"/>
|
||||
<result column="sex" jdbcType="CHAR" property="sex"/>
|
||||
<result column="avatar_type" jdbcType="VARCHAR" property="avatarType"/>
|
||||
<result column="avatar_url" jdbcType="VARCHAR" property="avatarUrl"/>
|
||||
<result column="email" jdbcType="VARCHAR" property="email"/>
|
||||
<result column="phone" jdbcType="VARCHAR" property="phone"/>
|
||||
<result column="status" jdbcType="CHAR" property="status"/>
|
||||
<result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/>
|
||||
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
|
||||
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
|
||||
</resultMap>
|
||||
<resultMap id="ExportResultMap" type="com.rymcu.vertical.dto.UserExportDTO">
|
||||
<result column="OFFICE_NAME" property="officeName"/>
|
||||
<result column="NAME" property="name"/>
|
||||
<result column="SEX" property="sex"/>
|
||||
<result column="LOGIN_NAME" property="loginName"/>
|
||||
<result column="STORE_PERM" property="storePerm"/>
|
||||
<result column="DEPART_PERM" property="departPerm"/>
|
||||
</resultMap>
|
||||
<resultMap id="RoleDTOResultMap" type="com.rymcu.vertical.dto.RoleDTO">
|
||||
<id column="ID" property="id"></id>
|
||||
<result column="NAME" property="name"/>
|
||||
<result column="ENNAME" property="enname"/>
|
||||
<result column="ROLE_TYPE" property="roleType"/>
|
||||
<result column="REMARKS" property="remarks"/>
|
||||
<result column="MENU_IDS" property="menuIds"/>
|
||||
<resultMap id="UserInfoResultMapper" type="com.rymcu.vertical.dto.UserInfoDTO">
|
||||
<result column="account" jdbcType="VARCHAR" property="account"/>
|
||||
<result column="nickname" jdbcType="VARCHAR" property="nickname"/>
|
||||
<result column="sex" jdbcType="VARCHAR" property="sex"/>
|
||||
<result column="avatar_type" jdbcType="VARCHAR" property="avatarType"/>
|
||||
<result column="avatar_url" jdbcType="VARCHAR" property="avatarUrl"/>
|
||||
<result column="email" jdbcType="VARCHAR" property="email"/>
|
||||
<result column="phone" jdbcType="VARCHAR" property="phone"/>
|
||||
<result column="status" jdbcType="INTEGER" property="status"/>
|
||||
<result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/>
|
||||
</resultMap>
|
||||
<insert id="insertUserRole">
|
||||
insert into SYS_USER_ROLE (USER_ID, ROLE_ID) VALUES (#{userId}, #{roleId})
|
||||
insert into sys_user_role (id_user,id_role,created_time) values (#{idUser},#{idRole},sysdate())
|
||||
</insert>
|
||||
<delete id="deleteUserRoleByUserId">
|
||||
delete SYS_USER_ROLE
|
||||
where USER_ID = #{userId}
|
||||
</delete>
|
||||
<update id="deleteUserById">
|
||||
update SYS_USER set STATUS = 2 where ID = #{id}
|
||||
</update>
|
||||
<update id="resetPassword">
|
||||
UPDATE SYS_USER SET PASSWORD = #{password} WHERE ID = #{userId}
|
||||
</update>
|
||||
<update id="updateLastLoginTime">
|
||||
UPDATE SYS_USER SET LAST_LOGIN_TIME = #{date} WHERE ID = #{id}
|
||||
</update>
|
||||
<select id="findAllDTO" resultType="com.rymcu.vertical.dto.UserDTO">
|
||||
select
|
||||
u.ID,
|
||||
u.NO,
|
||||
u.LOGIN_NAME loginName,
|
||||
u.SEX,
|
||||
u.NAME,
|
||||
u.EMAIL,
|
||||
u.MOBILE,
|
||||
u.PHONE,
|
||||
u.OFFICE_ID officeId,
|
||||
u.LAST_LOGIN_TIME lastLoginTime,
|
||||
u.STATUS,
|
||||
u.REMARKS,
|
||||
u.INPUT_CODE inputCode,
|
||||
(
|
||||
select NAME from SYS_OFFICE o2 where o2.ID = u.OFFICE_ID
|
||||
<if test="user.office != null and user.office != ''">
|
||||
and o2.NAME = #{user.office}
|
||||
</if>
|
||||
) office,
|
||||
(select wm_concat(ROLE_ID) from SYS_USER_ROLE where USER_ID = u.ID) roleIds
|
||||
from SYS_USER u
|
||||
where u.STATUS != 2
|
||||
<if test="user.officeId != null and user.officeId != ''">
|
||||
and ( u.OFFICE_ID in (select id from SYS_OFFICE where status = 0 start with id = #{user.officeId} connect by prior id = parent_id))
|
||||
</if>
|
||||
<if test="user.name != null and user.name != ''">
|
||||
and u.NAME like '%'||#{user.name}||'%'
|
||||
</if>
|
||||
<if test="user.loginName != null and user.loginName != ''">
|
||||
and u.LOGIN_NAME like '%'||#{user.loginName}||'%'
|
||||
</if>
|
||||
<if test="user.inputCode != null and user.inputCode != ''">
|
||||
and u.INPUT_CODE like '%'||#{user.inputCode}||'%'
|
||||
</if>
|
||||
<if test="user.status != null and user.status != ''">
|
||||
and u.STATUS like '%'||#{user.status}||'%'
|
||||
</if>
|
||||
ORDER BY CREATE_DATE
|
||||
|
||||
<select id="findByAccount" resultMap="BaseResultMap">
|
||||
select id, nickname, account, password, status from sys_user where account = #{account} AND status = 0
|
||||
</select>
|
||||
<select id="findUserDTOById" resultType="com.rymcu.vertical.dto.UserDTO">
|
||||
select
|
||||
u.ID,
|
||||
u.NO,
|
||||
u.LOGIN_NAME loginName,
|
||||
u.SEX,
|
||||
u.NAME,
|
||||
u.EMAIL,
|
||||
u.MOBILE,
|
||||
u.PHONE,
|
||||
u.STATUS,
|
||||
u.OFFICE_ID officeId,
|
||||
u.LAST_LOGIN_TIME lastLoginTime,
|
||||
(
|
||||
select NAME
|
||||
from SYS_OFFICE o2
|
||||
where o2.ID = u.OFFICE_ID
|
||||
) office,
|
||||
(select wm_concat(ROLE_ID) from SYS_USER_ROLE where USER_ID = #{id}) roleIds,
|
||||
u.REMARKS,
|
||||
u.INPUT_CODE inputCode
|
||||
from SYS_USER u
|
||||
where u.id = #{id}
|
||||
</select>
|
||||
<select id="findByLoginName" resultMap="BaseResultMap">
|
||||
SELECT LOGIN_NAME, PASSWORD, STATUS, ID, NAME FROM SYS_USER WHERE LOGIN_NAME = #{loginName} AND STATUS = 0
|
||||
<select id="findUserInfoByAccount" resultType="com.rymcu.vertical.dto.UserInfoDTO">
|
||||
select id, nickname, sex, avatar_type, avatar_url, email, phone, account, password, status, last_login_time from sus_user when account = #{account}
|
||||
</select>
|
||||
|
||||
<select id="queryUserByInputCode" resultType="com.rymcu.vertical.dto.UserDTO">
|
||||
select
|
||||
u.ID,
|
||||
u.NO,
|
||||
u.LOGIN_NAME loginName,
|
||||
u.SEX,
|
||||
u.NAME,
|
||||
u.EMAIL,
|
||||
u.MOBILE,
|
||||
u.PHONE,
|
||||
u.OFFICE_ID officeId,
|
||||
u.LAST_LOGIN_TIME lastLoginTime,
|
||||
u.STATUS,
|
||||
u.REMARKS,
|
||||
u.INPUT_CODE inputCode
|
||||
from SYS_USER u
|
||||
where id in (select user_id from sys_user_role where role_id in (select id from sys_role where enname = #{eName}) )
|
||||
</select>
|
||||
|
||||
<select id="findUserExportData" resultMap="ExportResultMap">
|
||||
SELECT TO_CHAR((SELECT NVL(NAME||'/','') FROM SYS_OFFICE WHERE ID = SO.PARENT_ID)||SO.NAME) AS OFFICE_NAME,SU.NAME,SEX,LOGIN_NAME,
|
||||
(SELECT wm_concat(NAME) FROM BAS_STORE WHERE ID_STORE IN (SELECT * FROM table(fn_split(SU .STORE,',')))) AS STORE_PERM ,
|
||||
(SELECT wm_concat(BD.DEPART_NAME) FROM SYS_USER_DEPART_PERM SUDP LEFT JOIN BAS_DEPART BD ON SUDP.ID_DEPART = BD.ID_DEPART WHERE SUDP.USER_ID = SU.ID) AS DEPART_PERM
|
||||
FROM SYS_USER SU LEFT JOIN SYS_OFFICE SO ON SU.OFFICE_ID = SO.ID
|
||||
where SU.STATUS != 2
|
||||
<if test="user.officeId != null and user.officeId != ''">
|
||||
and ( SU.OFFICE_ID in (select id from SYS_OFFICE where status = 0 start with id = #{user.officeId} connect by prior id = parent_id))
|
||||
</if>
|
||||
<if test="user.name != null and user.name != ''">
|
||||
and SU.NAME like '%'||#{user.name}||'%'
|
||||
</if>
|
||||
<if test="user.loginName != null and user.loginName != ''">
|
||||
and SU.LOGIN_NAME like '%'||#{user.loginName}||'%'
|
||||
</if>
|
||||
<if test="user.inputCode != null and user.inputCode != ''">
|
||||
and SU.INPUT_CODE like '%'||#{user.inputCode}||'%'
|
||||
</if>
|
||||
<if test="user.status != null and user.status != ''">
|
||||
and SU.STATUS like '%'||#{user.status}||'%'
|
||||
</if>
|
||||
ORDER BY OFFICE_NAME
|
||||
</select>
|
||||
<select id="findRoleOfUser" resultMap="RoleDTOResultMap">
|
||||
SELECT * FROM SYS_ROLE WHERE ID IN (SELECT ROLE_ID FROM SYS_USER_ROLE WHERE USER_ID = #{userId})
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user