Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Jc #4

Merged
merged 4 commits into from
Oct 26, 2018
Merged

Jc #4

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,22 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-miniapp</artifactId>
<version>3.1.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.wizzstudio.substitute.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
* 微信小程序有关配置
* Created By Cx On 2018/8/1 13:32
*/
@Component
@Data
@ConfigurationProperties("wechat")
public class WeChatAccountConfig {

/**
* 小程序appId
*/
private String appid;

/**
* 小程序appSecret
*/
private String secret;

/**
* 小程序令牌
*/
private String token;

/**
* 加密密钥
*/
private String aesKey;

/**
* 数据格式
*/
private String msgDataFormat;

/**
* 微信模板ID
*/
private Map<String, String> templateId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.wizzstudio.substitute.config;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.WxMaConfig;
import cn.binarywang.wx.miniapp.config.WxMaInMemoryConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class WxMaConfiguration {

@Autowired
private WeChatAccountConfig properties;

@Bean
@ConditionalOnMissingBean
public WxMaConfig maConfig() {
WxMaInMemoryConfig config = new WxMaInMemoryConfig();
config.setAppid(this.properties.getAppid());
config.setSecret(this.properties.getSecret());
config.setToken(this.properties.getToken());
config.setAesKey(this.properties.getAesKey());
config.setMsgDataFormat(this.properties.getMsgDataFormat());
return config;
}

@Bean
@ConditionalOnMissingBean
public WxMaService wxMaService(WxMaConfig maConfig) {
WxMaService service = new WxMaServiceImpl();
service.setWxMaConfig(maConfig);
return service;
}
}
13 changes: 13 additions & 0 deletions src/main/java/com/wizzstudio/substitute/constants/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.wizzstudio.substitute.constants;

public class Constants {
public static final int SYSTEM_BUSY = -1;
public static final int REQUEST_SUCCEED = 0;
public static final int INVALID_TOKEN = 40001;
public static final int INVALID_CERTIFICATE_TYPE = 40002;
public static final int INVALID_USER_ID = 40003;
public static final int INVALID_MSG_TYPE = 40008;

public static final String QUERY_SUCCESSFULLY = "请求成功";
public static final String QUERY_FAILED = "请求失败";
}
4 changes: 3 additions & 1 deletion src/main/java/com/wizzstudio/substitute/dao/UserDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
import org.springframework.stereotype.Repository;

@Repository
public interface UserDao extends JpaRepository<User, Integer> {
public interface UserDao extends JpaRepository<User, String> {
User findByOpenid(String id);

}
133 changes: 133 additions & 0 deletions src/main/java/com/wizzstudio/substitute/dto/ApprenticeBasicInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package com.wizzstudio.substitute.dto;

import com.wizzstudio.substitute.enums.Gender;

import java.io.Serializable;

public class ApprenticeBasicInfo implements Serializable {

private String id;

private String userName;

private String avatar;

private String school;

private Gender gender;

public ApprenticeBasicInfo() {
}


public ApprenticeBasicInfo(String id, String userName, String avatar, String school, Gender gender) {
this.id = id;
this.userName = userName;
this.avatar = avatar;
this.school = school;
this.gender = gender;
}

private ApprenticeBasicInfo(Builder builder) {
setId(builder.id);
setUserName(builder.userName);
setAvatar(builder.avatar);
setSchool(builder.school);
setGender(builder.gender);
}

public static Builder newBuilder() {
return new Builder();
}

public static Builder newBuilder(ApprenticeBasicInfo copy) {
Builder builder = new Builder();
builder.id = copy.getId();
builder.userName = copy.getUserName();
builder.avatar = copy.getAvatar();
builder.school = copy.getSchool();
builder.gender = copy.getGender();
return builder;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getAvatar() {
return avatar;
}

public void setAvatar(String avatar) {
this.avatar = avatar;
}

public String getSchool() {
return school;
}

public void setSchool(String school) {
this.school = school;
}

public Gender getGender() {
return gender;
}

public void setGender(Gender gender) {
this.gender = gender;
}


public static final class Builder {
private String id;
private String userName;
private String avatar;
private String school;
private Gender gender;

private Builder() {
}

public Builder setId(String id) {
this.id = id;
return this;
}

public Builder setUserName(String userName) {
this.userName = userName;
return this;
}

public Builder setAvatar(String avatar) {
this.avatar = avatar;
return this;
}

public Builder setSchool(String school) {
this.school = school;
return this;
}

public Builder setGender(Gender gender) {
this.gender = gender;
return this;
}

public ApprenticeBasicInfo build() {
return new ApprenticeBasicInfo(this);
}
}
}
63 changes: 63 additions & 0 deletions src/main/java/com/wizzstudio/substitute/dto/ModifyUserInfoDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.wizzstudio.substitute.dto;

import com.wizzstudio.substitute.enums.Gender;
import lombok.Data;

import java.io.Serializable;


public class ModifyUserInfoDTO implements Serializable {

private static final long serialVersionUID = -6191983979387003051L;
private String userName;
private String trueName;
private Long phoneNumber;
private String school;
private Gender gender;


public ModifyUserInfoDTO() {
}



public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getTrueName() {
return trueName;
}

public void setTrueName(String trueName) {
this.trueName = trueName;
}

public Long getPhoneNumber() {
return phoneNumber;
}

public void setPhoneNumber(Long phoneNumber) {
this.phoneNumber = phoneNumber;
}

public String getSchool() {
return school;
}

public void setSchool(String school) {
this.school = school;
}

public Gender getGender() {
return gender;
}

public void setGender(Gender gender) {
this.gender = gender;
}
}
30 changes: 30 additions & 0 deletions src/main/java/com/wizzstudio/substitute/dto/ResultDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.wizzstudio.substitute.dto;

import lombok.Data;

import java.io.Serializable;


@Data
public class ResultDTO<T> implements Serializable {

private static final long serialVersionUID = -276259361015856308L;

//状态码
private Integer code;

//信息
private String msg;

//数据
private T data;

public ResultDTO() {
}

public ResultDTO(Integer code, String msg, T data) {
this.code = code;
this.msg = msg;
this.data = data;
}
}
17 changes: 17 additions & 0 deletions src/main/java/com/wizzstudio/substitute/dto/WxInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.wizzstudio.substitute.dto;

import lombok.Data;

import java.io.Serializable;

@Data
public class WxInfo implements Serializable {

private String code;

private String encryptedData;

private String iv;


}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ public enum IndentState {
* 执行中
*/
PERFORMING,
/**
* 货物已送达
*/
ARRIVED,
/**
*订单完成
*/
Expand Down
Loading