예제 #1
0
 public NutMap upload(TempFile tmp, int userId) throws IOException {
   NutMap re = new NutMap();
   if (userId < 1) return re.setv("msg", "请先登陆!");
   if (tmp == null || tmp.getSize() == 0) {
     return re.setv("msg", "空文件");
   }
   if (tmp.getSize() > 10 * 1024 * 1024) {
     tmp.delete();
     return re.setv("msg", "文件太大了");
   }
   String id = R.UU32();
   String path = "/" + id.substring(0, 2) + "/" + id.substring(2);
   File f = new File(imageDir + path);
   Files.createNewFile(f);
   Files.write(f, tmp.getInputStream());
   tmp.delete();
   re.put("url", Mvcs.getServletContext().getContextPath() + "/yvr/upload" + path);
   re.setv("success", true);
   return re;
 }
예제 #2
0
 @At
 public Object add(@Param("..") User user) {
   NutMap nutMap = new NutMap();
   dao.insert(user);
   return nutMap.setv("ok", true).setv("msg", "添加用户成功");
 }
예제 #3
0
 public NutMap _author(UserProfile profile) {
   NutMap author = new NutMap();
   author.setv("loginname", profile.getLoginname());
   author.setv("avatar_url", _avatar_url(profile.getLoginname()));
   return author;
 }