From 89ac7f9b30215669a15fb4fec39d698cb1892c6d Mon Sep 17 00:00:00 2001 From: E1ED922C1E9526DD63272D7EC5C6CB77 <E1ED922C1E9526DD63272D7EC5C6CB77@i-search.com.cn> Date: 星期日, 27 九月 2020 11:43:00 +0800 Subject: [PATCH] 初始化 --- /dev/null | 51 ------------ src/main/java/com/hx/util/SimpleEncrypt.java | 17 +--- .idea/modules.xml | 1 .idea/uiDesigner.xml | 124 +++++++++++++++++++++++++++++++ src/main/java/com/hx/common/BaseController.java | 19 ---- src/main/java/com/hx/util/JwtTool.java | 3 src/main/java/com/hx/mybatisTool/SqlSentence.java | 24 ------ 7 files changed, 133 insertions(+), 106 deletions(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index 4800ad9..2ddb899 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,7 +3,6 @@ <component name="ProjectModuleManager"> <modules> <module fileurl="file://$PROJECT_DIR$/hx-common.iml" filepath="$PROJECT_DIR$/hx-common.iml" /> - <module fileurl="file://$PROJECT_DIR$/src/main/main.iml" filepath="$PROJECT_DIR$/src/main/main.iml" /> </modules> </component> </project> \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="Palette2"> + <group name="Swing"> + <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" /> + </item> + <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" /> + </item> + <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true"> + <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" /> + <initial-values> + <property name="text" value="Button" /> + </initial-values> + </item> + <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="RadioButton" /> + </initial-values> + </item> + <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="CheckBox" /> + </initial-values> + </item> + <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="Label" /> + </initial-values> + </item> + <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> + <preferred-size width="200" height="200" /> + </default-constraints> + </item> + <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> + <preferred-size width="200" height="200" /> + </default-constraints> + </item> + <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" /> + </item> + <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1"> + <preferred-size width="-1" height="20" /> + </default-constraints> + </item> + <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" /> + </item> + <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" /> + </item> + </group> + </component> +</project> \ No newline at end of file diff --git a/src/main/java/com/hx/common/CommonInit.java b/src/main/java/com/hx/common/BaseController.java similarity index 86% rename from src/main/java/com/hx/common/CommonInit.java rename to src/main/java/com/hx/common/BaseController.java index 5caaf8f..5c5a168 100644 --- a/src/main/java/com/hx/common/CommonInit.java +++ b/src/main/java/com/hx/common/BaseController.java @@ -2,8 +2,6 @@ import com.hx.exception.ParamException; import com.hx.exception.ServiceException; -import com.hx.mybatisTool.SqlParam; -import com.hx.mybatisTool.SqlSentence; import org.springframework.beans.propertyeditors.CustomDateEditor; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; @@ -16,8 +14,6 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.HashMap; -import java.util.Map; /**鍏叡鍒濆鍖� @@ -25,13 +21,9 @@ * @Date 2020-06-11 */ -public class CommonInit { +public class BaseController { /*璇蜂笉瑕佸0鏄庡彉閲忥紝浼氬鑷翠笉瀹夊叏锛屽洜涓鸿繖涓槸鍗曞垪*/ - - protected HttpServletRequest request = null; - protected HttpSession session = null; - //鍙渶瑕佸姞涓婁笅闈㈣繖娈靛嵆鍙紝娉ㄦ剰涓嶈兘蹇樿娉ㄨВ @InitBinder @@ -44,14 +36,12 @@ public HttpServletRequest getRequest() { //鑾峰彇鍙傛暟瀵硅薄 ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - request = attributes.getRequest(); - return request; + return attributes.getRequest(); } public HttpSession getSession() { //鑾峰彇鍙傛暟瀵硅薄 - session = getRequest() .getSession(); - return session; + return getRequest() .getSession(); } /** @@ -73,8 +63,6 @@ getRequest().setAttribute(attrName, attrObject); } - - /** * 鎶涘嚭鏈嶅姟寮傚父 * @param msg 閿欒淇℃伅 @@ -92,6 +80,5 @@ { throw new ParamException(msg); } - } diff --git a/src/main/java/com/hx/mybatisTool/SqlParam.java b/src/main/java/com/hx/mybatisTool/SqlParam.java deleted file mode 100644 index 0757522..0000000 --- a/src/main/java/com/hx/mybatisTool/SqlParam.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.hx.mybatisTool; - -import java.util.Map; - -import com.hx.exception.TipsException; -import com.hx.util.SimpleTool; -/** - * mybatis 鑷畾涔夊鐞唖ql璇彞 - * @author chenjiahe - * @Data: 2020-06-08 - */ -public class SqlParam { - - private String whereSentence = "1=1"; - private String updateSentence; - private Map<String,Object> m; - - /********************mother****************************/ - /** - * 鏌ヨ鐨勮鍙� - * @param sql 濡傦細id = #{m.userId} order by age - * @param values 瀛樻斁鐨勫�煎锛歷alues.put("userId","123456") - */ - public void sqlWhere(String sql,Map<String,Object> values) { - if(!SimpleTool.checkNotNull(values)){ - throw new TipsException("values is null"); - } - if(!SimpleTool.checkNotNull(sql)) { - sql = "1=1"; - } - whereSentence = sql; - m = values; - } - - /** - * 鏇存柊璇彞鐨勮鍙� - * @param sql 濡傦細name = #{m.name},age = ? Where id = #{m.id} - * @param values 瀛樻斁鐨勫�� - */ - public void sqlUpdate(String sql,Map<String,Object> values) { - if(!SimpleTool.checkNotNull(values)){ - throw new TipsException("values is null"); - } - m = values; - updateSentence = sql; - } - - /************************************************************************/ - - public String getWhereSentence() { - return whereSentence; - } - - public void setWhereSentence(String whereSentence) { - this.whereSentence = whereSentence; - } - - public String getUpdateSentence() { - return updateSentence; - } - - public void setUpdateSentence(String updateSentence) { - this.updateSentence = updateSentence; - } - - public Map<String, Object> getM() { - return m; - } - - public void setM(Map<String, Object> m) { - this.m = m; - } - -} - diff --git a/src/main/java/com/hx/mybatisTool/SqlSentence.java b/src/main/java/com/hx/mybatisTool/SqlSentence.java index 280ef0a..a888e46 100644 --- a/src/main/java/com/hx/mybatisTool/SqlSentence.java +++ b/src/main/java/com/hx/mybatisTool/SqlSentence.java @@ -15,8 +15,6 @@ private String sqlSentence; private Map<String,Object> m; - /**绫诲瀷*/ - private Integer type = TYPE_NORMAL; /**鎺掑簭*/ private String orderBy; /**寮�濮嬮〉鏁�*/ @@ -25,10 +23,6 @@ private Integer pageNum = 0; ////////////////////////////////////////////////////////////// - /**姝e父*/ - public static final int TYPE_NORMAL = 0; - /**鍔ㄦ��*/ - public static final int TYPE_DYN = 1; /********************mother****************************/ @@ -90,16 +84,6 @@ m = values; } - /** - * 璁剧疆鍔ㄦ�佹煡璇� - * @param map 鏌ヨ - */ - public void setDynSql(Map<String, Object> map) - { - this.type = TYPE_DYN; - this.m = map; - } - /************************************************************************/ @@ -117,14 +101,6 @@ public void setSqlSentence(String sqlSentence) { this.sqlSentence = sqlSentence; - } - - public Integer getType() { - return type; - } - - public void setType(Integer type) { - this.type = type; } public String getOrderBy() { diff --git a/src/main/java/com/hx/util/BASE64.java b/src/main/java/com/hx/util/BASE64.java deleted file mode 100644 index dddd636..0000000 --- a/src/main/java/com/hx/util/BASE64.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.hx.util; -import sun.misc.BASE64Decoder; -import sun.misc.BASE64Encoder; - -/** - * BASE64鍔犲瘑瑙e瘑 - */ -public class BASE64 -{ - - /** - * BASE64瑙e瘑 - * @param key - * @return - * @throws Exception - */ - public static byte[] decryptBASE64(String key) { - byte[] t = new byte[]{}; - try{ - t = (new BASE64Decoder()).decodeBuffer(key); - }catch (Exception e) { - e.printStackTrace(); - } - return t; - } - - /** - * BASE64鍔犲瘑 - * @param key - * @return - * @throws Exception - */ - public static String encryptBASE64(byte[] key){ - String s = ""; - try{ - s = (new BASE64Encoder()).encodeBuffer(key); - }catch (Exception e) { - e.printStackTrace(); - } - return s; - } - - - public static void main(String[] args) throws Exception - { - String data = BASE64.encryptBASE64("123456789".getBytes()); - System.out.println("鍔犲瘑鍓嶏細"+data); - byte[] byteArray = BASE64.decryptBASE64(data); - System.out.println("瑙e瘑鍚庯細"+new String(byteArray)); - } -} diff --git a/src/main/java/com/hx/util/JwtTool.java b/src/main/java/com/hx/util/JwtTool.java index 873b27a..c2d050a 100644 --- a/src/main/java/com/hx/util/JwtTool.java +++ b/src/main/java/com/hx/util/JwtTool.java @@ -1,5 +1,6 @@ package com.hx.util; +import java.util.Base64; import java.util.Date; import javax.crypto.SecretKey; @@ -71,7 +72,7 @@ } public static SecretKey generalKey() { - byte[] encodedKey = BASE64.decryptBASE64(JwtConstant.JWT_SECERT); + byte[] encodedKey = Base64.getDecoder().decode(JwtConstant.JWT_SECERT); SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); return key; } diff --git a/src/main/java/com/hx/util/SimpleEncrypt.java b/src/main/java/com/hx/util/SimpleEncrypt.java index 69909b0..88f48a2 100644 --- a/src/main/java/com/hx/util/SimpleEncrypt.java +++ b/src/main/java/com/hx/util/SimpleEncrypt.java @@ -1,12 +1,6 @@ package com.hx.util; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Random; - -import sun.misc.BASE64Decoder; -import sun.misc.BASE64Encoder; +import java.util.*; /*** * 锟�?鍗曠殑鍔犲瘑绋嬪簭锛屽拰瑙e瘑绋嬪簭 @@ -54,11 +48,7 @@ public static String simpleEnCode(String dataString) { // 缁勬嫾闅忔満鍊� String ranString = generateCheckCode(13).toString() + dataString + generateCheckCode(9).toString(); - - System.out.println(ranString); - // 杩涜鍔犲瘑 sun.misc.BASE64Encoder.BASE64Encoder() - String enCode = new BASE64Encoder().encodeBuffer(ranString.getBytes()); - + String enCode = new String(Base64.getEncoder().encode(ranString.getBytes())); return enCode; } @@ -73,7 +63,8 @@ */ public static String simpleDeCode(String dataString) throws Exception { // 杩涜瑙e瘑sun.misc.BASE64Decoder.BASE64Decoder() - byte[] enCode = new BASE64Decoder().decodeBuffer(dataString); + + byte[] enCode = Base64.getDecoder().decode(dataString); // 瑙e緱闅忔満鍊� String ranString = new String(enCode); -- Gitblit v1.8.0