use of com.ngtesting.platform.util.AuthPassport in project ngtesting-platform by aaronchen2k.
the class DocumentAction method save.
@AuthPassport(validate = true)
@RequestMapping(value = "save", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> save(HttpServletRequest request, @RequestBody DocumentVo vo) {
Map<String, Object> ret = new HashMap<String, Object>();
TestDocument doc = documentService.save(vo);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
use of com.ngtesting.platform.util.AuthPassport in project ngtesting-platform by aaronchen2k.
the class SysRoleAction method get.
@AuthPassport(validate = true)
@RequestMapping(value = "get", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> get(HttpServletRequest request, @RequestBody JSONObject req) {
Map<String, Object> ret = new HashMap<String, Object>();
String accountId = req.getString("id");
UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
SysRole po = (SysRole) roleService.get(SysRole.class, Long.valueOf(accountId));
RoleVo vo = roleService.genVo(po);
ret.put("data", vo);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
use of com.ngtesting.platform.util.AuthPassport in project ngtesting-platform by aaronchen2k.
the class UploadAction method uploadSingle.
@AuthPassport(validate = true)
@RequestMapping(value = "uploadSingle", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> uploadSingle(@RequestParam("file") MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
Long orgId = userVo.getDefaultOrgId();
String origName = file.getOriginalFilename();
String extName = FilenameUtils.getExtension(origName);
String fileName = UUID.randomUUID().toString() + "." + extName;
String uploadPath = FileUtils.SaveFile(file, "image/", fileName);
ret.put("origName", origName);
ret.put("uploadPath", uploadPath);
float flt = Float.parseFloat(String.valueOf(file.getSize()));
String fileSize = new DecimalFormat("##0.00").format(flt / 1000 / 1000);
ret.put("fileSize", fileSize + 'M');
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
use of com.ngtesting.platform.util.AuthPassport in project ngtesting-platform by aaronchen2k.
the class UserAction method save.
@AuthPassport(validate = true)
@RequestMapping(value = "save", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> save(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
Long orgId = userVo.getDefaultOrgId();
UserVo user = JSON.parseObject(JSON.toJSONString(json.get("user")), UserVo.class);
TestUser po = userService.save(user, orgId);
if (po == null) {
ret.put("code", RespCode.BIZ_FAIL.getCode());
ret.put("msg", "邮箱已存在");
return ret;
}
List<RelationOrgGroupUserVo> relations = (List<RelationOrgGroupUserVo>) json.get("relations");
orgGroupUserService.saveRelations(relations);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
use of com.ngtesting.platform.util.AuthPassport in project ngtesting-platform by aaronchen2k.
the class UserAction method search.
@AuthPassport(validate = true)
@RequestMapping(value = "search", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> search(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
Long orgId = json.getLong("orgId");
String keywords = json.getString("keywords");
JSONArray exceptIds = json.getJSONArray("exceptIds");
List userPos = userService.search(orgId, keywords, exceptIds);
List<UserVo> userVos = userService.genVos(userPos);
ret.put("data", userVos);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
Aggregations