Commit 0a993d01 by levphon

微信小程序后端服务

1 parent fe90ac28
Showing 28 changed files with 857 additions and 161 deletions
......@@ -2,15 +2,14 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>glsx-archetype-parent</artifactId>
<artifactId>glsx-ne-shield</artifactId>
<groupId>com.glsx</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<description>Microservice Scaffolding Project Base on Spring Cloud</description>
<artifactId>glsx-rest-app-archetype</artifactId>
<artifactId>ne-shield-miniappserver</artifactId>
<dependencies>
<dependency>
......@@ -19,31 +18,121 @@
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-context</artifactId>
<artifactId>rest-admin-office</artifactId>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-core</artifactId>
<artifactId>rest-admin-loggin</artifactId>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-mybatis</artifactId>
<artifactId>rest-admin-swagger2</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.glsx</groupId>-->
<!-- <artifactId>rest-admin-wechat</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-jwt</artifactId>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId>
<version>4.2.7.B</version>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-wechat</artifactId>
<artifactId>ne-shield-auth-client</artifactId>
<version>1.1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<!--mybatis 逆向生成插件-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.7</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.7</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>3.4.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>Generate MyBatis Artifacts</id>
<!--<phase>package</phase>-->
<phase>deploy</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<!--允许移动生成的文件 -->
<verbose>true</verbose>
<!-- 是否覆盖 -->
<overwrite>false</overwrite>
<!-- 自动生成的配置 -->
<configurationFile>src/main/resources/config/generatorConfig.xml</configurationFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>xlsx</nonFilteredFileExtension>
<nonFilteredFileExtension>xls</nonFilteredFileExtension>
<nonFilteredFileExtension>zip</nonFilteredFileExtension>
<nonFilteredFileExtension>cer</nonFilteredFileExtension>
<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
<nonFilteredFileExtension>py</nonFilteredFileExtension>
<nonFilteredFileExtension>keystore</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
</plugins>
</build>
......
......@@ -3,6 +3,8 @@ package cn.com.glsx.app;
import com.glsx.plat.context.EnableRestAdmin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.EnableMBeanExport;
import org.springframework.jmx.support.RegistrationPolicy;
import org.springframework.transaction.annotation.EnableTransactionManagement;
......@@ -17,9 +19,11 @@ import static java.util.TimeZone.getTimeZone;
* @author payu
*/
@EnableRestAdmin
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"cn.com.glsx.*.api"})
@EnableTransactionManagement
@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
@SpringBootApplication
@SpringBootApplication(scanBasePackages = {"cn.com.glsx.*"})
public class Application {
public static void main(String[] args) {
......
package cn.com.glsx.app.config;
import cn.com.glsx.auth.interceptor.WebRequestAuthorizeInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author payu
*/
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Autowired
private WebRequestAuthorizeInterceptor authInterceptor;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
//1.加入的顺序就是拦截器执行的顺序,
//2.按顺序执行所有拦截器的preHandle
//3.所有的preHandle 执行完再执行全部postHandle 最后是postHandle
registry.addInterceptor(authInterceptor)
.addPathPatterns("/**")
.excludePathPatterns("/")
.excludePathPatterns("/login")
.excludePathPatterns("/xactuator/**")
.excludePathPatterns("/api/**")
.excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
}
}
\ No newline at end of file
......@@ -7,16 +7,18 @@ import cn.com.glsx.app.modules.service.UserService;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.Map;
/**
* 本地登录
*
* @author liuyf
*/
@Slf4j
......@@ -38,7 +40,7 @@ public class LocalLoginController {
* 本地登录
*/
@PostMapping(value = "/login")
public R login(@RequestBody @Valid LoginByAccountBO loginBO) {
public R login(@RequestBody @Validated LoginByAccountBO loginBO) {
AppUser user = loginService.localAuth(loginBO);
......
package cn.com.glsx.app.modules;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.com.glsx.app.modules.entity.UserAuthRel;
import cn.com.glsx.app.modules.model.AppUser;
import cn.com.glsx.app.modules.model.QQLoginBO;
import cn.com.glsx.app.modules.model.QQOAuth2AccessToken;
import cn.com.glsx.app.modules.model.WechatLoginBO;
import cn.com.glsx.app.modules.service.LoginService;
import cn.com.glsx.app.modules.service.UserService;
......@@ -10,9 +13,7 @@ import cn.hutool.json.JSONUtil;
import com.glsx.plat.common.annotation.NoLogin;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -22,34 +23,31 @@ import java.util.Map;
import java.util.Optional;
/**
* 第三方登录
*
* @author liuyf
* @Title UserController.java
* @Package com.hflw.vasp.controller
* @Description 微信登录
* @date 2019年10月24日 下午2:02:54
*/
@Slf4j
@RestController
public class ThirdLoginController {
private final WxMpService wxMpService;
@Resource
private UserService userService;
@Autowired
private LoginService loginService;
public ThirdLoginController(WxMpService wxMpService) {
this.wxMpService = wxMpService;
}
@Autowired
private WxMaService wxMaService;
@NoLogin
@RequestMapping(value = "/wechatAuth")
public R wechatAuth(@RequestParam String code) throws WxErrorException {
WxOAuth2AccessToken accessToken = wxMpService.getOAuth2Service().getAccessToken(code);
log.info("微信code[{}]获取的Token信息为{}", code, JSONUtil.toJsonStr(accessToken));
UserAuthRel authRel = loginService.wechatAuth(accessToken);
//获取openId、unionid、session_key
WxMaJscode2SessionResult sessionInfo = wxMaService.getUserService().getSessionInfo(code);
log.info("微信code[{}]获取的Session信息为{}", code, JSONUtil.toJsonStr(sessionInfo));
UserAuthRel authRel = loginService.wechatAuth(sessionInfo);
Map<String, Object> rtnMap = thirdLogin(authRel);
......@@ -70,7 +68,14 @@ public class ThirdLoginController {
@NoLogin
@RequestMapping(value = "/qqAuth")
public R qqAuth(@RequestParam String code) {
return R.ok();
QQOAuth2AccessToken accessToken = new QQOAuth2AccessToken();
log.info("QQ code[{}]获取的Session信息为{}", code, JSONUtil.toJsonStr(accessToken));
UserAuthRel authRel = loginService.qqAuth(accessToken);
Map<String, Object> rtnMap = thirdLogin(authRel);
return R.ok().data(rtnMap);
}
@NoLogin
......@@ -93,7 +98,7 @@ public class ThirdLoginController {
AppUser user = userService.getAppUserByUserId(optUserId.get());
String token = userService.createToken(user);
rtnMap.put("token", token);
// rtnMap.put("user", UserConverter.INSTANCE.do2dto(user));
rtnMap.put("user", user);
} else {
//没有绑定用户
rtnMap.put("authRelId", authRel.getId());
......
package cn.com.glsx.app.modules.controller;
import cn.com.glsx.app.modules.model.VehicleDeviceDTO;
import cn.com.glsx.app.modules.service.VehicleMonitorService;
import com.glsx.plat.core.web.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Slf4j
@RestController
@RequestMapping(value = "/monitor")
@Api(value = "车辆监控", tags = {"车辆监控"})
public class VehicleMonitorController {
@Autowired
private VehicleMonitorService vehicleMonitorService;
/**
* @param term
* @return
*/
@ApiOperation(value = "车辆树")
@GetMapping("/search")
public R<List> search(@RequestParam("term") String term) {
List<VehicleDeviceDTO> list = vehicleMonitorService.search(term);
return R.ok().data(list);
}
}
package cn.com.glsx.app.modules.converter;
import cn.com.glsx.app.modules.model.AppUser;
import cn.com.glsx.auth.model.SimpleUser;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface UserConverter {
UserConverter INSTANCE = Mappers.getMapper(UserConverter.class);
AppUser su2au(SimpleUser user);
}
......@@ -3,6 +3,7 @@ package cn.com.glsx.app.modules.entity;
import com.glsx.plat.mybatis.base.BaseEntity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
@Data
......@@ -10,13 +11,9 @@ import javax.persistence.Table;
public class UserLocalAuth extends BaseEntity {
/**
* 用户手机
* 用户id
*/
private String mobile;
/**
* 密码
*/
private String password;
@Column(name = "user_id")
private Long userId;
}
\ No newline at end of file
package cn.com.glsx.app.modules.entity;
import com.glsx.plat.mybatis.base.BaseEntity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
import java.util.Date;
@Data
@Table(name = "t_vehicle")
public class Vehicle extends BaseEntity {
/**
* 工单id
*/
@Column(name = "workorder_id")
private Long workOrderId;
/**
* 车主姓名
*/
@Column(name = "owner_name")
private String ownerName;
/**
* 车架号
*/
private String vin;
/**
* 车主性别
*/
@Column(name = "owner_sex")
private String ownerSex;
/**
* 车主联系方式
*/
@Column(name = "owner_tel")
private String ownerTel;
/**
* 车辆品牌id
*/
@Column(name = "brand_id")
private Integer brandId;
/**
* 车辆品牌
*/
@Column(name = "brand_name")
private String brandName;
/**
* 车辆子品牌id
*/
@Column(name = "sub_brand_id")
private Integer subBrandId;
/**
* 车辆子品牌
*/
@Column(name = "sub_brand_name")
private String subBrandName;
/**
* 车辆系别id
*/
@Column(name = "series_id")
private Integer seriesId;
/**
* 车辆系别
*/
@Column(name = "series_name")
private String seriesName;
/**
* 车辆类型id
*/
@Column(name = "type_id")
private Integer typeId;
/**
* 车辆类型
*/
@Column(name = "type_name")
private String typeName;
/**
* 车辆型号id
*/
@Column(name = "model_id")
private Integer modelId;
/**
* 车辆型号
*/
@Column(name = "model_name")
private String modelName;
/**
* 配置id
*/
@Column(name = "config_id")
private Integer configId;
/**
* 车辆配置
*/
@Column(name = "config_desc")
private String configDesc;
/**
* 车辆外部颜色
*/
private String color;
/**
* 车辆内饰颜色
*/
@Column(name = "inner_color")
private String innerColor;
/**
* 车牌
*/
@Column(name = "license_plate")
private String licensePlate;
/**
* 车辆类型 1:试乘试驶车 2:深度体验车
*/
@Column(name = "vehicle_type")
private Byte vehicleType;
/**
* 发动机
*/
private String engine;
/**
* 排量
*/
private String displacement;
/**
* 里程
*/
private String mileage;
/**
* 购置方式 1.租赁
*/
@Column(name = "buy_type")
private Integer buyType;
/**
* 购车时间
*/
@Column(name = "buy_date")
private Date buyDate;
/**
* 车辆说明
*/
private String description;
/**
* 备注
*/
private String remark;
/**
* 服役类型:0未上牌,1已上牌
*/
@Column(name = "serve_type")
private Byte serveType;
/**
* 销售经理
*/
@Column(name = "sale_manager")
private String saleManager;
/**
* 销售经理电话
*/
@Column(name = "sale_manager_phone")
private String saleManagerPhone;
/**
* 验证(激活)状态 0默认,1:通过,2 不通过,车辆可能不用关联设备
*/
@Column(name = "validate_status")
private Byte validateStatus;
/**
* 1 专属用途 2 非专属用途
*/
@Column(name = "vehicle_usages")
private Byte vehicleUsages;
/**
* 验证(激活)详情
*/
@Column(name = "validate_info")
private String validateInfo;
/**
* 上牌日期
*/
@Column(name = "registration_date")
private Date registrationDate;
}
\ No newline at end of file
package cn.com.glsx.app.modules.entity;
import com.glsx.plat.mybatis.base.BaseEntity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
@Data
@Table(name = "t_vehicle_device")
public class VehicleDevice extends BaseEntity {
/**
* 车辆id
*/
@Column(name = "vehicle_id")
private Long vehicleId;
/**
* 设备sn
*/
private String sn;
/**
* 绑定状态:1绑定,2解绑
*/
@Column(name = "bind_status")
private Byte bindStatus;
/**
* 试驾类型 0:非试驾设备, 1,试驾设备
*/
@Column(name = "trial_type")
private Byte trialType;
/**
* 历史试驾类型 0:曾经不是试驾设备; 1:曾经是试驾设备
*/
@Column(name = "his_type")
private Byte hisType;
/**
* 有线无线类型:1有线,0无线
*/
@Column(name = "wire_type")
private Byte wireType;
}
\ No newline at end of file
package cn.com.glsx.app.modules.entity;
import com.glsx.plat.mybatis.base.BaseEntity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
@Data
@Table(name = "t_vehicle_permit")
public class VehiclePermit extends BaseEntity {
/**
* 授权数据id
*/
@Column(name = "content_id")
private Long contentId;
/**
* 授权人id
*/
@Column(name = "accorder_id")
private Long accorderId;
/**
* 获权人id
*/
@Column(name = "receiver_id")
private Long receiverId;
/**
* 内容类型:0车辆
*/
@Column(name = "content_type")
private Integer contentType;
/**
* 权限类型 r=只读 wr=读写
*/
@Column(name = "permit_type")
private String permitType;
}
\ No newline at end of file
......@@ -10,10 +10,6 @@ public interface UserLocalAuthMapper extends CommonBaseMapper<UserLocalAuth> {
UserLocalAuth selectById(@Param("id") Long id);
UserLocalAuth selectByUserId(@Param("userId") Long userId);
int updateMobileByUserId(@Param("userId") Long userId, @Param("mobile") String mobile);
int updatePasswordByUserId(@Param("userId") Long userId, @Param("password") String password);
int logicDeleteById(@Param("id") Long id);
......
package cn.com.glsx.app.modules.mapper;
import cn.com.glsx.app.modules.entity.UserLocalAccount;
import cn.com.glsx.app.modules.entity.VehicleDevice;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface UserLocalAccountMapper extends CommonBaseMapper<UserLocalAccount> {
UserLocalAccount selectByAuthId(@Param("authId") Long authId);
UserLocalAccount selectByUserId(@Param("userId") Long userId);
UserLocalAccount selectByUnionId(@Param("unionId") String unionId);
int logicDeleteById(@Param("id") Long id);
public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
}
\ No newline at end of file
package cn.com.glsx.app.modules.mapper;
import cn.com.glsx.app.modules.entity.Vehicle;
import cn.com.glsx.app.modules.model.VehicleDeviceDTO;
import com.glsx.plat.common.annotation.DataPerm;
import com.glsx.plat.common.annotation.DataPermShare;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
@DataPerm(showSql = true)
@DataPermShare(showSql = true)
List<VehicleDeviceDTO> search(@Param("term") String term);
}
\ No newline at end of file
package cn.com.glsx.app.modules.mapper;
import cn.com.glsx.app.modules.entity.VehiclePermit;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface VehiclePermitMapper extends CommonBaseMapper<VehiclePermit> {
}
\ No newline at end of file
......@@ -9,10 +9,10 @@ import javax.validation.constraints.NotNull;
public class LoginByAccountBO {
/**
* 登录类型:1密码,2短信验证码
* 登录类型:1密码(默认),2短信验证码
*/
@NotNull
private Integer loginType;
private Integer loginType = 1;
@NotBlank(message = "账号不能为空")
private String account;
......@@ -20,7 +20,7 @@ public class LoginByAccountBO {
@NotBlank(message = "验证码/密码不能为空")
private String code;
//@NotNull(message = "APP客户端ID不能为空")
private String clientId;
// @NotNull(message = "APP客户端ID不能为空")
// private String clientId;
}
package cn.com.glsx.app.modules.model;
import lombok.Data;
@Data
public class VehicleDeviceDTO {
private Long id;
private Long vid;
private String vin;
private String ownerName;
private String sns;
private Long creatorId;
private Integer source;
/**
* 设备类型:1(OBD),8(GPS)
*/
private Integer deviceType;
}
package cn.com.glsx.app.modules.service;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.com.glsx.app.common.enums.AuthType;
import cn.com.glsx.app.common.enums.LoginType;
import cn.com.glsx.app.common.exception.AppServerException;
import cn.com.glsx.app.modules.converter.UserConverter;
import cn.com.glsx.app.modules.entity.*;
import cn.com.glsx.app.modules.mapper.*;
import cn.com.glsx.app.modules.model.*;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
import cn.com.glsx.auth.api.AuthFeignClient;
import cn.com.glsx.auth.model.SimpleUser;
import com.glsx.plat.core.web.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -25,32 +30,36 @@ public class LoginService {
private UserThirdAuthMapper thirdAuthMapper;
@Resource
private UserLocalAccountMapper localAccountMapper;
@Resource
private UserWechatAccountMapper wechatAccountMapper;
@Resource
private UserQQAccountMapper qqAccountMapper;
@Autowired
private AuthFeignClient authFeignClient;
@Transactional(rollbackFor = Exception.class)
public AppUser localAuth(LoginByAccountBO loginBO) {
// TODO: 2022/3/24 内部登录转成appUser返回前端
AppUser appUser = new AppUser();
UserAuthRel userAuthRel = authRelMapper.selectLocalAuthRelByUserId(appUser.getId());
//内部登录转成appUser返回前端
if (loginBO.getLoginType() == 1) {
//密码登录
R<SimpleUser> userR = authFeignClient.login(loginBO.getAccount(), loginBO.getCode());
SimpleUser simpleUser = userR.getData(SimpleUser.class);
if (!userR.isSuccess() || simpleUser == null) {
throw new AppServerException(userR.getMessage());
}
UserAuthRel userAuthRel = authRelMapper.selectLocalAuthRelByUserId(simpleUser.getId());
UserLocalAuth localAuth = localAuthMapper.selectById(userAuthRel.getAuthId());
if (localAuth == null) {
throw new AppServerException("请先开通登录权限");
}
return UserConverter.INSTANCE.su2au(simpleUser);
} else if (loginBO.getLoginType() == 2) {
//验证码校验
//smsService.verifyCode(loginBO.getAccount(), loginBO.getCode());
}
return appUser;
return null;
}
@Transactional(rollbackFor = Exception.class)
......@@ -110,12 +119,12 @@ public class LoginService {
}
@Transactional(rollbackFor = Exception.class)
public UserAuthRel wechatAuth(WxOAuth2AccessToken accessToken) {
UserThirdAuth thirdAuth = thirdAuthMapper.selectByOpenid(accessToken.getOpenId());
public UserAuthRel wechatAuth(WxMaJscode2SessionResult sessionInfo) {
UserThirdAuth thirdAuth = thirdAuthMapper.selectByOpenid(sessionInfo.getOpenid());
if (thirdAuth == null) {
thirdAuth = new UserThirdAuth();
thirdAuth.setOpenid(accessToken.getOpenId());
thirdAuth.setAccessToken(accessToken.getAccessToken());
thirdAuth.setOpenid(sessionInfo.getOpenid());
thirdAuth.setAccessToken(sessionInfo.getSessionKey());
thirdAuth.setLoginType(LoginType.WECHAT.getType());
thirdAuthMapper.insertUseGeneratedKeys(thirdAuth);
}
......@@ -124,7 +133,7 @@ public class LoginService {
if (wechatAccount == null) {
wechatAccount = new UserWechatAccount();
wechatAccount.setAuthId(thirdAuth.getId());
wechatAccount.setUnionId(accessToken.getUnionId());
wechatAccount.setUnionId(sessionInfo.getUnionid());
wechatAccountMapper.insertUseGeneratedKeys(wechatAccount);
}
......
package cn.com.glsx.app.modules.service;
import cn.com.glsx.app.modules.mapper.VehicleMapper;
import cn.com.glsx.app.modules.model.VehicleDeviceDTO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class VehicleMonitorService {
@Resource
private VehicleMapper vehicleMapper;
public List<VehicleDeviceDTO> search(String term) {
return vehicleMapper.search(term);
}
}
#项目名称
spring.application.name=glsx-rest-appserver
spring.application.name=ne-shield-miniappserver
#日志路径(logback-spring.xml读取,不要加入配置中心)
logging.path=/data/java_log/jetty/${spring.application.name}/${spring.application.name}.log
......@@ -9,13 +9,13 @@ spring.cloud.nacos.config.server-addr=192.168.3.206:8848
#nacos配置id,完整dataId=${spring.cloud.nacos.config.prefix}-${spring.profiles.active}.${file-extension(由新增配置时选的文件类型决定)}
#示例:http://192.168.0.63:8848/nacos/v1/cs/configs?dataId=glsx-rest-admin.properties&group=DEV_GROUP
spring.cloud.nacos.config.group=DEV_GROUP
spring.cloud.nacos.config.group=NESHIELD_DEV_GROUP
#配置prefix,默认值同${spring.application.name}
spring.cloud.nacos.config.prefix=${spring.application.name}
#配置开发环境
#spring.profiles.active=DEV
spring.profiles.active=dev
#配置格式
#spring.cloud.nacos.config.file-extension=properties
spring.cloud.nacos.config.file-extension=properties
#微服务sentinel、zipkin、actuator等公共配置
spring.cloud.nacos.config.shared-configs[0].data-id=glsx-rest-microservice-share.properties
......@@ -23,6 +23,6 @@ spring.cloud.nacos.config.shared-configs[0].group=DEV_GROUP
spring.cloud.nacos.config.shared-configs[0].refresh=true
#数据库、redis等公共配置
spring.cloud.nacos.config.shared-configs[1].group=DEV_GROUP
spring.cloud.nacos.config.shared-configs[1].data-id=glsx-rest-admin-share.properties
spring.cloud.nacos.config.shared-configs[1].group=NESHIELD_DEV_GROUP
spring.cloud.nacos.config.shared-configs[1].data-id=glsx-ne-shield-share-dev.properties
spring.cloud.nacos.config.shared-configs[1].refresh=true
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE generatorConfiguration PUBLIC
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<!-- 配置生成器 -->
<generatorConfiguration>
<!--classPathEntry:数据库的JDBC驱动,换成你自己的驱动位置 可选 -->
<!-- <classPathEntry location="F://jdbc//mysql-connector-java-8.0.18.jar"/>-->
<!-- 一个数据库一个context -->
<context id="DB2Tables" targetRuntime="Mybatis3">
<!-- 自动识别数据库关键字,默认false,如果设置为true,根据SqlReservedWords中定义的关键字列表;一般保留默认值,遇到数据库关键字(Java关键字),使用columnOverride覆盖 -->
<property name="autoDelimitKeywords" value="true"/>
<!-- 生成的Java文件的编码 -->
<property name="javaFileEncoding" value="utf-8"/>
<!-- beginningDelimiter和endingDelimiter:指明数据库的用于标记数据库对象名的符号,比如ORACLE就是双引号,MYSQL默认是`反引号; -->
<property name="beginningDelimiter" value="`"/>
<property name="endingDelimiter" value="`"/>
<!-- 格式化java代码 -->
<property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter"/>
<!-- 格式化XML代码 -->
<property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/>
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>
<plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>
<!-- 配置 tk.mybatis 插件 -->
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="mappers" value="com.glsx.plat.mybatis.mapper.CommonBaseMapper"/>
</plugin>
<!--配置生成注释信息,最多配置一个 -->
<commentGenerator>
<!-- 阻止生成注释包含时间戳 默认为false -->
<property name="suppressDate" value="true"/>
<!-- 注释是否添加数据库表的备注信息 默认为false -->
<property name="addRemarkComments" value="true"/>
</commentGenerator>
<!-- jdbc连接-->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://192.168.3.190:3306/neshield?serverTimeZone=Shanghai&amp;useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false"
userId="dev_user"
password="df234fl">
<!--防止生成其他库同名表-->
<property name="nullCatalogMeansCurrent" value="true"/>
</jdbcConnection>
<!-- 类型转换 -->
<javaTypeResolver>
<!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成实体类地址 -->
<javaModelGenerator targetPackage="cn.com.glsx.app.modules.entity" targetProject="src/main/java">
<!-- 是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="true"/>
<!-- 从数据库返回的值去掉前后空格 -->
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成mapper.xml文件存放地址 -->
<sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成接口dao type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象 type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象 type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator targetPackage="cn.com.glsx.app.modules.mapper" targetProject="src/main/java" type="XMLMAPPER">
<property name="enableSubPackages" value="false"/>
</javaClientGenerator>
<!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 -->
<table tableName="t_vehicle" domainObjectName="Vehicle" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
</context>
</generatorConfiguration>
\ No newline at end of file
<?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="cn.com.glsx.app.modules.mapper.UserLocalAccountMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.app.modules.entity.UserLocalAccount">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="user_id" jdbcType="INTEGER" property="userId"/>
<result column="auth_id" jdbcType="INTEGER" property="authId"/>
<result column="union_id" jdbcType="VARCHAR" property="unionId"/>
<result column="username" jdbcType="VARCHAR" property="username"/>
<result column="avatar" jdbcType="VARCHAR" property="avatar"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, user_id, auth_id, union_id, username, avatar, del_flag, created_date, created_by,
updated_date, updated_by
</sql>
<select id="selectByAuthId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_user_local_account
where auth_id = #{authId}
and del_flag = 0
</select>
<select id="selectByUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_user_local_account
where user_id = #{userId}
and del_flag = 0
</select>
<select id="selectByUnionId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_user_local_account
where union_id = #{unionId}
and del_flag = 0
</select>
<update id="logicDeleteById">
update t_user_local_account
set del_flag = -1
where id = #{id}
</update>
</mapper>
\ No newline at end of file
......@@ -6,8 +6,7 @@
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="mobile" jdbcType="VARCHAR" property="mobile"/>
<result column="password" jdbcType="VARCHAR" property="password"/>
<result column="user_id" jdbcType="INTEGER" property="userId"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
......@@ -18,7 +17,7 @@
<!--
WARNING - @mbg.generated
-->
id, mobile, `password`, del_flag, created_date, created_by,
id, user_id, del_flag, created_date, created_by,
updated_date, updated_by
</sql>
......@@ -30,26 +29,6 @@
and del_flag = 0
</select>
<select id="selectByUserId" resultMap="BaseResultMap">
select tcula.id, tcula.mobile, tcula.`password`, tcuar.user_id, tcuar.auth_id
from t_user_local_auth tcula,
t_user_auth_rel tcuar
where tcula.id = tcuar.auth_id
and auth_type = 'local'
and tcuar.user_id = #{userId}
and tcuar.del_flag = 0 limit 1
</select>
<update id="updateMobileByUserId">
update t_user_local_auth tcula ,t_user_auth_rel tcuar,t_user tcu
set tcula.mobile = #{mobile},
tcu.account = #{mobile}
where tcula.id = tcuar.auth_id
and auth_type = 'local'
and tcuar.user_id = tcu.id
and tcuar.user_id = #{userId}
</update>
<update id="updatePasswordByUserId">
update t_user_local_auth tcula ,t_user_auth_rel tcuar
set tcula.password = #{password}
......
<?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="cn.com.glsx.app.modules.mapper.VehicleDeviceMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.app.modules.entity.VehicleDevice">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="vehicle_id" jdbcType="INTEGER" property="vehicleId" />
<result column="sn" jdbcType="VARCHAR" property="sn" />
<result column="bind_status" jdbcType="TINYINT" property="bindStatus" />
<result column="trial_type" jdbcType="TINYINT" property="trialType" />
<result column="his_type" jdbcType="TINYINT" property="hisType" />
<result column="wire_type" jdbcType="TINYINT" property="wireType" />
<result column="del_flag" jdbcType="TINYINT" property="delFlag" />
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate" />
<result column="created_by" jdbcType="INTEGER" property="createdBy" />
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate" />
<result column="updated_by" jdbcType="INTEGER" property="updatedBy" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, vehicle_id, sn, bind_status, trial_type, his_type, wire_type, del_flag, created_date,
created_by, updated_date, updated_by
</sql>
</mapper>
\ No newline at end of file
<?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="cn.com.glsx.app.modules.mapper.VehicleMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.app.modules.entity.Vehicle">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="workorder_id" jdbcType="INTEGER" property="workOrderId"/>
<result column="owner_name" jdbcType="VARCHAR" property="ownerName"/>
<result column="vin" jdbcType="VARCHAR" property="vin"/>
<result column="owner_sex" jdbcType="VARCHAR" property="ownerSex"/>
<result column="owner_tel" jdbcType="VARCHAR" property="ownerTel"/>
<result column="brand_id" jdbcType="INTEGER" property="brandId"/>
<result column="brand_name" jdbcType="VARCHAR" property="brandName"/>
<result column="sub_brand_id" jdbcType="INTEGER" property="subBrandId"/>
<result column="sub_brand_name" jdbcType="VARCHAR" property="subBrandName"/>
<result column="series_id" jdbcType="INTEGER" property="seriesId"/>
<result column="series_name" jdbcType="VARCHAR" property="seriesName"/>
<result column="type_id" jdbcType="INTEGER" property="typeId"/>
<result column="type_name" jdbcType="VARCHAR" property="typeName"/>
<result column="model_id" jdbcType="INTEGER" property="modelId"/>
<result column="model_name" jdbcType="VARCHAR" property="modelName"/>
<result column="config_id" jdbcType="INTEGER" property="configId"/>
<result column="config_desc" jdbcType="VARCHAR" property="configDesc"/>
<result column="color" jdbcType="VARCHAR" property="color"/>
<result column="inner_color" jdbcType="VARCHAR" property="innerColor"/>
<result column="license_plate" jdbcType="VARCHAR" property="licensePlate"/>
<result column="vehicle_type" jdbcType="TINYINT" property="vehicleType"/>
<result column="engine" jdbcType="VARCHAR" property="engine"/>
<result column="displacement" jdbcType="VARCHAR" property="displacement"/>
<result column="mileage" jdbcType="VARCHAR" property="mileage"/>
<result column="buy_type" jdbcType="INTEGER" property="buyType"/>
<result column="buy_date" jdbcType="DATE" property="buyDate"/>
<result column="description" jdbcType="VARCHAR" property="description"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="serve_type" jdbcType="TINYINT" property="serveType"/>
<result column="sale_manager" jdbcType="VARCHAR" property="saleManager"/>
<result column="sale_manager_phone" jdbcType="VARCHAR" property="saleManagerPhone"/>
<result column="validate_status" jdbcType="TINYINT" property="validateStatus"/>
<result column="vehicle_usages" jdbcType="TINYINT" property="vehicleUsages"/>
<result column="validate_info" jdbcType="VARCHAR" property="validateInfo"/>
<result column="registration_date" jdbcType="TIMESTAMP" property="registrationDate"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, workorder_id, owner_name, vin, owner_sex, owner_tel, brand_id, brand_name, sub_brand_id,
sub_brand_name, series_id, series_name, type_id, type_name, model_id, model_name,
config_id, config_desc, color, inner_color, license_plate, vehicle_type, engine,
displacement, mileage, buy_type, buy_date, description, remark, serve_type, sale_manager,
sale_manager_phone, validate_status, vehicle_usages, validate_info, registration_date,
del_flag, created_date, created_by, updated_date, updated_by
</sql>
<select id="search" resultType="cn.com.glsx.app.modules.model.VehicleDeviceDTO">
select tvd.id,
tv.id vid,
tv.vin,
tv.owner_name ownerName,
tvd.sn sns,
tv.created_by creatorId,
td.source,
td.device_type deviceType
from t_vehicle tv
left join t_vehicle_device tvd on tv.id = tvd.vehicle_id
left join t_device td on td.sn = tvd.sn
where tv.del_flag = 0 and tvd.del_flag = 0
and tvd.bind_status = 1
and tv.created_by is not null
<if test="term != null and term !=''">
and (
tv.owner_name like '%${term}%'
or tv.vin like '%${term}%'
or tvd.sn like '%${term}%'
)
</if>
order by tv.id desc
</select>
</mapper>
\ No newline at end of file
<?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="cn.com.glsx.app.modules.mapper.VehiclePermitMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.app.modules.entity.VehiclePermit">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="content_id" jdbcType="INTEGER" property="contentId" />
<result column="accorder_id" jdbcType="INTEGER" property="accorderId" />
<result column="receiver_id" jdbcType="INTEGER" property="receiverId" />
<result column="content_type" jdbcType="TINYINT" property="contentType" />
<result column="permit_type" jdbcType="VARCHAR" property="permitType" />
<result column="del_flag" jdbcType="TINYINT" property="delFlag" />
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate" />
<result column="created_by" jdbcType="INTEGER" property="createdBy" />
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate" />
<result column="updated_by" jdbcType="INTEGER" property="updatedBy" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, content_id, accorder_id, receiver_id, content_type, permit_type, del_flag, created_date,
created_by, updated_date, updated_by
</sql>
</mapper>
\ No newline at end of file
......@@ -10,11 +10,11 @@
###########init variable#############
JAVA_HOME="/app/soft/jdk1.8.0_144"
SERVER_PORT="8820"
SERVER_PORT="8995"
DUBBO_PORT=""
JMX_ARG="-Xmx1024m -Xms512m -Xmn256m"
MAIN="cn.com.glsx.Application"
SERVER_NAME="glsx-rest-admin"
SERVER_NAME="ne-shield-miniappserver"
###########end#######################
......
......@@ -7,7 +7,7 @@
# #
####################################
SERVER_NAME="glsx-rest-admin"
SERVER_NAME="ne-shield-miniappserver"
PID_DIR="/app/soft/java_project/pids"
cd `dirname $0`
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!