quyueting 5 سال پیش
والد
کامیت
8f38812ab0

+ 59 - 3
minigame/src/com/hssx/controller/UserController.java

@@ -4,7 +4,9 @@ import java.io.IOException;
 import java.security.KeyManagementException;
 import java.security.NoSuchAlgorithmException;
 import java.security.NoSuchProviderException;
-import java.util.HashMap;
+import java.util.Date;
+import java.util.SortedMap;
+import java.util.TreeMap;
 
 import javax.servlet.http.HttpServletResponse;
 
@@ -24,15 +26,24 @@ import com.hssx.constant.Constant;
 import com.hssx.entity.User;
 import com.hssx.entity.UserExample;
 import com.hssx.mapper.UserMapper;
+import com.hssx.mapper.WxParamMapper;
+import com.hssx.model.WxParam;
+import com.hssx.model.WxParamExample;
 import com.hssx.utils.HttpKit;
 import com.hssx.utils.HttpRespMsg;
-import com.sun.javafx.collections.MappingChange.Map;
+import com.hssx.utils.JsapiTicketUtil;
+import com.hssx.utils.Sha1Util;
 
 @Controller
 @RequestMapping("/user")
 public class UserController {
 	@Autowired
 	UserMapper usermapper;
+	@Autowired
+	WxParamMapper wxParamMapper;
+	
+
+	public static int WX_TOKEN_EXPIRE = 7200*1000;
 
 	/**
 	 * 微信授权登录 参数: type:授权类型,0-微信,1-微博 code:平台返回的code值
@@ -168,5 +179,50 @@ public class UserController {
 		response.setCharacterEncoding("UTF-8");
 		response.getWriter().println(msg.toJSONStr());
 	}
-	
+
+	/**
+	 * 获取微信JS config参数
+	 * @param url
+	 * @param response
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getWxConfigParam")
+	public String getWxConfigParam(
+			@RequestParam String url,
+			HttpServletResponse response) throws Exception {
+		HttpRespMsg msg = new HttpRespMsg();
+		
+		WxParamExample example = new WxParamExample();
+		Date d = new Date(System.currentTimeMillis() - WX_TOKEN_EXPIRE);
+		example.createCriteria().andIndateGreaterThan(d);
+		example.setOrderByClause("id desc limit 1");
+		String jsapiTicket = "";
+		if (wxParamMapper.countByExample(example) == 0) {
+			jsapiTicket = JsapiTicketUtil.getJSApiTicket();
+			WxParam record = new WxParam();
+			record.setJsapiTicket(jsapiTicket);
+			wxParamMapper.insertSelective(record);
+		} else {
+			jsapiTicket = wxParamMapper.selectByExample(example).get(0).getJsapiTicket();
+		}
+		// 随机数
+		String nonce_str = Sha1Util.getNonceStr();
+		String timestamp = Sha1Util.getTimeStamp();
+		// 对以下字段进行签名
+		SortedMap<String, String> packageParams = new TreeMap<String, String>();
+		packageParams.put("jsapi_ticket", jsapiTicket);
+		packageParams.put("noncestr", nonce_str);
+		packageParams.put("timestamp", ""+timestamp);
+		packageParams.put("url", url);
+		String sign = Sha1Util.createSHA1Sign(packageParams);
+		packageParams.put("sign", sign);
+		packageParams.put("appid", Constant.WECHAT_APPID);
+		msg.data = packageParams;
+		
+		response.setContentType("application/json");
+		response.setCharacterEncoding("UTF-8");
+		response.getWriter().println(msg.toJSONStr());
+		return null;
+	}
 }

+ 96 - 0
minigame/src/com/hssx/mapper/WxParamMapper.java

@@ -0,0 +1,96 @@
+package com.hssx.mapper;
+
+import com.hssx.model.WxParam;
+import com.hssx.model.WxParamExample;
+import java.util.List;
+import org.apache.ibatis.annotations.Param;
+
+public interface WxParamMapper {
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    long countByExample(WxParamExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    int deleteByExample(WxParamExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    int deleteByPrimaryKey(Integer id);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    int insert(WxParam record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    int insertSelective(WxParam record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    List<WxParam> selectByExample(WxParamExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    WxParam selectByPrimaryKey(Integer id);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    int updateByExampleSelective(@Param("record") WxParam record, @Param("example") WxParamExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    int updateByExample(@Param("record") WxParam record, @Param("example") WxParamExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    int updateByPrimaryKeySelective(WxParam record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    int updateByPrimaryKey(WxParam record);
+}

+ 271 - 0
minigame/src/com/hssx/mapper/WxParamMapper.xml

@@ -0,0 +1,271 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.hssx.mapper.WxParamMapper">
+  <resultMap id="BaseResultMap" type="com.hssx.model.WxParam">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="access_token" jdbcType="VARCHAR" property="accessToken" />
+    <result column="jsapi_ticket" jdbcType="VARCHAR" property="jsapiTicket" />
+    <result column="indate" jdbcType="TIMESTAMP" property="indate" />
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    <where>
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    id, access_token, jsapi_ticket, indate
+  </sql>
+  <select id="selectByExample" parameterType="com.hssx.model.WxParamExample" resultMap="BaseResultMap">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from wx_param
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    select 
+    <include refid="Base_Column_List" />
+    from wx_param
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    delete from wx_param
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.hssx.model.WxParamExample">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    delete from wx_param
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.hssx.model.WxParam">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
+      SELECT LAST_INSERT_ID()
+    </selectKey>
+    insert into wx_param (access_token, jsapi_ticket, indate
+      )
+    values (#{accessToken,jdbcType=VARCHAR}, #{jsapiTicket,jdbcType=VARCHAR}, #{indate,jdbcType=TIMESTAMP}
+      )
+  </insert>
+  <insert id="insertSelective" parameterType="com.hssx.model.WxParam">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
+      SELECT LAST_INSERT_ID()
+    </selectKey>
+    insert into wx_param
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="accessToken != null">
+        access_token,
+      </if>
+      <if test="jsapiTicket != null">
+        jsapi_ticket,
+      </if>
+      <if test="indate != null">
+        indate,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="accessToken != null">
+        #{accessToken,jdbcType=VARCHAR},
+      </if>
+      <if test="jsapiTicket != null">
+        #{jsapiTicket,jdbcType=VARCHAR},
+      </if>
+      <if test="indate != null">
+        #{indate,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.hssx.model.WxParamExample" resultType="java.lang.Long">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    select count(*) from wx_param
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    update wx_param
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=INTEGER},
+      </if>
+      <if test="record.accessToken != null">
+        access_token = #{record.accessToken,jdbcType=VARCHAR},
+      </if>
+      <if test="record.jsapiTicket != null">
+        jsapi_ticket = #{record.jsapiTicket,jdbcType=VARCHAR},
+      </if>
+      <if test="record.indate != null">
+        indate = #{record.indate,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    update wx_param
+    set id = #{record.id,jdbcType=INTEGER},
+      access_token = #{record.accessToken,jdbcType=VARCHAR},
+      jsapi_ticket = #{record.jsapiTicket,jdbcType=VARCHAR},
+      indate = #{record.indate,jdbcType=TIMESTAMP}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.hssx.model.WxParam">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    update wx_param
+    <set>
+      <if test="accessToken != null">
+        access_token = #{accessToken,jdbcType=VARCHAR},
+      </if>
+      <if test="jsapiTicket != null">
+        jsapi_ticket = #{jsapiTicket,jdbcType=VARCHAR},
+      </if>
+      <if test="indate != null">
+        indate = #{indate,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.hssx.model.WxParam">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Sat Sep 21 19:35:25 CST 2019.
+    -->
+    update wx_param
+    set access_token = #{accessToken,jdbcType=VARCHAR},
+      jsapi_ticket = #{jsapiTicket,jdbcType=VARCHAR},
+      indate = #{indate,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+</mapper>

+ 137 - 0
minigame/src/com/hssx/model/WxParam.java

@@ -0,0 +1,137 @@
+package com.hssx.model;
+
+import java.util.Date;
+
+public class WxParam {
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column wx_param.id
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    private Integer id;
+
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column wx_param.access_token
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    private String accessToken;
+
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column wx_param.jsapi_ticket
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    private String jsapiTicket;
+
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column wx_param.indate
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    private Date indate;
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column wx_param.id
+     *
+     * @return the value of wx_param.id
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public Integer getId() {
+        return id;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column wx_param.id
+     *
+     * @param id the value for wx_param.id
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column wx_param.access_token
+     *
+     * @return the value of wx_param.access_token
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public String getAccessToken() {
+        return accessToken;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column wx_param.access_token
+     *
+     * @param accessToken the value for wx_param.access_token
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public void setAccessToken(String accessToken) {
+        this.accessToken = accessToken;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column wx_param.jsapi_ticket
+     *
+     * @return the value of wx_param.jsapi_ticket
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public String getJsapiTicket() {
+        return jsapiTicket;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column wx_param.jsapi_ticket
+     *
+     * @param jsapiTicket the value for wx_param.jsapi_ticket
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public void setJsapiTicket(String jsapiTicket) {
+        this.jsapiTicket = jsapiTicket;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column wx_param.indate
+     *
+     * @return the value of wx_param.indate
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public Date getIndate() {
+        return indate;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column wx_param.indate
+     *
+     * @param indate the value for wx_param.indate
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public void setIndate(Date indate) {
+        this.indate = indate;
+    }
+}

+ 563 - 0
minigame/src/com/hssx/model/WxParamExample.java

@@ -0,0 +1,563 @@
+package com.hssx.model;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class WxParamExample {
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    protected String orderByClause;
+
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    protected boolean distinct;
+
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    protected List<Criteria> oredCriteria;
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public WxParamExample() {
+        oredCriteria = new ArrayList<Criteria>();
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public void setOrderByClause(String orderByClause) {
+        this.orderByClause = orderByClause;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public String getOrderByClause() {
+        return orderByClause;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public void setDistinct(boolean distinct) {
+        this.distinct = distinct;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public boolean isDistinct() {
+        return distinct;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public List<Criteria> getOredCriteria() {
+        return oredCriteria;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public void or(Criteria criteria) {
+        oredCriteria.add(criteria);
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public Criteria or() {
+        Criteria criteria = createCriteriaInternal();
+        oredCriteria.add(criteria);
+        return criteria;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public Criteria createCriteria() {
+        Criteria criteria = createCriteriaInternal();
+        if (oredCriteria.size() == 0) {
+            oredCriteria.add(criteria);
+        }
+        return criteria;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    protected Criteria createCriteriaInternal() {
+        Criteria criteria = new Criteria();
+        return criteria;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public void clear() {
+        oredCriteria.clear();
+        orderByClause = null;
+        distinct = false;
+    }
+
+    /**
+     * This class was generated by MyBatis Generator.
+     * This class corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    protected abstract static class GeneratedCriteria {
+        protected List<Criterion> criteria;
+
+        protected GeneratedCriteria() {
+            super();
+            criteria = new ArrayList<Criterion>();
+        }
+
+        public boolean isValid() {
+            return criteria.size() > 0;
+        }
+
+        public List<Criterion> getAllCriteria() {
+            return criteria;
+        }
+
+        public List<Criterion> getCriteria() {
+            return criteria;
+        }
+
+        protected void addCriterion(String condition) {
+            if (condition == null) {
+                throw new RuntimeException("Value for condition cannot be null");
+            }
+            criteria.add(new Criterion(condition));
+        }
+
+        protected void addCriterion(String condition, Object value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value));
+        }
+
+        protected void addCriterion(String condition, Object value1, Object value2, String property) {
+            if (value1 == null || value2 == null) {
+                throw new RuntimeException("Between values for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value1, value2));
+        }
+
+        public Criteria andIdIsNull() {
+            addCriterion("id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIsNotNull() {
+            addCriterion("id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdEqualTo(Integer value) {
+            addCriterion("id =", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotEqualTo(Integer value) {
+            addCriterion("id <>", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThan(Integer value) {
+            addCriterion("id >", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThanOrEqualTo(Integer value) {
+            addCriterion("id >=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThan(Integer value) {
+            addCriterion("id <", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThanOrEqualTo(Integer value) {
+            addCriterion("id <=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIn(List<Integer> values) {
+            addCriterion("id in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotIn(List<Integer> values) {
+            addCriterion("id not in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdBetween(Integer value1, Integer value2) {
+            addCriterion("id between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotBetween(Integer value1, Integer value2) {
+            addCriterion("id not between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenIsNull() {
+            addCriterion("access_token is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenIsNotNull() {
+            addCriterion("access_token is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenEqualTo(String value) {
+            addCriterion("access_token =", value, "accessToken");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenNotEqualTo(String value) {
+            addCriterion("access_token <>", value, "accessToken");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenGreaterThan(String value) {
+            addCriterion("access_token >", value, "accessToken");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenGreaterThanOrEqualTo(String value) {
+            addCriterion("access_token >=", value, "accessToken");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenLessThan(String value) {
+            addCriterion("access_token <", value, "accessToken");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenLessThanOrEqualTo(String value) {
+            addCriterion("access_token <=", value, "accessToken");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenLike(String value) {
+            addCriterion("access_token like", value, "accessToken");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenNotLike(String value) {
+            addCriterion("access_token not like", value, "accessToken");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenIn(List<String> values) {
+            addCriterion("access_token in", values, "accessToken");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenNotIn(List<String> values) {
+            addCriterion("access_token not in", values, "accessToken");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenBetween(String value1, String value2) {
+            addCriterion("access_token between", value1, value2, "accessToken");
+            return (Criteria) this;
+        }
+
+        public Criteria andAccessTokenNotBetween(String value1, String value2) {
+            addCriterion("access_token not between", value1, value2, "accessToken");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketIsNull() {
+            addCriterion("jsapi_ticket is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketIsNotNull() {
+            addCriterion("jsapi_ticket is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketEqualTo(String value) {
+            addCriterion("jsapi_ticket =", value, "jsapiTicket");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketNotEqualTo(String value) {
+            addCriterion("jsapi_ticket <>", value, "jsapiTicket");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketGreaterThan(String value) {
+            addCriterion("jsapi_ticket >", value, "jsapiTicket");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketGreaterThanOrEqualTo(String value) {
+            addCriterion("jsapi_ticket >=", value, "jsapiTicket");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketLessThan(String value) {
+            addCriterion("jsapi_ticket <", value, "jsapiTicket");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketLessThanOrEqualTo(String value) {
+            addCriterion("jsapi_ticket <=", value, "jsapiTicket");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketLike(String value) {
+            addCriterion("jsapi_ticket like", value, "jsapiTicket");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketNotLike(String value) {
+            addCriterion("jsapi_ticket not like", value, "jsapiTicket");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketIn(List<String> values) {
+            addCriterion("jsapi_ticket in", values, "jsapiTicket");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketNotIn(List<String> values) {
+            addCriterion("jsapi_ticket not in", values, "jsapiTicket");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketBetween(String value1, String value2) {
+            addCriterion("jsapi_ticket between", value1, value2, "jsapiTicket");
+            return (Criteria) this;
+        }
+
+        public Criteria andJsapiTicketNotBetween(String value1, String value2) {
+            addCriterion("jsapi_ticket not between", value1, value2, "jsapiTicket");
+            return (Criteria) this;
+        }
+
+        public Criteria andIndateIsNull() {
+            addCriterion("indate is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIndateIsNotNull() {
+            addCriterion("indate is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIndateEqualTo(Date value) {
+            addCriterion("indate =", value, "indate");
+            return (Criteria) this;
+        }
+
+        public Criteria andIndateNotEqualTo(Date value) {
+            addCriterion("indate <>", value, "indate");
+            return (Criteria) this;
+        }
+
+        public Criteria andIndateGreaterThan(Date value) {
+            addCriterion("indate >", value, "indate");
+            return (Criteria) this;
+        }
+
+        public Criteria andIndateGreaterThanOrEqualTo(Date value) {
+            addCriterion("indate >=", value, "indate");
+            return (Criteria) this;
+        }
+
+        public Criteria andIndateLessThan(Date value) {
+            addCriterion("indate <", value, "indate");
+            return (Criteria) this;
+        }
+
+        public Criteria andIndateLessThanOrEqualTo(Date value) {
+            addCriterion("indate <=", value, "indate");
+            return (Criteria) this;
+        }
+
+        public Criteria andIndateIn(List<Date> values) {
+            addCriterion("indate in", values, "indate");
+            return (Criteria) this;
+        }
+
+        public Criteria andIndateNotIn(List<Date> values) {
+            addCriterion("indate not in", values, "indate");
+            return (Criteria) this;
+        }
+
+        public Criteria andIndateBetween(Date value1, Date value2) {
+            addCriterion("indate between", value1, value2, "indate");
+            return (Criteria) this;
+        }
+
+        public Criteria andIndateNotBetween(Date value1, Date value2) {
+            addCriterion("indate not between", value1, value2, "indate");
+            return (Criteria) this;
+        }
+    }
+
+    /**
+     * This class was generated by MyBatis Generator.
+     * This class corresponds to the database table wx_param
+     *
+     * @mbg.generated do_not_delete_during_merge Sat Sep 21 19:35:25 CST 2019
+     */
+    public static class Criteria extends GeneratedCriteria {
+
+        protected Criteria() {
+            super();
+        }
+    }
+
+    /**
+     * This class was generated by MyBatis Generator.
+     * This class corresponds to the database table wx_param
+     *
+     * @mbg.generated Sat Sep 21 19:35:25 CST 2019
+     */
+    public static class Criterion {
+        private String condition;
+
+        private Object value;
+
+        private Object secondValue;
+
+        private boolean noValue;
+
+        private boolean singleValue;
+
+        private boolean betweenValue;
+
+        private boolean listValue;
+
+        private String typeHandler;
+
+        public String getCondition() {
+            return condition;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object getSecondValue() {
+            return secondValue;
+        }
+
+        public boolean isNoValue() {
+            return noValue;
+        }
+
+        public boolean isSingleValue() {
+            return singleValue;
+        }
+
+        public boolean isBetweenValue() {
+            return betweenValue;
+        }
+
+        public boolean isListValue() {
+            return listValue;
+        }
+
+        public String getTypeHandler() {
+            return typeHandler;
+        }
+
+        protected Criterion(String condition) {
+            super();
+            this.condition = condition;
+            this.typeHandler = null;
+            this.noValue = true;
+        }
+
+        protected Criterion(String condition, Object value, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.typeHandler = typeHandler;
+            if (value instanceof List<?>) {
+                this.listValue = true;
+            } else {
+                this.singleValue = true;
+            }
+        }
+
+        protected Criterion(String condition, Object value) {
+            this(condition, value, null);
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.secondValue = secondValue;
+            this.typeHandler = typeHandler;
+            this.betweenValue = true;
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue) {
+            this(condition, value, secondValue, null);
+        }
+    }
+}

+ 89 - 0
minigame/src/com/hssx/utils/JsapiTicketUtil.java

@@ -0,0 +1,89 @@
+package com.hssx.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import com.alibaba.fastjson.JSONObject;
+import com.hssx.constant.Constant;
+
+
+
+public class JsapiTicketUtil {
+    
+    /***
+     * 模拟get请求
+     * @param url
+     * @param charset
+     * @param timeout
+     * @return
+     */
+     public static String sendGet(String url, String charset, int timeout)
+      {
+        String result = "";
+        try
+        {
+          URL u = new URL(url);
+          try
+          {
+            URLConnection conn = u.openConnection();
+            conn.connect();
+            conn.setConnectTimeout(timeout);
+            BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), charset));
+            String line="";
+            while ((line = in.readLine()) != null)
+            {
+             
+              result = result + line;
+            }
+            in.close();
+          } catch (IOException e) {
+            return result;
+          }
+        }
+        catch (MalformedURLException e)
+        {
+          return result;
+        }
+       
+        return result;
+      }
+     /***
+      * 获取acess_token 
+      * 来源www.vxzsk.com
+      * @return
+      */
+     public static String getAccessToken(){
+            String appid=Constant.WECHAT_APPID;//应用ID
+            String appSecret=Constant.WECHAT_APPSECRET;//(应用密钥)
+            String url ="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appid+"&secret="+appSecret+"";
+            String backData;
+			backData = sendGet(url, "utf-8", 10000);
+			System.out.println("backData=="+backData);
+			String accessToken = (String) JSONObject.parseObject(backData).get("access_token");  
+            return accessToken;
+     }
+    /***
+      * 获取jsapiTicket
+      * 来源 www.vxzsk.com
+      * @return
+      */
+    public static String getJSApiTicket(){ 
+        //获取token
+        String acess_token= JsapiTicketUtil.getAccessToken();
+           
+        String urlStr = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token="+acess_token+"&type=jsapi";  
+        String backData;
+		backData = sendGet(urlStr, "utf-8", 10000);
+		String ticket = (String) JSONObject.parseObject(backData).get("ticket");  
+        return  ticket;  
+           
+    }  
+     public static void main(String[] args) {
+        String jsapiTicket = JsapiTicketUtil.getJSApiTicket();
+        System.out.println("调用微信jsapi的凭证票为:"+jsapiTicket);
+        }
+}

+ 46 - 0
minigame/src/com/hssx/utils/MD5Util.java

@@ -0,0 +1,46 @@
+package com.hssx.utils;
+
+
+
+
+import java.security.MessageDigest;
+
+public class MD5Util {
+
+	private static String byteArrayToHexString(byte b[]) {
+		StringBuffer resultSb = new StringBuffer();
+		for (int i = 0; i < b.length; i++)
+			resultSb.append(byteToHexString(b[i]));
+
+		return resultSb.toString();
+	}
+
+	private static String byteToHexString(byte b) {
+		int n = b;
+		if (n < 0)
+			n += 256;
+		int d1 = n / 16;
+		int d2 = n % 16;
+		return hexDigits[d1] + hexDigits[d2];
+	}
+
+	public static String MD5Encode(String origin, String charsetname) {
+		String resultString = null;
+		try {
+			resultString = new String(origin);
+			MessageDigest md = MessageDigest.getInstance("MD5");
+			if (charsetname == null || "".equals(charsetname))
+				resultString = byteArrayToHexString(md.digest(resultString
+						.getBytes()));
+			else
+				resultString = byteArrayToHexString(md.digest(resultString
+						.getBytes(charsetname)));
+		} catch (Exception exception) {
+		}
+		return resultString;
+	}
+
+	private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5",
+			"6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
+
+}

+ 79 - 0
minigame/src/com/hssx/utils/Sha1Util.java

@@ -0,0 +1,79 @@
+package com.hssx.utils;
+
+
+
+import java.net.URLDecoder;
+import java.security.MessageDigest;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.SortedMap;
+
+/*
+'============================================================================
+'api说明:
+'createSHA1Sign创建签名SHA1
+'getSha1()Sha1签名
+'============================================================================
+'*/
+public class Sha1Util {
+	
+	public static void main(String[] args) {
+		String str = "jsapi_ticket=kgt8ON7yVITDhtdwci0qecaNzS34qhbQACy88uRm_S0XvT3hcWiBONbLzKnA5o5uPukt2sA3a8bBfETg4TyaQg&noncestr=10907813b97e249163587e6246612e21&timestamp=1516590573&url=http://www.dzjy.com/payHtml.html?num=1&code=001EjC0a2q6qoO0fn2Z92E6D0a2EjC0D&state=1";
+		String sign = getSha1(str);
+		System.out.println(sign);
+	}
+
+	public static String getNonceStr() {
+		Random random = new Random();
+		return MD5Util.MD5Encode(String.valueOf(random.nextInt(10000)), "UTF-8");
+	}
+	public static String getTimeStamp() {
+		return String.valueOf(System.currentTimeMillis() / 1000);
+	}
+	
+   //创建签名SHA1
+	public static String createSHA1Sign(SortedMap<String, String> signParams) throws Exception {
+		StringBuffer sb = new StringBuffer();
+		Set es = signParams.entrySet();
+		Iterator it = es.iterator();
+		while (it.hasNext()) {
+			Map.Entry entry = (Map.Entry) it.next();
+			String k = (String) entry.getKey();
+			String v = (String) entry.getValue();
+			sb.append(k + "=" + v + "&");
+			//要采用URLENCODER的原始值!
+		}
+		String params = sb.substring(0, sb.lastIndexOf("&"));
+		System.out.println("sha1之前:" + params);
+		System.out.println("SHA1签名为:"+getSha1(params));
+		return getSha1(params);
+	}
+	//Sha1签名
+	public static String getSha1(String str) {
+		if (str == null || str.length() == 0) {
+			return null;
+		}
+		char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+				'a', 'b', 'c', 'd', 'e', 'f' };
+
+		try {
+			MessageDigest mdTemp = MessageDigest.getInstance("SHA1");
+			mdTemp.update(str.getBytes("UTF-8"));
+
+			byte[] md = mdTemp.digest();
+			int j = md.length;
+			char buf[] = new char[j * 2];
+			int k = 0;
+			for (int i = 0; i < j; i++) {
+				byte byte0 = md[i];
+				buf[k++] = hexDigits[byte0 >>> 4 & 0xf];
+				buf[k++] = hexDigits[byte0 & 0xf];
+			}
+			return new String(buf);
+		} catch (Exception e) {
+			return null;
+		}
+	}
+}