admin后台登录

1.x
tanghc 6 years ago
parent 85e98f1e14
commit a778ffb497
  1. 4
      sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/system/SystemApi.java
  2. 2
      sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/AdminErrors.java
  3. 19
      sop.sql

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

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

@ -61,8 +61,20 @@ CREATE TABLE `perm_role_permission` (
UNIQUE KEY `uk_role_perm` (`role_code`,`route_id`) USING BTREE
) 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;
@ -112,7 +124,12 @@ INSERT INTO `perm_role_permission` (`id`, `role_code`, `route_id`, `gmt_create`,
ALTER TABLE `perm_role_permission` ENABLE KEYS;
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;

Loading…
Cancel
Save