@SecurityMapping(
     title = "楼层分类Ajax更新",
     value = "/admin/goods_floor_ajax.htm*",
     rtype = "admin",
     rname = "首页楼层",
     rcode = "goods_floor",
     rgroup = "商品")
 @RequestMapping("/admin/goods_floor_ajax.htm")
 public void goods_floor_ajax(
     HttpServletRequest request,
     HttpServletResponse response,
     String id,
     String fieldName,
     String value)
     throws ClassNotFoundException {
   GoodsFloor obj = this.goodsfloorService.getObjById(Long.parseLong(id));
   Field[] fields = GoodsFloor.class.getDeclaredFields();
   BeanWrapper wrapper = new BeanWrapper(obj);
   Object val = null;
   for (Field field : fields) {
     // System.out.println(field.getName());
     if (field.getName().equals(fieldName)) {
       Class clz = Class.forName("java.lang.String");
       if (field.getType().getName().equals("int")) {
         clz = Class.forName("java.lang.Integer");
       }
       if (field.getType().getName().equals("boolean")) {
         clz = Class.forName("java.lang.Boolean");
       }
       if (!value.equals("")) {
         val = BeanUtils.convertType(value, clz);
       } else {
         val = !CommUtil.null2Boolean(wrapper.getPropertyValue(fieldName));
       }
       wrapper.setPropertyValue(fieldName, val);
     }
   }
   this.goodsfloorService.update(obj);
   response.setContentType("text/plain");
   response.setHeader("Cache-Control", "no-cache");
   response.setCharacterEncoding("UTF-8");
   PrintWriter writer;
   try {
     writer = response.getWriter();
     writer.print(val.toString());
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Esempio n. 2
0
 /**
  * 其他应用登陆设置登陆状态 请修改此方法或都在子类复盖此方法来实现你的逻辑
  *
  * @param request
  * @param response
  * @param get
  */
 protected void iskyshop_login(
     HttpServletRequest request, HttpServletResponse response, Map<String, String> args) {
   boolean admin_login =
       CommUtil.null2Boolean(
           request.getSession(false).getAttribute("admin_login")); // 判断是否管理员登录,管理员登录不需要进行重复登录处理
   if (!admin_login) {
     String userName = args.get("username");
     String password = "";
     User user = this.userService.getObjByProperty("userName", userName);
     if (user != null) {
       password = user.getPassword();
     } else {
       user = new User();
       user.setUserName(userName);
       user.setUserRole("BUYER");
       user.setAddTime(new Date());
       // user.setEmail(email);
       user.setPassword(Md5Encrypt.md5(password).toLowerCase());
       Map params = new HashMap();
       params.put("type", "BUYER");
       List<Role> roles =
           this.roleService.query("select obj from Role obj where obj.type=:type", params, -1, -1);
       user.getRoles().addAll(roles);
       if (this.configService.getSysConfig().isIntegral()) {
         user.setIntegral(this.configService.getSysConfig().getMemberRegister());
         this.userService.save(user);
         IntegralLog log = new IntegralLog();
         log.setAddTime(new Date());
         log.setContent("用户注册增加" + this.configService.getSysConfig().getMemberRegister() + "分");
         log.setIntegral(this.configService.getSysConfig().getMemberRegister());
         log.setIntegral_user(user);
         log.setType("reg");
         this.integralLogService.save(log);
       } else {
         this.userService.save(user);
       }
       // 创建用户默认相册
       Album album = new Album();
       album.setAddTime(new Date());
       album.setAlbum_default(true);
       album.setAlbum_name("默认相册");
       album.setAlbum_sequence(-10000);
       album.setUser(user);
       this.albumService.save(album);
     }
     String url =
         CommUtil.getURL(request)
             + "/iskyshop_login.htm?username="******"&password="******"&encode=true";
     try {
       response.sendRedirect(url);
     } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
 }