package com.tjpcms.common;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import net.sf.json.JSONObject;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import com.tjpcms.common.Crud.Crud;
import com.tjpcms.common.Crud.Retrieve;
import com.tjpcms.spring.mapper.EntMapper;
public class Hanshu {
public static void flushResponse(HttpServletResponse response, Object responseContent) {
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
PrintWriter writer = null;
try {
writer = response.getWriter();
writer.write(ConvertUtils.convert(responseContent));
} catch (IOException e) {
} finally {
writer.flush();
writer.close();
}
}
public static void setGlobal(Map<String,Object> m) {
m.put("WZMC", CL.WZMC);
m.put("GGY", CL.GGY);
m.put("GGY2", CL.GGY2);
m.put("YUMING", CL.YUMING);
}
public static void ajaxupload(MultipartFile file, HttpServletRequest request, HttpServletResponse response, EntMapper entMapper) throws IllegalStateException, IOException{
Map<String, Object> m = new HashMap<String, Object>();
if (file==null){
m.put("ret","请先选择文件!");
Hanshu.flushResponse(response, JSONObject.fromObject(m));
return;
}
String oriName= file.getOriginalFilename();
String prefix=oriName.substring(oriName.lastIndexOf("."));//如 .png
if (!".jpg".equalsIgnoreCase(prefix) && !".png".equalsIgnoreCase(prefix)
&& !".gif".equalsIgnoreCase(prefix) && !".jpeg".equalsIgnoreCase(prefix)){
m.put("ret","请选择jpg、jpeg、png或gif格式!");
Hanshu.flushResponse(response, JSONObject.fromObject(m));
return;
}
String path = request.getServletContext().getRealPath("")+"\\upload\\pic\\";
File mulu = new File(path);
if (!mulu.exists()){
mulu.mkdirs();
}
Date date = new Date();
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String uid = UUID.randomUUID().toString();
String picSrc = fmt.format(date).substring(0,14)+uid.substring(3, 6)+fmt.format(date).substring(14,17)+uid.substring(9, 12)+uid.substring(19, 23)+prefix;
File bcFile = new File(path+picSrc);
file.transferTo(bcFile);
m.put("ret","0");
m.put("src",picSrc);
Hanshu.flushResponse(response, JSONObject.fromObject(m));
}
public static void delete(HttpServletRequest request, HttpServletResponse response, EntMapper entMapper){
Crud o = (Crud)request.getSession(false).getAttribute(request.getParameter("u"));
if (o==null){
Hanshu.flushResponse(response, "-1");
return;
}
String ids = request.getParameter("ids");
if (StringUtils.isEmpty(ids)){
Hanshu.flushResponse(response, "-1");
return;
}
String arr[] = ids.split(",");
if (arr == null || arr.length<=0){
Hanshu.flushResponse(response, "-1");
return;
}
//删除前钩子
if (StringUtils.isNotEmpty(o.getD().getHook_befdel())) {
Object ret = execHook(o.getD().getHook_befdel(), request, o);
if (ret==null || !"0".equals(ret.toString())){
flushResponse(response,ret.toString());
return;
}
}
String batdel = StringUtils.isNotEmpty(o.getD().getZdysql()) ? Hanshu.zdydel(o, arr) : Hanshu.batdel(o.getMp(), o.getTb(), arr);
if (!"0".equals(batdel)){
flushResponse(response,batdel);
return;
}
//删除后钩子
if (StringUtils.isNotEmpty(o.getD().getHook_aftdel())) {
Object ret = execHook(o.getD().getHook_aftdel(), request, o);//如果有更新前钩子,执行一下
if (ret==null || !"0".equals(ret.toString())){
flushResponse(response,"-1");
return;
}
}
request.getSession().setAttribute("listtipmsg", "删除成功!");
Hanshu.flushResponse(response, "0");
}
public static void unique(HttpServletRequest request, HttpServletResponse response, EntMapper entMapper){
Map<String, Object> map = new HashMap<String, Object>();
map.put("getdata", "false");
Crud o = (Crud)request.getSession(false).getAttribute(request.getParameter("u"));
String id = request.getParameter("id");
String lx = request.getParameter("lx");
String val = request.getParameter("val");
String zdm = request.getParameter("zdm");
if (o==null ||StringUtils.isEmpty(val)||StringUtils.isEmpty(zdm) || !("0".equals(lx) || "1".equals(lx)) || ("1".equals(lx) && StringUtils.isEmpty(id))){
Hanshu.flushResponse(response, JSONObject.fromObject(map));
return;
}
String ex = "";
String filter = request.getParameter("___extfilter");
if (StringUtils.isNotEmpty(filter)) {
ex += " and "+filter+" ";
}
ex += " and ("+zdm+" = '"+val+"') ";
if ("1".equals(lx)) {//编辑
ex += " and (id!='"+id+"') ";
}
map.put("getdata", String.valueOf(Hanshu.cnt(o.getMp(), o.getTb(), ex)<=0));
flushResponse(response, JSONObject.fromObject(map));
}
private static Object execHook(String hook, HttpServletRequest request, Crud o){
if (StringUtils.isNotEmpty(hook) && request!=null && o!=null){
int dtIndx = hook.lastIndexOf(".");
if (dtIndx != -1) {
String clsnm = hook.substring(0, dtIndx);
String metd = hook.substring(dtIndx+1, hook.length());
if (StringUtils.isNotEmpty(clsnm) && StringUtils.isNotEmpty(metd)) {
try{
Class<?> classT = Class.forName(clsnm);//获取对应类
Method methodT = classT.getMethod(metd, Object.class, Object.class, Object.class);
Object obj = classT.newInstance();//创建类对象
return methodT.invoke(obj, (Object)request, (Object)o, (Object)null);
}catch(Exception e){
e.printStackTrace();
return null;
}
}
}
}
return null;
}
//栏目那边通用的新增保存功能
public static void addedit(HttpServletRequest request, HttpServletResponse response, EntMapper entMapper){
Crud o = (Crud)request.getSession(false).getAttribute(request.getParameter("u"));
if (o==null){
flushResponse(response,"-1");
return;
}
String id = request.getParameter("id");
if (StringUtils.isNotEmpty(id) && StringUtils.isNotEmpty(o.getAev().getHook_befgx())) {
Object ret = execHook(o.getAev().getHook_befgx(), request, o);//如果有更新前钩子,执行一下
if (ret==null || !"0".equals(ret.toString())){
flushResponse(response,"-1");
return;
}
}
String addedit = addedit(o.getMp(),o.getTb(),request, o.getLsttbZd());
if (!"0".equals(addedit)){
flushResponse(response,addedit);
return;
}
if (StringUtils.isNotEmpty(id) && StringUtils.isNotEmpty(o.getAev().getHook_aftgx())) {
Object ret = execHook(o.getAev().getHook_aftgx(), request, o);//如果有更新后钩子,执行一下
if (ret==null || !"0".equals(ret.toString())){
flushResponse(response,"-1");
return;
}
}
flushResponse(response,"0");
}
public static ModelAndView aev(HttpServletRequest request, EntMapper entMapper){
String t = request.getParameter("t");
String id = request.getParameter("id");
Crud o = (Crud)request.getSession(false).getAttribute(request.getParameter("u"));
if ((!"0".equals(t) && !"1".equals(t) && !"2".equals(t)) || o==null || (!"0".equals(t) && StringUtils.isEmpty
没有合适的资源?快使用搜索试试~ 我知道了~
tjpcms国产java类cms.zip
共631个文件
png:176个
gif:106个
js:96个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 184 浏览量
2022-11-16
02:21:05
上传
评论
收藏 16.24MB ZIP 举报
温馨提示
tjpcms国产java类cms.zip
资源推荐
资源详情
资源评论
收起资源包目录
tjpcms国产java类cms.zip (631个子文件)
.rebel.xml.bak 501B
Hanshu.class 64KB
NedAdmController.class 35KB
IndexController.class 24KB
SecurityFilter.class 12KB
Crud.class 7KB
Retrieve.class 7KB
EncryptUtil.class 5KB
injFilter.class 4KB
EntMapper.class 4KB
Cmn.class 3KB
FileUploadInterceptor.class 3KB
Aev.class 3KB
Hook.class 3KB
AevZdType.class 2KB
JiamiDbpwd.class 1KB
CL.class 1KB
NetworkUtil.class 1KB
Delete.class 1KB
NedAdmController$6.class 1KB
NedAdmController$4.class 1KB
NedAdmController$2.class 1KB
SecurityFilter$2.class 1KB
NedAdmController$5.class 1KB
NedAdmController$1.class 1KB
NedAdmController$3.class 1KB
SecurityFilter$1.class 1KB
Update.class 500B
.classpath 476B
org.eclipse.wst.common.component 560B
org.eclipse.wst.jsdt.ui.superType.container 49B
pintuer.css 149KB
ueditor.css 44KB
ueditor.min.css 34KB
video-js.css 21KB
image.css 19KB
video.css 15KB
attachment.css 15KB
ht_cmn.css 14KB
layer.css 14KB
video-js.min.css 11KB
index_ad.css 8KB
shCoreDefault.css 7KB
dashi.css 6KB
zTreeStyle.css 6KB
index.css 6KB
layer.ext.css 4KB
datepicker.css 4KB
scrawl.css 4KB
datepicker.css 4KB
cssfwb.css 3KB
codemirror.css 3KB
charts.css 3KB
background.css 2KB
emotion.css 2KB
dialogbase.css 2KB
music.css 2KB
smartMenu.css 1KB
laypage.css 1KB
edittable.css 1KB
template.css 1KB
webuploader.css 515B
help.css 395B
WdatePicker.css 192B
iframe.css 42B
iconfont.eot 52KB
vjs.eot 3KB
UEditorSnapscreen.exe 508KB
wface.gif 49KB
jxface2.gif 40KB
yface.gif 28KB
bface.gif 27KB
icons.gif 20KB
file-icons.gif 20KB
file-icons.gif 20KB
tface.gif 19KB
fface.gif 18KB
cface.gif 8KB
bigloading.gif 6KB
loading-0.gif 6KB
zTreeStandard.gif 5KB
icons-all.gif 4KB
20160601111725325577.gif 3KB
btn_del_hover.gif 3KB
btn_config_hover.gif 3KB
btn_del.gif 3KB
btn_save2_hover.gif 3KB
btn_config.gif 3KB
btn_save2.gif 3KB
btn_recycle_hover.gif 3KB
btn_checked_hover.gif 3KB
btn_nochecked_hover.gif 3KB
201606301646128325168fdac64.gif 3KB
2016061414450292b7026edbc45.gif 3KB
20160613174522e0a306d77b6a2.gif 3KB
2016061518205465e358ac59c52.gif 3KB
20160720155933c26491395b0d1.gif 3KB
20160614170227d76067eefbd53.gif 3KB
btn_recycle.gif 3KB
btn_count_hover.gif 3KB
共 631 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
毕业_设计
- 粉丝: 1979
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功