Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增新功能并解决存在的bug #163

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion disconf-web/html/assets/js/modify_password.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $("#item_submit").on("click", function (e) {
alert(data.result);
window.location.href = "/login.html";
} else {
$("#error").html(data.result);
Util.input.whiteError($("#error"), data);
}
});
});
12 changes: 12 additions & 0 deletions disconf-web/sql/0-init_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CREATE TABLE `app` (
CREATE TABLE `config` (
`config_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '唯一的ID(没有啥意义,主键,自增长而已)',
`type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '配置文件/配置项',
`status` int(11) NOT NULL DEFAULT '1' COMMENT '状态:1是正常 0是删除',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '配置文件名/配置项KeY名',
`value` text NOT NULL COMMENT '0 配置文件:文件的内容,1 配置项:配置值',
`app_id` bigint(20) NOT NULL COMMENT 'appid',
Expand All @@ -24,6 +25,17 @@ CREATE TABLE `config` (
PRIMARY KEY (`config_id`)
) ENGINE=InnoDB AUTO_INCREMENT=150 DEFAULT CHARSET=utf8 COMMENT='配置';

CREATE TABLE `config_history` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`config_id` bigint(20) NOT NULL,
`old_value` longtext NOT NULL,
`new_value` longtext NOT NULL,
`create_time` varchar(14) NOT NULL DEFAULT '99991231235959',
`update_by` bigint(20) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8;


CREATE TABLE `env` (
`env_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '环境ID(主键,自增长)',
`name` varchar(255) NOT NULL DEFAULT 'DEFAULT_ENV' COMMENT '环境名字',
Expand Down
19 changes: 6 additions & 13 deletions disconf-web/sql/1-init_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,12 @@ VALUES
(71, 2, '/api/web/config/filetext/{configId}', 'update', '0100', '99991231235959'),
(72, 3, '/api/web/config/filetext/{configId}', 'update', '0000', '99991231235959');

/* testUser1 MhxzKhl9209*/
/* testUser2 MhxzKhl167*/
/* testUser3 MhxzKhl783*/
/* testUser4 MhxzKhl8758*/
/* testUser5 MhxzKhl112*/
INSERT INTO `role_resource` (`role_id`, `url_pattern`, `url_description`, `method_mask`) VALUES
(1,'/api/account/password' , '修改密码' , '0100'),
(2,'/api/account/password' , '修改密码' , '0100'),
(3,'/api/account/password' , '修改密码' , '0000');

/* admin admin*/
INSERT INTO `user` (`user_id`, `name`, `password`, `token`, `ownapps`, `role_id`)
VALUES
(1, 'testUser1', '5eec8499597a115c88e0a9580ae1562ab85d0b1a', 'b9070d385a13357efa09e50e080607c2b299241b', '2', 1),
(2, 'testUser2', '71e9dc667eefa5a3a4840cb4f1ce22bc246f22f0', 'b169dec42f61ec6cbad88d70e7c4c6b89630ccfb', '2', 1),
(3, 'testUser3', 'e2cdc4a9195030543e38e19a923f075d54471cc4', 'a1a20b0e03a5191c530cbfc064eda3c16254df64', '2', 1),
(4, 'testUser4', '5cef2d7e4ada5a615f03e12b569d80aedfb056fc', '007b07fccbc1c82c987f7b8e4651e85cca01cf2b', '2', 1),
(5, 'testUser5', 'f996eeaa224abe0037d99adbce73c315e13238f9', 'c9dfdcb50a3d84f2b6a4771dcb7c2ceb19e7d281', '2', 1),
(6, 'admin', 'd033e22ae348aeb5660fc2140aec35850c4da997', 'f28d164d23291c732f64134e6b7d92be3ff8b1b3', '', 2),
(7, 'admin_read', 'b76f3e20d1c8d0bc17d40158e44097d5eeee8640', '2022ab9c2754d62f9ddba5fded91e4238247ebaf', '2', 3),
(8, 'mobiledsp', '0855b44a368e44dc6e6825532073b29a368584af', '132069654193f802203d1c6c86e753ecede698f6', '4', 1);
(1, 'admin', 'd033e22ae348aeb5660fc2140aec35850c4da997', 'f28d164d23291c732f64134e6b7d92be3ff8b1b3', '', 2)
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public String addOneAppForUser(Long userId, int appId) {
User user = getUser(userId);

String ownAppIds = user.getOwnApps();
if ("admin".equals(user.getName())) {
if ("admin".equals(user.getName()) && StringUtils.isNotBlank(ownAppIds)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要用admin字符进行判断是否是管理员

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"admin"只是一个很特殊的用户,而并不是简单的管理员,这样做,是将admin唯一的管理员权限,下发到各个部门各自有自己的管理,这样便于脱离"中心管理",当然也可以去掉这个特殊情况,但是这样,就没有一个整体的管控了、、、

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要用admin字符串来判断是否是管理员

ownAppIds = StringUtils.EMPTY;
user.setOwnApps(ownAppIds);
userDao.update(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ public JsonObjectBase password(@Valid PasswordModifyForm passwordModifyForm, Htt
Visitor visitor = ThreadContext.getSessionVisitor();
userMgr.modifyPassword(visitor.getLoginUserId(), passwordModifyForm.getNew_password());

// re login
// relogin
redisLogin.logout(request);

return buildSuccess("修改成功,请重新登录");
return buildSuccess("修改密码成功,请重新登录");
}


Expand Down Expand Up @@ -184,7 +184,7 @@ public JsonObjectBase register(@Valid RegisterForm registerForm, HttpServletRequ

userMgr.create(user);

return buildSuccess("修改成功,请重新登录");
return buildSuccess("注册成功,请重新登录");
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package com.baidu.dsp.common.utils.email;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.baidu.disconf.web.config.ApplicationPropertyConfig;
import com.baidu.disconf.web.service.user.dto.Visitor;
import com.baidu.ub.common.commons.ThreadContext;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baidu.disconf.web.config.ApplicationPropertyConfig;
import com.baidu.disconf.web.service.user.dto.Visitor;
import com.baidu.ub.common.commons.ThreadContext;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
* @author liaoqiqi
Expand All @@ -24,6 +26,8 @@ public class LogMailBean {

protected static final Logger LOG = LoggerFactory.getLogger(LogMailBean.class);

private final ExecutorService service = Executors.newFixedThreadPool(10);

/**
* 发送报警邮件中标题的最大长度,255
*/
Expand Down Expand Up @@ -108,7 +112,7 @@ public void sendLogExceptionEmail(String message, Throwable e) {
*
* @return
*/
public boolean sendHtmlEmail(String toEmail, String title, String content) {
public boolean sendHtmlEmail(String toEmail, String title, final String content) {

LOG.info("send to " + toEmail);
LOG.info("title: " + title);
Expand Down Expand Up @@ -148,8 +152,8 @@ public boolean sendHtmlEmail(String toEmail, String title, String content) {
}

String mailTo = toEmail;
String mailFrom = emailProperties.getFromEmail();
String[] mailToList = mailTo.split(";");
final String mailFrom = emailProperties.getFromEmail();
final String[] mailToList = mailTo.split(";");

if (content == null) {

Expand All @@ -158,7 +162,14 @@ public boolean sendHtmlEmail(String toEmail, String title, String content) {
} else {

try {
mailBean.sendHtmlMail(mailFrom, mailToList, mailTitle, content);
final String finalMailTitle = mailTitle;
service.submit(new Callable<Object>() {
@Override
public Object call() throws Exception {
mailBean.sendHtmlMail(mailFrom, mailToList, finalMailTitle, content);
return null;
}
});
} catch (Exception e) {
LOG.error("When send alarm mail,we can't send it", e);
return false;
Expand Down