admin后台登录

This commit is contained in:
tanghc
2019-04-03 10:51:45 +08:00
parent 85e98f1e14
commit a778ffb497
3 changed files with 24 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ import javax.servlet.http.HttpSession;
public class SystemApi { public class SystemApi {
public static final int STATUS_FORBIDDEN = 2;
@Autowired @Autowired
AdminUserInfoMapper adminUserInfoMapper; AdminUserInfoMapper adminUserInfoMapper;
@@ -45,6 +46,9 @@ public class SystemApi {
if (user == null) { if (user == null) {
throw AdminErrors.ERROR_USERNAME_PWD.getException(); throw AdminErrors.ERROR_USERNAME_PWD.getException();
} else { } else {
if (user.getStatus() == STATUS_FORBIDDEN) {
throw AdminErrors.USER_FORBIDDEN.getException();
}
SessionManager sessionManager = ApiContext.getSessionManager(); SessionManager sessionManager = ApiContext.getSessionManager();
// 生成一个新session // 生成一个新session
HttpSession session = sessionManager.getSession(null); HttpSession session = sessionManager.getSession(null);

View File

@@ -31,5 +31,7 @@ public class AdminErrors {
public static final ErrorMeta ERROR_OPT = new ErrorMeta(isvModule, "10014", "非法操作"); public static final ErrorMeta ERROR_OPT = new ErrorMeta(isvModule, "10014", "非法操作");
public static final ErrorMeta NO_USER = new ErrorMeta(isvModule, "10015", "用户不存在"); public static final ErrorMeta NO_USER = new ErrorMeta(isvModule, "10015", "用户不存在");
public static final ErrorMeta USER_FORBIDDEN = new ErrorMeta(isvModule, "10016", "用户已禁用");
} }

19
sop.sql
View File

@@ -61,8 +61,20 @@ CREATE TABLE `perm_role_permission` (
UNIQUE KEY `uk_role_perm` (`role_code`,`route_id`) USING BTREE UNIQUE KEY `uk_role_perm` (`role_code`,`route_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COMMENT='角色权限表'; ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COMMENT='角色权限表';
DROP TABLE IF EXISTS `admin_user_info`;
CREATE TABLE `admin_user_info` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(64) NOT NULL DEFAULT '' COMMENT '用户名',
`password` varchar(128) NOT NULL DEFAULT '' COMMENT '密码',
`status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '状态1启用2禁用',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_username` (`username`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='后台用户表';
SET FOREIGN_KEY_CHECKS = @PREVIOUS_FOREIGN_KEY_CHECKS; SET FOREIGN_KEY_CHECKS = @PREVIOUS_FOREIGN_KEY_CHECKS;
@@ -112,7 +124,12 @@ INSERT INTO `perm_role_permission` (`id`, `role_code`, `route_id`, `gmt_create`,
ALTER TABLE `perm_role_permission` ENABLE KEYS; ALTER TABLE `perm_role_permission` ENABLE KEYS;
UNLOCK TABLES; UNLOCK TABLES;
LOCK TABLES `admin_user_info` WRITE;
ALTER TABLE `admin_user_info` DISABLE KEYS;
INSERT INTO `admin_user_info` (`id`, `username`, `password`, `status`, `gmt_create`, `gmt_modified`) VALUES
(1,'admin','14e1b600b1fd579f47433b88e8d85291',1,'2019-04-02 19:55:26','2019-04-02 19:55:26');
ALTER TABLE `admin_user_info` ENABLE KEYS;
UNLOCK TABLES;
SET FOREIGN_KEY_CHECKS = @PREVIOUS_FOREIGN_KEY_CHECKS; SET FOREIGN_KEY_CHECKS = @PREVIOUS_FOREIGN_KEY_CHECKS;