📄 systemfileaction.java
字号:
package com.easyjf.news.action;
import java.io.File;
import com.easyjf.dbo.EasyJDB;
import com.easyjf.news.business.ActiveUser;
import com.easyjf.news.business.SystemUtil;
import com.easyjf.news.business.Template;
import com.easyjf.util.CommUtil;
import com.easyjf.web.Globals;
import com.easyjf.web.Module;
import com.easyjf.web.Page;
import com.easyjf.web.WebForm;
import com.easyjf.web.tools.IPageList;
import com.easyjf.web.tools.ListQuery;
import com.easyjf.web.tools.PageList;
public class SystemFileAction extends BaseAction {
public Object doBefore(WebForm form, Module module) {
ActiveUser u=(ActiveUser)this.getCurrentUser(form);
if(u==null)return new Page("popedomError","/nologin.htm","page");
String cid=CommUtil.null2String(form.get("cid"));
String dir=CommUtil.null2String(form.get("dir"));
File f=new File(Globals.APP_BASE_DIR+dir+"\\"+cid);
String path=f.getAbsolutePath().substring(Globals.APP_BASE_DIR.length()-1);
if("new".equals(this.getCommand()))form.addResult("path",path);
return null;
}
public IPageList doQuery(WebForm form, int currentPage, int pageSize) {
String dir=CommUtil.null2String(form.get("dir"));
dir=dir.replaceAll("\\.\\.","");
IPageList pList=new PageList(new ListQuery(SystemUtil.getSystemFile(dir)));
pList.doList(pageSize,currentPage,"","");
return pList;
}
public Object form2Obj(WebForm form) {
String cid=CommUtil.null2String(form.get("cid"));
Template obj=null;
if(cid.equals(""))
{
obj=(Template)form.toPo(Template.class);
obj.setStatus(new Integer(0));
}
else
{
obj=Template.read(cid);
if(obj==null)
{
String dir=CommUtil.null2String(form.get("dir"));
File f=new File(Globals.APP_BASE_DIR+dir+"\\"+cid);
String path=f.getAbsolutePath().substring(Globals.APP_BASE_DIR.length()-1);
obj=Template.readByPath(path);
if(obj==null)
{
if(f.exists())
{
obj=new Template();
obj.setPath(path);
obj.setTitle("");
if(f.isDirectory())obj.setTypes(new Integer(1));
else
{
obj.setTypes(new Integer(0));
obj.setContent(obj.readFromFile());
}
}
}
}
}
if(obj!=null){
if("del".equals(this.getCommand()))obj.delFile();
else if("update".equals(this.getCommand())|| "add".equals(this.getCommand()))
{
obj.setTitle((String)form.get("title"));
obj.setContent((String)form.get("content"));
obj.setPath((String)form.get("path"));
obj.setUrl((String)form.get("url"));
obj.saveToFile();
}
}
form.addPo(obj);
return obj;
}
public Page doMulitDel(WebForm form, Module module) throws Exception {
String MulitCid=CommUtil.null2String(form.get("mulitCid"));
boolean opSuccess=false;
if(!MulitCid.equals("")){//执行批量删除
String[] s=MulitCid.split(",");
String scope="cid in('";
for(int i=0;i<s.length;i++)
{
scope+=s[i]+"'"+(i==s.length-1?"":",'");
}
scope+=")";
EasyJDB db=EasyJDB.getInstance();
if(db.execute("delete from DynamicStaticPair where "+scope)>0)opSuccess=true;
if(!opSuccess)
form.addResult("msg","删除数据失败!");
else
form.addResult("msg","删除数据成功!");
}
return super.doQuery(form,module,this.getCurrentUser(form));
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -