예제 #1
0
 // 编辑模块
 public void edit() {
     String method = getRequest().getMethod();
     Integer id = getParaToInt("id");
     if(method.equalsIgnoreCase(Constants.RequestMethod.GET)) {
     	Section oneSection=Section.me.findById(id);
         setAttr("section", oneSection);
         
         String section_admin=oneSection.getStr("section_admin");
         
         if(!StrUtil.isBlank(section_admin)){
         	
         	User oneUser= User.me.findById(section_admin);
             
             if(oneUser!=null){
             	
                 setAttr("section_admin_name",oneUser.getStr("nickname"));
             }	
         }
         
         render("edit.html");
     } else if(method.equalsIgnoreCase(Constants.RequestMethod.POST)) {
         String name = getPara("name");
         Integer show_status = getParaToInt("show_status");
         String tab = getPara("tab");
         
         String desc_text = getPara("desc_text");
         String image_logo = getPara("image_logo");
         String section_admin = getPara("section_admin");
         String section_admin_name = getPara("section_admin_name");
         
         //效验版主
         if(!StringUtils.isNullOrEmpty(section_admin_name)){
         
         	User oneUser= User.me.findByNickname(section_admin_name);
             
             if(oneUser==null){
             	setAttr("msg","绑定的版主不存在!");
             	render("add.html");
             	return;
             }else{
             	section_admin=oneUser.getStr("id");
             }
         }
         
         Section section = Section.me.findById(id);
         section.set("name", name)
         	.set("show_status", show_status)
         	.set("tab", tab)
     		.set("desc_text", desc_text)
     		.set("image_logo", image_logo)
     		.set("section_admin", section_admin)
         	.update();
         // clear cache
         clearCache(Constants.CacheName.SECTIONLIST, null);
         clearCache(Constants.CacheName.SECTIONSHOWLIST, null);
         redirect(Constants.getBaseUrl() + "/admin/section/index");
     }
 }
예제 #2
0
 // 排序
 public void sort() {
     Integer[] ids = getParaValuesToInt("ids");
     if(ids != null && ids.length > 0) {
         for(int i = 0; i < ids.length; i++) {
             Section section = Section.me.findById(ids[i]);
             section.set("display_index", i+1).update();
         }
     }
     // clear cache
     clearCache(Constants.CacheName.SECTIONLIST, null);
     redirect(Constants.getBaseUrl() + "/admin/section/index");
 }