1 package edu.must.uh.impl; 2 import java.util.List; 3 import java.util.Map; 4 import javax.servlet.http.HttpServletRequest; 5 import javax.servlet.http.HttpServletResponse; 6 import edu.must.uh.util.JedisUtil; 7 import edu.must.uh.util.MySqlUtils; 8 import edu.must.uh.util.PageBean; 9 import edu.must.uh.util.R; 10 import edu.must.uh.util.Tools; 11 import edu.must.uh.util.ToolsOfString; 12 13 public class BaseImpl { 14 15 protected String cashkey = " "; 16 protected String cashListkey = " "; 17 protected String keyFields =" "; 18 protected String tableName =" "; 19 20 21 public String getCashkey() { 22 return cashkey; 23 } 24 25 public void setCashkey(String cashkey) { 26 this.cashkey = cashkey; 27 } 28 29 public PageBean _PageBean = null; 30 31 public Integer update(Object bean,String keyValue) throws Exception { 32 JedisUtil.del(cashkey); 33 return MySqlUtils.update(tableName,bean,keyFields,keyValue); 34 } 35 36 public Integer update(String sql) throws Exception 37 { 38 JedisUtil.del(cashkey); 39 return MySqlUtils.update(sql); 40 } 41 42 43 public List<Map<String,Object>> ExistField(String controlId,String keydata,String keyValue) throws Exception { 44 String keywordSQL =""; 45 if(Tools.notEmpty(keyValue)) { 46 keywordSQL = "AND "+keyFields+" <> '" + keyValue +"' "; 47 } 48 String sqlString= "SELECT 1 from " + tableName + " where 1 = 1 AND "+controlId+" ='"+keydata+"'" + keywordSQL; 49 return MySqlUtils.getlist(sqlString); 50 } 51 52 53 public Integer delete(String keyValue) throws Exception { 54 JedisUtil.del(cashkey); 55 return MySqlUtils.delete(tableName,keyFields,keyValue); 56 } 57 58 public Integer deleteByCondition(Map<String, Object> searchcondition) throws Exception { 59 JedisUtil.del(cashkey); 60 if(searchcondition !=null && !searchcondition.isEmpty()) { 61 String sqlString = "DELETE FROM "+tableName+" Where 1 = 1 "; 62 sqlString = sqlString + Tools.getSQLCondition(searchcondition); 63 return MySqlUtils.update(sqlString); 64 } 65 return 0; 66 } 67 68 public Integer disAble(String keyValue) throws Exception { 69 JedisUtil.del(cashkey); 70 return MySqlUtils.disOrEnAble(tableName,"0",keyFields,keyValue); 71 } 72 public Integer enAble(String keyValue) throws Exception { 73 JedisUtil.del(cashkey); 74 return MySqlUtils.disOrEnAble(tableName,"1",keyFields,keyValue); 75 } 76 }