2024年2月21日发(作者:)

2.3、后台服务2.3.1、封装数据ckage ;public class R { /**响应编码*/ private int code; /**响应消息*/ private String msg; /**数据总量*/ private int count; /**数据*/ private Object data; public R() { } public R(int code, String msg, int count, Object data) { super(); = code; = msg; = count; = data; } @Override public String toString() { return "R [code=" + code + ", msg=" + msg + ", count=" + count + ", data=" + data + "]"; } public int getCode() { return code; } public void setCode(int code) { = code; } public String getMsg() { return msg; } public void setMsg(String msg) { = msg; } public int getCount() { return count; } public void setCount(int count) { = count; } public Object getData() { return data; }

后台管理3.4、创建实体类ckage ;import imal;import ;/** * 产品 Bean * */public class Product { private int id; private String name; private BigDecimal price; private Date addDate;

public static String DRIVER = "verDriver"; public static String URL = "jdbc:sqlserver://localhost:1433;databasename=GoMallPro"; public static String USER_NAME = "sa"; public static String PASSWORD = "sa"; static { try { e(DRIVER); } catch (ClassNotFoundException e) { tackTrace(); } } private JDBCUtils() { } /** * Get connection *

* @return */ public static Connection getconnnection() { Connection con = null; try { con = nection(URL, USER_NAME, PASSWORD); } catch (SQLException e) { tackTrace(); } return con; } /** * Close connection *

* @param rs * @param st * @param con */ public static void close(ResultSet rs, Statement st, Connection con) { try { try { if (rs != null) { (); } } finally { try { if (st != null) { (); } } finally { if (con != null) (); } } } catch (SQLException e) { tackTrace(); } } /** * Close connection *

* @param rs */ public static void close(ResultSet rs) { Statement st = null; Connection con = null; try { try { if (rs != null) { st = tement(); (); } } finally { try { if (st != null) { con = nection(); (); } } finally { if (con != null) { (); } } }

} catch (SQLException e) { tackTrace(); } } /** * Close connection *

* @param st * @param con */ public static void close(Statement st, Connection con) { try { try { if (st != null) { (); } } finally { if (con != null) (); } } catch (SQLException e) { tackTrace(); } } /** * insert/update/delete *

* @param sql * @param args * @return */ public static int update(String sql, args) { int result = 0; Connection con = getconnnection(); PreparedStatement ps = null; try { ps = eStatement(sql); if (args != null) { for (int i = 0; i < ; i++) { ect((i + 1), args[i]); } } result = eUpdate(); } catch (SQLException e) { tackTrace(); } finally { close(ps, con); } return result; } /** * query, because need to manually close the resource, so not recommended * for use it *

* @param sql * @param args * @return ResultSet */ @Deprecated public static ResultSet query(String sql, args) { ResultSet result = null; Connection con = getconnnection(); PreparedStatement ps = null; try { ps = eStatement(sql); if (args != null) { for (int i = 0; i < ; i++) { ect((i + 1), args[i]); } } result = eQuery(); } catch (SQLException e) { tackTrace(); } return result; } /** * Query a single record *

* @param sql * @param args * @return Map

*/ public static Map queryForMap(String sql, args) { Map result = new HashMap(); List> list = queryForList(sql, args); if (() > 0) { result = (0); } return result; } /** * Query a single record *

* @param sql * @param args * @return */ public static T queryForObject(String sql, Class clz, args) { T result = null; List list = queryForList(sql, clz, args); if (() > 0) { result = (0); } return result; } /** * Query a single record *

* @param sql * @param args * @return List> */ public static List> queryForList(String sql, args) { List> result = new ArrayList>(); Connection con = null; ResultSet rs = null; PreparedStatement ps = null; try { con = getconnnection(); ps = eStatement(sql); if (args != null) { for (int i = 0; i < ; i++) { ect((i + 1), args[i]); } } rs = eQuery(); ResultSetMetaData rsmd = aData(); int columnCount = umnCount(); while (()) { Map map = new HashMap(); for (int i = 1; i <= columnCount; i++) { (umnLabel(i), ect(i)); } (map); } } catch (SQLException e) { tackTrace(); } finally { close(rs, ps, con); } return result; } /** * Query a single record *

* @param sql * @param args * @return List */ public static List queryForList(String sql, Class clz, args) { List result = new ArrayList(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = getconnnection(); ps = eStatement(sql); if (args != null) { for (int i = 0; i < ; i++) { ect((i + 1), args[i]); } } rs = eQuery(); ResultSetMetaData rsmd = aData(); int columnCount = umnCount();

3.8.3、其它属性设置s = { designMode : true, fullscreenMode : false, filterMode : true, wellFormatMode : true, shadowMode : true, loadStyleMode : true, basePath : th, themesPath : th + 'themes/', langPath : th + 'lang/', pluginsPath : th + 'plugins/', themeType : 'default', langType : 'zh-CN', urlType : '', newlineTag : 'p', resizeType : 2, syncType : 'form', pasteType : 2, dialogAlignType : 'page', useContextmenu : true, fullscreenShortcut : false, bodyClass : 'ke-content', indentChar : 't', cssPath : '', cssData : '', minWidth : 650, minHeight : 100, minChangeSize : 50, zIndex : 811213, items : [ 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage', 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about' ], noDisableItems : ['source', 'fullscreen'], colorTable : [ ['#E53333', '#E56600', '#FF9900', '#64451D', '#DFC5A4', '#FFE500'], ['#009900', '#006600', '#99BB00', '#B8D100', '#60D978', '#00D5FF'], ['#337FE5', '#003399', '#4C33E5', '#9933E5', '#CC33E5', '#EE33EE'], ['#FFFFFF', '#CCCCCC', '#999999', '#666666', '#333333', '#000000'] ], fontSizeTable : ['9px', '10px', '12px', '14px', '16px', '18px', '24px', '32px'], htmlTags : { font : ['id', 'class', 'color', 'size', 'face', '.background-color'], span : [ 'id', 'class', '.color', '.background-color', '.font-size', '.font-family', '.background', '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.line-height' ], div : [ 'id', 'class', 'align', '.border', '.margin', '.padding', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.font-weight', '.background', '.font-style', '.text-decoration', '.vertical-align', '.margin-left' ], table: [ 'id', 'class', 'border', 'cellspacing', 'cellpadding', 'width', 'height', 'align', 'bordercolor', '.padding', '.margin', '.border', 'bgcolor', '.text-align', '.color', '.background-color',