mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-02 20:08:40 +08:00
项目列表没有权限灰色显示,用户管理项目默认选择修改
This commit is contained in:
parent
2a2ca4b2c6
commit
3a4868b806
@ -18,9 +18,6 @@ import javax.annotation.Resource;
|
|||||||
@RequestMapping(value = "/")
|
@RequestMapping(value = "/")
|
||||||
public class IndexControl extends BaseController {
|
public class IndexControl extends BaseController {
|
||||||
|
|
||||||
@Resource
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
@RequestMapping(value = "error", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
|
@RequestMapping(value = "error", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
|
||||||
@NotLogin
|
@NotLogin
|
||||||
public String error() {
|
public String error() {
|
||||||
@ -34,7 +31,6 @@ public class IndexControl extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping(value = {"index", "", "index.html", "/"}, method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
|
@RequestMapping(value = {"index", "", "index.html", "/"}, method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
|
||||||
public String index() {
|
public String index() {
|
||||||
setAttribute("manager", userService.isManager("", getUserName()));
|
|
||||||
return "index";
|
return "index";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,13 +55,16 @@ public class ManageControl extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping(value = "getProjectInfo")
|
@RequestMapping(value = "getProjectInfo")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getProjectInfo() {
|
public String getProjectInfo(String userId) {
|
||||||
try {
|
try {
|
||||||
// 查询数据
|
// 查询数据
|
||||||
JSONObject json = manageService.getAllProjectInfo();
|
JSONObject json = manageService.getAllProjectInfo();
|
||||||
// 转换为数据
|
// 转换为数据
|
||||||
List<JSONObject> array = new ArrayList<>();
|
List<JSONObject> array = new ArrayList<>();
|
||||||
Set<String> setKey = json.keySet();
|
Set<String> setKey = json.keySet();
|
||||||
|
if (StrUtil.isEmpty(userId)) {
|
||||||
|
userId = getUserName();
|
||||||
|
}
|
||||||
for (String asetKey : setKey) {
|
for (String asetKey : setKey) {
|
||||||
ProjectInfoModel projectInfoModel = manageService.getProjectInfo(asetKey);
|
ProjectInfoModel projectInfoModel = manageService.getProjectInfo(asetKey);
|
||||||
String result = commandService.execCommand(CommandService.CommandOp.status, projectInfoModel);
|
String result = commandService.execCommand(CommandService.CommandOp.status, projectInfoModel);
|
||||||
@ -69,7 +72,7 @@ public class ManageControl extends BaseController {
|
|||||||
projectInfoModel.setStatus(status);
|
projectInfoModel.setStatus(status);
|
||||||
String id = projectInfoModel.getId();
|
String id = projectInfoModel.getId();
|
||||||
JSONObject object = (JSONObject) JSONObject.toJSON(projectInfoModel);
|
JSONObject object = (JSONObject) JSONObject.toJSON(projectInfoModel);
|
||||||
object.put("manager", userService.isManager(id, getUserName()));
|
object.put("manager", userService.isManager(id, userId));
|
||||||
array.add(object);
|
array.add(object);
|
||||||
}
|
}
|
||||||
array.sort((o1, o2) -> {
|
array.sort((o1, o2) -> {
|
||||||
|
@ -44,7 +44,11 @@ public class UserInfoController extends BaseController {
|
|||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "addUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping(value = "addUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public String addUser(String id, String name, String role, String password) {
|
public String addUser(String id, String name, String manage, String password) {
|
||||||
|
boolean manager = userService.isManager("", getUserName());
|
||||||
|
if (!manager) {
|
||||||
|
return JsonMessage.getString(400, "你还没有权限");
|
||||||
|
}
|
||||||
if (StrUtil.isEmpty(id)) {
|
if (StrUtil.isEmpty(id)) {
|
||||||
return JsonMessage.getString(400, "登录名不能为空");
|
return JsonMessage.getString(400, "登录名不能为空");
|
||||||
}
|
}
|
||||||
@ -55,7 +59,7 @@ public class UserInfoController extends BaseController {
|
|||||||
if (length < 6) {
|
if (length < 6) {
|
||||||
return JsonMessage.getString(400, "密码长度为6-12位");
|
return JsonMessage.getString(400, "密码长度为6-12位");
|
||||||
}
|
}
|
||||||
boolean b = userService.addUser(id, name, password);
|
boolean b = userService.addUser(id, name, password, "true".equals(manage));
|
||||||
if (b) {
|
if (b) {
|
||||||
return JsonMessage.getString(200, "添加成功");
|
return JsonMessage.getString(200, "添加成功");
|
||||||
}
|
}
|
||||||
|
@ -188,14 +188,16 @@ public class UserService extends BaseDataService {
|
|||||||
* @param id 用户登录名
|
* @param id 用户登录名
|
||||||
* @param name 昵称
|
* @param name 昵称
|
||||||
* @param password 密码
|
* @param password 密码
|
||||||
|
* @param manage 是否是管理员
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
public boolean addUser(String id, String name, String password) {
|
public boolean addUser(String id, String name, String password, boolean manage) {
|
||||||
try {
|
try {
|
||||||
UserModel userModel = new UserModel();
|
UserModel userModel = new UserModel();
|
||||||
userModel.setName(name);
|
userModel.setName(name);
|
||||||
userModel.setId(id);
|
userModel.setId(id);
|
||||||
userModel.setPassword(password);
|
userModel.setPassword(password);
|
||||||
|
userModel.setManage(manage);
|
||||||
return addUser(userModel);
|
return addUser(userModel);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
DefaultSystemLog.LOG().error(e.getMessage(), e);
|
DefaultSystemLog.LOG().error(e.getMessage(), e);
|
||||||
|
@ -35,8 +35,7 @@
|
|||||||
<a href="javascript:;" data-options="{'id':'manage', 'title':'项目管理', 'url':'/manage/projectInfo'}">项目管理</a>
|
<a href="javascript:;" data-options="{'id':'manage', 'title':'项目管理', 'url':'/manage/projectInfo'}">项目管理</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="layui-nav-item">
|
<li class="layui-nav-item">
|
||||||
<a href="javascript:;"
|
<a href="javascript:;" data-options="{'id':'user', 'title':'用户管理', 'url':'/user/list'}">用户管理</a>
|
||||||
#if($manager)data-options="{'id':'user', 'title':'用户管理', 'url':'/user/list'}" #end>用户管理</a>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -104,9 +103,6 @@
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
options = eval('(' + dataJSON + ')');
|
options = eval('(' + dataJSON + ')');
|
||||||
}
|
}
|
||||||
if (!options) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tabChange(options);
|
tabChange(options);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@
|
|||||||
if (!d.manager) {
|
if (!d.manager) {
|
||||||
rgb = [211, 211, 211];
|
rgb = [211, 211, 211];
|
||||||
}
|
}
|
||||||
return "<div title='" + d.group + "(" + d.id + ")' style='background: rgb(" + rgb + ");color: #fff;margin: 0 -15px;padding: 0 15px;'>" + (d.runLibDesc || "") + " / " + (d.useLibDesc || "") + "</div>";
|
return "<div name='" + d.id + "' title='" + d.group + "(" + d.id + ")' style='background: rgb(" + rgb + ");color: #fff;margin: 0 -15px;padding: 0 15px;'>" + (d.runLibDesc || "") + " / " + (d.useLibDesc || "") + "</div>";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{field: 'createTime', title: '创建时间', width: '13%'},
|
{field: 'createTime', title: '创建时间', width: '13%'},
|
||||||
@ -139,6 +139,13 @@
|
|||||||
statusCode: 200
|
statusCode: 200
|
||||||
},
|
},
|
||||||
done: function (data) {
|
done: function (data) {
|
||||||
|
var projects = data.data;
|
||||||
|
for (var i = 0; i < projects.length; i++) {
|
||||||
|
var project = projects[i];
|
||||||
|
if (!project.manager) {
|
||||||
|
$('tr[data-index="' + i + '"').css('background-color', 'rgb(211,211,211)');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -93,8 +93,8 @@
|
|||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<label class="layui-form-label">管理项目</label>
|
<label class="layui-form-label">管理项目</label>
|
||||||
{{# layui.each(d.data, function(index, item){ }}
|
{{# layui.each(d.data, function(index, item){ }}
|
||||||
<input type="checkbox" name="project" value={{ item.id }} title={{ item.name }} {{# if(item.manager){ }}
|
<input type="checkbox" name="project" value="{{= item.id }}"
|
||||||
checked {{# } }}>
|
title="{{= item.name }}" {{# if(item.manager){ }} checked {{# } }}>
|
||||||
{{# }); }}
|
{{# }); }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -131,18 +131,15 @@
|
|||||||
document.getElementById('form_user').reset();
|
document.getElementById('form_user').reset();
|
||||||
$('#form_user [name="id"]').attr('readonly', true).addClass('layui-disabled');
|
$('#form_user [name="id"]').attr('readonly', true).addClass('layui-disabled');
|
||||||
// 设置表单值
|
// 设置表单值
|
||||||
var projects = [];
|
|
||||||
for (var key in data) {
|
for (var key in data) {
|
||||||
if ("manage" === key) {
|
if ("manage" === key) {
|
||||||
if (true === data[key])
|
if (true === data[key])
|
||||||
$('#form_user [name="manage"]').attr('checked', true);
|
$('#form_user [name="manage"]').attr('checked', true);
|
||||||
} else if ("projects" === key) {
|
|
||||||
projects = data[key];
|
|
||||||
} else {
|
} else {
|
||||||
$('#form_user [name="' + key + '"]').val(data[key]);
|
$('#form_user [name="' + key + '"]').val(data[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getProject(projects);
|
getProject(data.id);
|
||||||
// 弹出
|
// 弹出
|
||||||
layer.open({
|
layer.open({
|
||||||
type: 1,
|
type: 1,
|
||||||
@ -159,12 +156,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getProject(projects) {
|
function getProject(userId) {
|
||||||
var length = projects.length;
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/manage/getProjectInfo",
|
url: "/manage/getProjectInfo",
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
data: {userId: userId},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (200 == data.code) {
|
if (200 == data.code) {
|
||||||
var manager = manageProject.innerHTML;
|
var manager = manageProject.innerHTML;
|
||||||
|
Loading…
Reference in New Issue
Block a user