Skip to content

Commit c64366f

Browse files
author
liaomengge
committed
修正修改配置文件数据库lock异常&数据库sql统一更正
1 parent 702cfe6 commit c64366f

File tree

6 files changed

+46
-30
lines changed

6 files changed

+46
-30
lines changed

disconf-web/html/assets/js/modify_password.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $("#item_submit").on("click", function (e) {
3737
alert(data.result);
3838
window.location.href = "/login.html";
3939
} else {
40-
$("#error").html(data.result);
40+
Util.input.whiteError($("#error"), data);
4141
}
4242
});
4343
});

disconf-web/sql/0-init_table.sql

+12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CREATE TABLE `app` (
1414
CREATE TABLE `config` (
1515
`config_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '唯一的ID(没有啥意义,主键,自增长而已)',
1616
`type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '配置文件/配置项',
17+
`status` int(11) NOT NULL DEFAULT '1' COMMENT '状态:1是正常 0是删除',
1718
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '配置文件名/配置项KeY名',
1819
`value` text NOT NULL COMMENT '0 配置文件:文件的内容,1 配置项:配置值',
1920
`app_id` bigint(20) NOT NULL COMMENT 'appid',
@@ -24,6 +25,17 @@ CREATE TABLE `config` (
2425
PRIMARY KEY (`config_id`)
2526
) ENGINE=InnoDB AUTO_INCREMENT=150 DEFAULT CHARSET=utf8 COMMENT='配置';
2627

28+
CREATE TABLE `config_history` (
29+
`id` bigint(20) NOT NULL AUTO_INCREMENT,
30+
`config_id` bigint(20) NOT NULL,
31+
`old_value` longtext NOT NULL,
32+
`new_value` longtext NOT NULL,
33+
`create_time` varchar(14) NOT NULL DEFAULT '99991231235959',
34+
`update_by` bigint(20) NOT NULL DEFAULT '0',
35+
PRIMARY KEY (`id`)
36+
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8;
37+
38+
2739
CREATE TABLE `env` (
2840
`env_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '环境ID(主键,自增长)',
2941
`name` varchar(255) NOT NULL DEFAULT 'DEFAULT_ENV' COMMENT '环境名字',

disconf-web/sql/1-init_data.sql

+6-13
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,12 @@ VALUES
109109
(71, 2, '/api/web/config/filetext/{configId}', 'update', '0100', '99991231235959'),
110110
(72, 3, '/api/web/config/filetext/{configId}', 'update', '0000', '99991231235959');
111111

112-
/* testUser1 MhxzKhl9209*/
113-
/* testUser2 MhxzKhl167*/
114-
/* testUser3 MhxzKhl783*/
115-
/* testUser4 MhxzKhl8758*/
116-
/* testUser5 MhxzKhl112*/
112+
INSERT INTO `role_resource` (`role_id`, `url_pattern`, `url_description`, `method_mask`) VALUES
113+
(1,'/api/account/password' , '修改密码' , '0100'),
114+
(2,'/api/account/password' , '修改密码' , '0100'),
115+
(3,'/api/account/password' , '修改密码' , '0000');
116+
117117
/* admin admin*/
118118
INSERT INTO `user` (`user_id`, `name`, `password`, `token`, `ownapps`, `role_id`)
119119
VALUES
120-
(1, 'testUser1', '5eec8499597a115c88e0a9580ae1562ab85d0b1a', 'b9070d385a13357efa09e50e080607c2b299241b', '2', 1),
121-
(2, 'testUser2', '71e9dc667eefa5a3a4840cb4f1ce22bc246f22f0', 'b169dec42f61ec6cbad88d70e7c4c6b89630ccfb', '2', 1),
122-
(3, 'testUser3', 'e2cdc4a9195030543e38e19a923f075d54471cc4', 'a1a20b0e03a5191c530cbfc064eda3c16254df64', '2', 1),
123-
(4, 'testUser4', '5cef2d7e4ada5a615f03e12b569d80aedfb056fc', '007b07fccbc1c82c987f7b8e4651e85cca01cf2b', '2', 1),
124-
(5, 'testUser5', 'f996eeaa224abe0037d99adbce73c315e13238f9', 'c9dfdcb50a3d84f2b6a4771dcb7c2ceb19e7d281', '2', 1),
125-
(6, 'admin', 'd033e22ae348aeb5660fc2140aec35850c4da997', 'f28d164d23291c732f64134e6b7d92be3ff8b1b3', '', 2),
126-
(7, 'admin_read', 'b76f3e20d1c8d0bc17d40158e44097d5eeee8640', '2022ab9c2754d62f9ddba5fded91e4238247ebaf', '2', 3),
127-
(8, 'mobiledsp', '0855b44a368e44dc6e6825532073b29a368584af', '132069654193f802203d1c6c86e753ecede698f6', '4', 1);
120+
(1, 'admin', 'd033e22ae348aeb5660fc2140aec35850c4da997', 'f28d164d23291c732f64134e6b7d92be3ff8b1b3', '', 2)

disconf-web/src/main/java/com/baidu/disconf/web/service/user/service/impl/UserMgrImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public String addOneAppForUser(Long userId, int appId) {
9292
User user = getUser(userId);
9393

9494
String ownAppIds = user.getOwnApps();
95-
if ("admin".equals(user.getName())) {
95+
if ("admin".equals(user.getName()) && StringUtils.isNotBlank(ownAppIds)) {
9696
ownAppIds = StringUtils.EMPTY;
9797
user.setOwnApps(ownAppIds);
9898
userDao.update(user);

disconf-web/src/main/java/com/baidu/disconf/web/web/auth/UserController.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ public JsonObjectBase password(@Valid PasswordModifyForm passwordModifyForm, Htt
148148
Visitor visitor = ThreadContext.getSessionVisitor();
149149
userMgr.modifyPassword(visitor.getLoginUserId(), passwordModifyForm.getNew_password());
150150

151-
// re login
151+
// relogin
152152
redisLogin.logout(request);
153153

154-
return buildSuccess("修改成功,请重新登录");
154+
return buildSuccess("修改密码成功,请重新登录");
155155
}
156156

157157

@@ -184,7 +184,7 @@ public JsonObjectBase register(@Valid RegisterForm registerForm, HttpServletRequ
184184

185185
userMgr.create(user);
186186

187-
return buildSuccess("修改成功,请重新登录");
187+
return buildSuccess("注册成功,请重新登录");
188188
}
189189

190190
}

disconf-web/src/main/java/com/baidu/dsp/common/utils/email/LogMailBean.java

+23-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
package com.baidu.dsp.common.utils.email;
22

3-
import java.net.InetAddress;
4-
import java.net.UnknownHostException;
5-
import java.text.SimpleDateFormat;
6-
import java.util.Date;
7-
3+
import com.baidu.disconf.web.config.ApplicationPropertyConfig;
4+
import com.baidu.disconf.web.service.user.dto.Visitor;
5+
import com.baidu.ub.common.commons.ThreadContext;
86
import org.apache.commons.lang3.StringUtils;
97
import org.slf4j.Logger;
108
import org.slf4j.LoggerFactory;
119
import org.springframework.beans.factory.annotation.Autowired;
1210
import org.springframework.stereotype.Service;
1311

14-
import com.baidu.disconf.web.config.ApplicationPropertyConfig;
15-
import com.baidu.disconf.web.service.user.dto.Visitor;
16-
import com.baidu.ub.common.commons.ThreadContext;
12+
import java.net.InetAddress;
13+
import java.net.UnknownHostException;
14+
import java.text.SimpleDateFormat;
15+
import java.util.Date;
16+
import java.util.concurrent.Callable;
17+
import java.util.concurrent.ExecutorService;
18+
import java.util.concurrent.Executors;
1719

1820
/**
1921
* @author liaoqiqi
@@ -24,6 +26,8 @@ public class LogMailBean {
2426

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

29+
private final ExecutorService service = Executors.newFixedThreadPool(10);
30+
2731
/**
2832
* 发送报警邮件中标题的最大长度,255
2933
*/
@@ -108,7 +112,7 @@ public void sendLogExceptionEmail(String message, Throwable e) {
108112
*
109113
* @return
110114
*/
111-
public boolean sendHtmlEmail(String toEmail, String title, String content) {
115+
public boolean sendHtmlEmail(String toEmail, String title, final String content) {
112116

113117
LOG.info("send to " + toEmail);
114118
LOG.info("title: " + title);
@@ -148,8 +152,8 @@ public boolean sendHtmlEmail(String toEmail, String title, String content) {
148152
}
149153

150154
String mailTo = toEmail;
151-
String mailFrom = emailProperties.getFromEmail();
152-
String[] mailToList = mailTo.split(";");
155+
final String mailFrom = emailProperties.getFromEmail();
156+
final String[] mailToList = mailTo.split(";");
153157

154158
if (content == null) {
155159

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

160164
try {
161-
mailBean.sendHtmlMail(mailFrom, mailToList, mailTitle, content);
165+
final String finalMailTitle = mailTitle;
166+
service.submit(new Callable<Object>() {
167+
@Override
168+
public Object call() throws Exception {
169+
mailBean.sendHtmlMail(mailFrom, mailToList, finalMailTitle, content);
170+
return null;
171+
}
172+
});
162173
} catch (Exception e) {
163174
LOG.error("When send alarm mail,we can't send it", e);
164175
return false;

0 commit comments

Comments
 (0)