Java编程

java接入网易云信工具类

package com.sima.toolcode;import java.security.MessageDigest;/ description : 校验码生成类*/public class CheckSumBuilder {//计算并获取checkSumpublic static String getCheckSum(String appSecret,String nonce,String curTime){return encode(“SHA”,appSecret+nonce+curTime);}private static String encode(String algorithm,String value){if(value == null){return null;}try {MessageDigest messageDigest=MessageDigest.getInstance(algorithm);messageDigest.update(value.getBytes());return getFormattedText(messageDigest.digest());} catch (Exception e) {throw new RuntimeException(e);}}private static String getFormattedText(byte[] bytes){int len=bytes.length;StringBuilder sb=new StringBuilder(len*2);for(int $i=0;$i>4)&0x0f]);sb.append(HEX_DIGITS[bytes[$i]&0x0f]);}return sb.toString();}private static final char[] HEX_DIGITS={‘0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’a’,’b’,’c’,’d’,’e’,’f’};}发送短信工具类。

java接入网易云信工具类

private static String encode(String algorithm,String value){。

private static Map beanData;// = new HashMap();。

private static String encode(String algorithm,String value){ if(value==null){ return null; }。

package com.model;public class Student {private long id;private long create_time;private long update_time;private String name;private String username;private String password;private int QQ;private String major;private String sex;private String introducemyself;public long getId() {return id;}public void setId(long id) {this.id = id;}public long getCreate_time() {return create_time;}public void setCreate_time(long create_time) {this.create_time = create_time;}public long getUpdate_time() {return update_time;}public void setUpdate_time(long update_time) {this.update_time = update_time;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public int getQQ() {return QQ;}public void setQQ(int QQ) {this.QQ = QQ;}public String getMajor() {return major;}public void setMajor(String major) {this.major = major;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public String getIntroducemyself() {return introducemyself;}public void setIntroducemyself(String introducemyself) {this.introducemyself = introducemyself;}@Overridepublic String toString() {return “Student{” +”id=” + id +”, create_time=” + create_time +”, update_time=” + update_time +”, name='” + name + ‘\” +”, username='” + username + ‘\” +”, password='” + password + ‘\” +”, QQ=” + QQ +”, major='” + major + ‘\” +”, sex='” + sex + ‘\” +”, introducemyself='” + introducemyself + ‘\” +’}’;}}然后在dao目录下新建StudentDao 接口文件。

package org.yanzi.bean;public class NewsItem{private int id;/ 标题*/private String title;/ 链接*/private String link;/ 发布日期*/private String date;/ 图片的链接*/private String imgLink;/ 内容*/private String content;/ 类型**/private int newsType;public int getNewsType(){return newsType;}public void setNewsType(int newsType){this.newsType = newsType;}public String getTitle(){return title;}public void setTitle(String title){this.title = title;}public String getLink(){return link;}public void setLink(String link){this.link = link;}public int getId(){return id;}public void setId(int id){this.id = id;}public String getDate(){return date;}public void setDate(String date){this.date = date;}public String getImgLink(){return imgLink;}public void setImgLink(String imgLink){this.imgLink = imgLink;}public String getContent(){return content;}public void setContent(String content){this.content = content;}@Overridepublic String toString(){return “NewsItem [id=” + id + “, title=” + title + “, link=” + link + “, date=” + date + “, imgLink=” + imgLink+ “, content=” + content + “, newsType=” + newsType + “]”;}}。

public class verifyServiceImpl implements InChatVerifyService {@Overridepublic boolean verifyToken(String token) {//登录校验return true;}@Overridepublic JSONArray getArrayByGroupId(String groupId) {//根据群聊id获取对应的群聊人员IDJSONArray jsonArray = JSONArray.parseArray(“[\”1111\”,\”2222\”,\”3333\”]”);return jsonArray;}}我们可以再详细的说下,获取群聊信息,是通过一个groupId来获取对应的用户Id数组,我们可以自己做一个数据查询。

这里仅仅是介绍一下有哪些最常用的 Java 单元测试工具,对于如何使用这些工具,在后续的博客中会有介绍,这里就不再多说了。有兴趣的请关注后续的文章。

每次执行 java 的工具都要进入到bin目录下,是非常麻烦的。根据windows系统在查找可执行程序的原理,可以将java工具所在路径定义到 path 环境变量中,让系统帮我们去找运行执行的程序。

Similar Posts

发表评论

邮箱地址不会被公开。 必填项已用*标注