use of com.ganster.cms.admin.dto.Message in project Ganster-CMS by Gangster-trio.
the class UserController method addUser.
/**
* 添加用户
* @param user
* @return Message 添加用户是否成功
*/
@PostMapping("/add")
@ResponseBody
public Message addUser(@RequestBody User user) {
Message message = new Message();
if (!this.index()) {
message.setMsg("添加权限失败");
return message;
}
user.setUserCreateTime(new Date());
UserExample userExample = new UserExample();
userExample.createCriteria().andUserNameEqualTo(user.getUserName());
List<User> userList = userService.selectByExample(userExample);
if (userList != null && !userList.isEmpty()) {
message.setMsg("用户已存在");
message.setCode(1);
} else {
userService.createUser(user);
message.setCode(0);
message.setMsg("成功添加");
}
return message;
}
use of com.ganster.cms.admin.dto.Message in project Ganster-CMS by Gangster-trio.
the class CategoryController method add.
@PostMapping("/add")
public Message add(@RequestBody Category category) {
Integer userId = (Integer) SecurityUtils.getSubject().getSession().getAttribute("id");
// 判断栏目内容是否为空
if (category == null) {
return super.buildMessage(1, "false", null);
}
// 判断登陆用户是否具有对栏目具有写的操作
// 查询栏目对应的modelId
ModuleExample moduleExample = new ModuleExample();
moduleExample.or().andModuleNameEqualTo("栏目管理");
Module module = moduleService.selectByExample(moduleExample).get(0);
if (!permissionService.hasModulePermission(userId, category.getCategorySiteId(), module.getModuleId(), CmsConst.PERMISSION_WRITE)) {
return super.buildMessage(2, "Null Permission", null);
}
// 插入栏目数据表的操作
category.setCategoryCreateTime(new Date());
category.setCategorySkin("default");
Category parentCategory = categoryService.selectByPrimaryKey(category.getCategoryParentId());
Integer level = parentCategory.getCategoryLevel();
if (level == -1) {
category.setCategoryLevel(0);
} else {
category.setCategoryLevel(level + 1);
}
int count = categoryService.insert(category);
// 插入权限表的操作
try {
User user = userService.selectByPrimaryKey(userId);
permissionService.addCategoryPermissionToUser(userId, category.getCategorySiteId(), category.getCategoryId(), CmsConst.PERMISSION_READ);
permissionService.addCategoryPermissionToUser(userId, category.getCategorySiteId(), category.getCategoryId(), CmsConst.PERMISSION_WRITE);
ArticleController.addPermission(category, user, userService, permissionService);
PermissionUtil.flush(userId);
} catch (UserNotFoundException e) {
e.printStackTrace();
return new Message(1, "false", "没有找到该用户");
}
if (count == 1) {
return new Message(0, "success", count);
} else {
return new Message(1, "false", count);
}
}
use of com.ganster.cms.admin.dto.Message in project Ganster-CMS by Gangster-trio.
the class InformationController method findInformation.
@GetMapping("/{UserId}")
public Message findInformation(@PathVariable("UserId") Integer userId) {
Message message = new Message();
InformationObject informationObject = new InformationObject();
User user = userService.selectByPrimaryKey(userId);
informationObject.setUserName(user.getUserName());
informationObject.setUserPhone(user.getUserPhone());
informationObject.setUserEmail(user.getUserEmail());
informationObject.setUserStatus(user.getUserStatus());
informationObject.setUserCreateTime(user.getUserCreateTime());
informationObject.setUserOrg(user.getUserOrg());
List<String> groupName = groupService.selectByUserId(userId).stream().map(group -> "<input type='text' disabled='disabled' value='" + group.getGroupName() + "'" + "class='layui-input'" + "/>").collect(Collectors.toList());
informationObject.setUserGroup(groupName);
message.setData(informationObject);
return message;
}
Aggregations