diff --git a/february-merchant-common/pom.xml b/february-merchant-common/pom.xml index 12d6153..3966e22 100644 --- a/february-merchant-common/pom.xml +++ b/february-merchant-common/pom.xml @@ -62,6 +62,11 @@ february-common-swagger 3.6.3 + + + org.projectlombok + lombok + diff --git a/february-merchant-common/src/main/java/com/february/system/domain/TCarType.java b/february-merchant-common/src/main/java/com/february/system/domain/TCarType.java new file mode 100644 index 0000000..714d88d --- /dev/null +++ b/february-merchant-common/src/main/java/com/february/system/domain/TCarType.java @@ -0,0 +1,9 @@ +package com.february.system.domain; + +import lombok.Data; + +@Data +public class TCarType { + private Integer carTypeId; + private String carTypeName; +} diff --git a/february-merchant-common/src/main/java/com/february/system/domain/Tadmin.java b/february-merchant-common/src/main/java/com/february/system/domain/Tadmin.java new file mode 100644 index 0000000..f3003d3 --- /dev/null +++ b/february-merchant-common/src/main/java/com/february/system/domain/Tadmin.java @@ -0,0 +1,18 @@ +package com.february.system.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +@Data +public class Tadmin { + private Integer adminId; + private String adminName; + private String adminPhone; + private String adminPassword; + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date adminRole; +} diff --git a/february-merchant-common/src/main/java/com/february/system/domain/Tcar.java b/february-merchant-common/src/main/java/com/february/system/domain/Tcar.java new file mode 100644 index 0000000..70820fa --- /dev/null +++ b/february-merchant-common/src/main/java/com/february/system/domain/Tcar.java @@ -0,0 +1,18 @@ +package com.february.system.domain; + +import lombok.Data; + +@Data +public class Tcar { + + private Integer carId;//主键id + private String carVin;//vin + private String carBh;//车牌号 + private Integer carTypeId;//车型id + private Integer actuateId;//驱动编号 + private Integer batteryId;//电池编号 + private Integer batteryMakerId;//电池厂家id + private Integer motorManufactuerId;//电机厂家id + private Integer carStatus;//车辆状态 + private String operatingArea;//运行区域 +} diff --git a/february-merchant-common/src/main/java/com/february/system/domain/Tuser.java b/february-merchant-common/src/main/java/com/february/system/domain/Tuser.java new file mode 100644 index 0000000..f99bf51 --- /dev/null +++ b/february-merchant-common/src/main/java/com/february/system/domain/Tuser.java @@ -0,0 +1,12 @@ +package com.february.system.domain; + +import lombok.Data; + +@Data +public class Tuser { + private Integer userId; + private String userName; + private String userPhone; + private String userPssword; + private String carVin; +} diff --git a/february-merchant-common/src/main/java/com/february/system/domain/constants/Constants.java b/february-merchant-common/src/main/java/com/february/system/domain/constants/Constants.java new file mode 100644 index 0000000..8d87b54 --- /dev/null +++ b/february-merchant-common/src/main/java/com/february/system/domain/constants/Constants.java @@ -0,0 +1,18 @@ +package com.february.system.domain.constants; + +/** + * @description: 系统常量 + * @author + */ +public class Constants { + /** + * 成功标记 + */ + public static final Integer SUCCESS = 200; + public static final String SUCCESS_MSG = "操作成功"; + /** + * 失败标记 + */ + public static final Integer ERROR = 500; + public static final String ERROR_MSG = "操作异常"; +} diff --git a/february-merchant-common/src/main/java/com/february/system/domain/constants/JwtConstants.java b/february-merchant-common/src/main/java/com/february/system/domain/constants/JwtConstants.java new file mode 100644 index 0000000..d65fc6d --- /dev/null +++ b/february-merchant-common/src/main/java/com/february/system/domain/constants/JwtConstants.java @@ -0,0 +1,29 @@ +package com.february.system.domain.constants; + +/** + * @author + * @description: Jwt常量 + */ +public class JwtConstants { + + /** + * 用户ID字段 + */ + public static final String DETAILS_USER_ID = "user_id"; + + /** + * 用户名字段 + */ + public static final String DETAILS_USERNAME = "username"; + + /** + * 用户标识 + */ + public static final String USER_KEY = "user_key"; + + /** + * 令牌秘钥 + */ + public final static String SECRET = "abcdefghijklmnopqrstuvwxyz"; + +} diff --git a/february-merchant-common/src/main/java/com/february/system/domain/constants/RabbitMQConstants.java b/february-merchant-common/src/main/java/com/february/system/domain/constants/RabbitMQConstants.java new file mode 100644 index 0000000..2e61192 --- /dev/null +++ b/february-merchant-common/src/main/java/com/february/system/domain/constants/RabbitMQConstants.java @@ -0,0 +1,17 @@ +package com.february.system.domain.constants; + +/** + * @ClassName: + * @Description: + * @Author: duKai + * @Date: 2023/6/27 + */ +public class RabbitMQConstants { + + /** + * 短信队列名称 + */ + public static final String SEND_SMS_QUEUE_NAME = "sms_queue"; + + public static final String COUNT_LOGIN_BY_DAY = "count_login_by_day"; +} diff --git a/february-merchant-common/src/main/java/com/february/system/domain/constants/TokenConstants.java b/february-merchant-common/src/main/java/com/february/system/domain/constants/TokenConstants.java new file mode 100644 index 0000000..e9ea731 --- /dev/null +++ b/february-merchant-common/src/main/java/com/february/system/domain/constants/TokenConstants.java @@ -0,0 +1,24 @@ +package com.february.system.domain.constants; + +/** + * @author + * @description: 令牌常量 + */ +public class TokenConstants { + /** + * 缓存有效期,默认720(分钟) + */ + public final static long EXPIRATION = 720; + /** + * 缓存刷新时间,默认120(分钟) + */ + public final static long REFRESH_TIME = 120; + /** + * 权限缓存前缀 + */ + public final static String LOGIN_TOKEN_KEY = "login_tokens:"; + /** + * token标识 + */ + public static final String TOKEN = "token"; +} diff --git a/february-merchant-common/src/main/java/com/february/system/domain/result/PageResult.java b/february-merchant-common/src/main/java/com/february/system/domain/result/PageResult.java new file mode 100644 index 0000000..9993abb --- /dev/null +++ b/february-merchant-common/src/main/java/com/february/system/domain/result/PageResult.java @@ -0,0 +1,34 @@ +package com.february.system.domain.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author + * @description: 列表返回结果集 + */ +@Data +public class PageResult implements Serializable { + /** + * 总条数 + */ + private long total; + /** + * 结果集合 + */ + private List list; + public PageResult() { + } + public PageResult(long total, List list) { + this.total = total; + this.list = list; + } + public static PageResult toPageResult(long total, List list){ + return new PageResult(total , list); + } + public static Result> toResult(long total, List list){ + return Result.success(PageResult.toPageResult(total,list)); + } +} diff --git a/february-merchant-common/src/main/java/com/february/system/domain/result/Result.java b/february-merchant-common/src/main/java/com/february/system/domain/result/Result.java new file mode 100644 index 0000000..8f129be --- /dev/null +++ b/february-merchant-common/src/main/java/com/february/system/domain/result/Result.java @@ -0,0 +1,76 @@ +package com.february.system.domain.result; + +import com.february.system.domain.constants.Constants; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author + * @description: 响应信息主体 + */ +@Data +public class Result implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * 成功 + */ + public static final int SUCCESS = Constants.SUCCESS; + /** + * 失败 + */ + public static final int FAIL = Constants.ERROR; + /** + * 返回状态码 + */ + private int code; + /** + * 响应信息 + */ + private String msg; + /** + * 响应数据 + */ + private T data; + + public static Result success() { + return restResult(null, SUCCESS, Constants.SUCCESS_MSG); + } + + public static Result success(T data) { + return restResult(data, SUCCESS, Constants.SUCCESS_MSG); + } + + public static Result success(T data, String msg) { + return restResult(data, SUCCESS, msg); + } + + public static Result error() { + return restResult(null, FAIL, Constants.ERROR_MSG); + } + + public static Result error(String msg) { + return restResult(null, FAIL, msg); + } + + public static Result error(T data) { + return restResult(data, FAIL, Constants.ERROR_MSG); + } + + public static Result error(T data, String msg) { + return restResult(data, FAIL, msg); + } + + public static Result error(int code, String msg) { + return restResult(null, code, msg); + } + + private static Result restResult(T data, int code, String msg) { + Result apiResult = new Result<>(); + apiResult.setCode(code); + apiResult.setData(data); + apiResult.setMsg(msg); + return apiResult; + } +} diff --git a/february-merchant-remote/pom.xml b/february-merchant-remote/pom.xml index c9810fa..faef62a 100644 --- a/february-merchant-remote/pom.xml +++ b/february-merchant-remote/pom.xml @@ -22,5 +22,12 @@ february-merchant-common 3.6.3 + + + com.february + february-common-core + 3.6.3 + compile + diff --git a/february-merchant-server/pom.xml b/february-merchant-server/pom.xml index c0a1bff..f55e73c 100644 --- a/february-merchant-server/pom.xml +++ b/february-merchant-server/pom.xml @@ -3,12 +3,12 @@ xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.february february-merchant-settlement 3.6.3 + com.february 3.6.3 february-merchant-server @@ -34,11 +34,7 @@ compile - - com.february - february-common-log - 3.6.3 - + com.february @@ -52,6 +48,42 @@ 3.6.3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${project.artifactId} diff --git a/february-merchant-server/src/main/java/com/february/Main.java b/february-merchant-server/src/main/java/com/february/merchant/Main.java similarity index 50% rename from february-merchant-server/src/main/java/com/february/Main.java rename to february-merchant-server/src/main/java/com/february/merchant/Main.java index 1d2e6c4..95d31f5 100644 --- a/february-merchant-server/src/main/java/com/february/Main.java +++ b/february-merchant-server/src/main/java/com/february/merchant/Main.java @@ -1,8 +1,13 @@ -package com.february; +package com.february.merchant; +import com.february.common.security.annotation.EnableCustomConfig; +import com.february.common.swagger.annotation.EnableCustomSwagger2; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +@EnableCustomConfig +@EnableCustomSwagger2 @SpringBootApplication public class Main { public static void main(String[] args) { diff --git a/february-merchant-server/src/main/java/com/february/merchant/controller/AddCarController.java b/february-merchant-server/src/main/java/com/february/merchant/controller/AddCarController.java new file mode 100644 index 0000000..db3587b --- /dev/null +++ b/february-merchant-server/src/main/java/com/february/merchant/controller/AddCarController.java @@ -0,0 +1,63 @@ +package com.february.merchant.controller; + +import com.alibaba.fastjson.JSONObject; +import com.february.merchant.service.AddCarService; +import com.february.system.domain.Tadmin; +import com.february.system.domain.Tcar; +import com.february.system.domain.Tuser; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import com.february.system.domain.result.Result; +import javax.servlet.http.HttpServletRequest; + + +@RestController +@RequestMapping("/add") +@Log4j2 +public class AddCarController { + @Autowired + private AddCarService addCarService; + @Autowired + + private HttpServletRequest request; + + @PostMapping("addCar") + public Result addCar(@RequestBody Tcar tcar){ + log.info("功能名称:添加车辆,请求URI:{},请求方式:{},请求结果:{}" + ,request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(tcar)); + addCarService.addCar(tcar); + Result result = Result.success(); + log.info("功能名称:添加车辆,响应URI:{},相应方式:{},响应结果:{}" + ,request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result)); + return result; + } + + /** + * 根据用户名获取用户信息 + */ + @PostMapping("/findByadminName/{adminName}") + public Result findByadminName(@PathVariable String adminName){ + log.info("功能名称:根据用户名获取用户信息,请求URI:{},请求方式:{},请求参数:{}" + ,request.getRequestURI(),request.getMethod(),adminName); + Tadmin tadmin=addCarService.findByadminName(adminName); + Result result = Result.success(tadmin); + log.info("功能名称:根据用户名获取用户信息,响应URI:{},相应方式:{},响应结果:{}" + ,request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result)); + return result; + } + + /** + * 根据客户名获取用户信息 + */ + @PostMapping("/findByuserName/{userName}") + public Result findByuserName(@PathVariable String userName){ + log.info("功能名称:根据客户名获取用户信息,请求URI:{},请求方式:{},请求参数:{}" + ,request.getRequestURI(),request.getMethod(),userName); + Tuser tuser= addCarService.findByuserName(userName); + Result result = Result.success(tuser); + log.info("功能名称:根据客户名获取用户信息,响应URI:{},响应方式:{},响应结果:{}" + ,request.getRequestURI(),request.getMethod(),JSONObject.toJSONString(result)); + return result; + } +} diff --git a/february-merchant-server/src/main/java/com/february/merchant/mapper/AddCarMapper.java b/february-merchant-server/src/main/java/com/february/merchant/mapper/AddCarMapper.java new file mode 100644 index 0000000..260da1b --- /dev/null +++ b/february-merchant-server/src/main/java/com/february/merchant/mapper/AddCarMapper.java @@ -0,0 +1,14 @@ +package com.february.merchant.mapper; + +import com.february.system.domain.Tadmin; +import com.february.system.domain.Tcar; +import com.february.system.domain.Tuser; +import org.apache.ibatis.annotations.Mapper; + +public interface AddCarMapper { + void addCar(Tcar tcar); + + Tadmin findByadminName(String adminName); + + Tuser findByuserName(String userName); +} diff --git a/february-merchant-server/src/main/java/com/february/merchant/service/AddCarService.java b/february-merchant-server/src/main/java/com/february/merchant/service/AddCarService.java new file mode 100644 index 0000000..d533694 --- /dev/null +++ b/february-merchant-server/src/main/java/com/february/merchant/service/AddCarService.java @@ -0,0 +1,15 @@ +package com.february.merchant.service; + +import com.february.system.domain.Tadmin; +import com.february.system.domain.Tcar; +import com.february.system.domain.Tuser; +import org.springframework.stereotype.Service; + +@Service +public interface AddCarService { + void addCar(Tcar tcar); + + Tadmin findByadminName(String adminName); + + Tuser findByuserName(String userName); +} diff --git a/february-merchant-server/src/main/java/com/february/merchant/service/impl/AddCarServiceImpl.java b/february-merchant-server/src/main/java/com/february/merchant/service/impl/AddCarServiceImpl.java new file mode 100644 index 0000000..eaedb0c --- /dev/null +++ b/february-merchant-server/src/main/java/com/february/merchant/service/impl/AddCarServiceImpl.java @@ -0,0 +1,31 @@ +package com.february.merchant.service.impl; + +import com.february.merchant.mapper.AddCarMapper; +import com.february.merchant.service.AddCarService; +import com.february.system.domain.Tadmin; +import com.february.system.domain.Tcar; +import com.february.system.domain.Tuser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class AddCarServiceImpl implements AddCarService { + @Autowired + private AddCarMapper addCarMapper; + + @Override + public void addCar(Tcar tcar) { + addCarMapper.addCar(tcar); + } + + @Override + public Tadmin findByadminName(String adminName) { + return addCarMapper.findByadminName(adminName); + } + + @Override + public Tuser findByuserName(String userName) { + return addCarMapper.findByuserName(userName); + } + +} diff --git a/february-merchant-server/src/main/resources/bootstrap.yml b/february-merchant-server/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..0cf8b43 --- /dev/null +++ b/february-merchant-server/src/main/resources/bootstrap.yml @@ -0,0 +1,25 @@ +# Tomcat +server: + port: 9204 + +# Spring +spring: + application: + # 应用名称 + name: merchant-settlement + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 10.100.1.4:8848 + config: + # 配置中心地址 + server-addr: 10.100.1.4:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/february-merchant-server/src/main/resources/mapper/AddCarMapper.xml b/february-merchant-server/src/main/resources/mapper/AddCarMapper.xml new file mode 100644 index 0000000..d689a97 --- /dev/null +++ b/february-merchant-server/src/main/resources/mapper/AddCarMapper.xml @@ -0,0 +1,30 @@ + + + + + + + INSERT INTO `car`.`t_car` (`car_id`, `car_vin`, `car_bh`, `car_type_id`, `actuate_id`, `battery_id`, `battery_maker_id`, `motor_manufacturer_id`, `car_status`, `operating_area`) VALUES + ( + null, + #{carVin}, + #{carBh}, + #{carTypeId}, + #{actuateId}, + #{batteryId}, + #{batteryMakerId}, + #{motorManufactuerId}, + #{carStatus}, + #{operatingArea} + ) + + + + + diff --git a/pom.xml b/pom.xml index d00ce0a..dd4fec4 100644 --- a/pom.xml +++ b/pom.xml @@ -32,4 +32,5 @@ http://10.100.1.5:8081/repository/maven-releases/ +