Merge pull request '自助机接口' (#110) from cgt into master
All checks were successful
continuous-integration/drone Build is passing
All checks were successful
continuous-integration/drone Build is passing
Reviewed-on: #110
This commit is contained in:
commit
ade0f2eb94
@ -1,29 +0,0 @@
|
||||
package cn.iocoder.yudao.module.datacenter.controller.app.asset;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.LoginBody;
|
||||
import cn.iocoder.yudao.module.datacenter.service.asset.AssetLoginService;
|
||||
import cn.iocoder.yudao.module.datacenter.service.asset.AssetService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Tag(name = "设备机")
|
||||
@RestController
|
||||
@RequestMapping("/assetLogin")
|
||||
@Validated
|
||||
public class AssetLoginApi {
|
||||
@Resource
|
||||
private AssetLoginService assetLoginService;
|
||||
@PostMapping("/login")
|
||||
@Operation(summary = "获得所有设备名称和数量")
|
||||
public CommonResult login(@RequestBody LoginBody loginBody) {
|
||||
System.out.println("datacenter loginBody:::::::::::::::::::" + loginBody);
|
||||
return assetLoginService.login(loginBody);
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package cn.iocoder.yudao.module.datacenter.controller.app.asset;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.LoginBody;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient("ticket-server")
|
||||
public interface AssetLoginClientApi {
|
||||
@PostMapping("/rpc-api/ticket/assetLoginLog/login")
|
||||
@Operation(summary = "设备登陆")
|
||||
CommonResult login(@RequestBody LoginBody loginBody);
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package cn.iocoder.yudao.module.datacenter.controller.app.asset;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.Heartbeat;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.LoginBody;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.PassengerInformation;
|
||||
import cn.iocoder.yudao.module.datacenter.service.asset.AssetLoginService;
|
||||
import cn.iocoder.yudao.module.datacenter.service.asset.HeartBeatService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Tag(name = "设备机")
|
||||
@RestController
|
||||
@RequestMapping("/asset/heartbeat")
|
||||
@Validated
|
||||
public class HeartBeatApi {
|
||||
@Resource
|
||||
private HeartBeatService heartBeatService;
|
||||
@PostMapping
|
||||
@Operation(summary = "设备状态上报")
|
||||
public CommonResult receiveHeartbeat(@RequestBody Heartbeat heartbeat) {
|
||||
return heartBeatService.receiveHeartbeat(heartbeat);
|
||||
}
|
||||
|
||||
@PostMapping("/doPassengerInformation")
|
||||
public CommonResult<String> doPassengerInformation(@RequestBody PassengerInformation passengerInformation){
|
||||
return heartBeatService.doPassengerInformation(passengerInformation);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package cn.iocoder.yudao.module.datacenter.controller.app.asset;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.Heartbeat;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.LoginBody;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.PassengerInformation;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient("ticket-server")
|
||||
public interface HeartBeatClientApi {
|
||||
@PostMapping("/rpc-api/ticket/heartbeat")
|
||||
@Operation(summary = "设备状态上报")
|
||||
CommonResult receiveHeartbeat(@RequestBody Heartbeat heartbeat);
|
||||
|
||||
@PostMapping("/rpc-api/ticket/heartbeat/doPassengerInformation")
|
||||
@Operation(summary = "旅客信息上报")
|
||||
CommonResult doPassengerInformation(@RequestBody PassengerInformation passengerInformation);
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package cn.iocoder.yudao.module.datacenter.controller.app.asset.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Heartbeat {
|
||||
//设备ID
|
||||
private String deviceId;
|
||||
//事件类型(1.设备上线 -1.故障发生 0.设备离线)
|
||||
private String eventType;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package cn.iocoder.yudao.module.datacenter.controller.app.asset.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Document("heartbeatlog")
|
||||
@Data
|
||||
public class HeartbeatLog {
|
||||
private String id;
|
||||
private String dataId;
|
||||
private String assetname;
|
||||
private String assettype;
|
||||
private String assettypename;
|
||||
private long lastFeedbackTime;
|
||||
private String requesttext;
|
||||
private String returntext;
|
||||
private List<Map<String, Object>> dataMapList;
|
||||
private String loginTime;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package cn.iocoder.yudao.module.datacenter.controller.app.asset.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LoginBody {
|
||||
//设备id
|
||||
private String deviceId;
|
||||
//识别码
|
||||
private String identificationCode;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package cn.iocoder.yudao.module.datacenter.controller.app.asset.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LoginResult {
|
||||
// private String userId;
|
||||
// private String username;
|
||||
private String token;
|
||||
// private String userType;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package cn.iocoder.yudao.module.datacenter.controller.app.asset.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
@Document("passengerInformation")
|
||||
@Data
|
||||
public class PassengerInformation {
|
||||
//编号
|
||||
private String id;
|
||||
//设备id
|
||||
private String deviceId;
|
||||
//旅客姓名
|
||||
private String name;
|
||||
//旅客身份证
|
||||
private String idCard;
|
||||
//提交时间
|
||||
private String commitTime;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package cn.iocoder.yudao.module.datacenter.service.asset;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.LoginBody;
|
||||
|
||||
public interface AssetLoginService {
|
||||
CommonResult login(LoginBody loginBody);
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package cn.iocoder.yudao.module.datacenter.service.asset;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.AssetLoginClientApi;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.LoginBody;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class AssetLoginServiceImpl implements AssetLoginService {
|
||||
@Resource
|
||||
private AssetLoginClientApi assetLoginClientApi;
|
||||
|
||||
@Override
|
||||
public CommonResult login(LoginBody loginBody) {
|
||||
return assetLoginClientApi.login(loginBody);
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package cn.iocoder.yudao.module.datacenter.service.asset;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.Heartbeat;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.PassengerInformation;
|
||||
|
||||
public interface HeartBeatService {
|
||||
public CommonResult<String> receiveHeartbeat(Heartbeat heartbeat);
|
||||
public CommonResult<String> doPassengerInformation(PassengerInformation passengerInformation);
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package cn.iocoder.yudao.module.datacenter.service.asset;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.HeartBeatClientApi;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.Heartbeat;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.asset.vo.PassengerInformation;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class HeartBeatServiceImpl implements HeartBeatService {
|
||||
@Resource
|
||||
private HeartBeatClientApi heartBeatClientApi;
|
||||
|
||||
@Override
|
||||
public CommonResult receiveHeartbeat(Heartbeat heartbeat) {
|
||||
return heartBeatClientApi.receiveHeartbeat(heartbeat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult doPassengerInformation(PassengerInformation passengerInformation) {
|
||||
return heartBeatClientApi.doPassengerInformation(passengerInformation);
|
||||
}
|
||||
}
|
@ -2,12 +2,14 @@ package cn.iocoder.yudao.module.ticket;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
*/
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients(basePackages = "cn.iocoder.yudao.module.ticket.controller.admin.clients")
|
||||
public class TicketingServerApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TicketingServerApplication.class, args);
|
||||
|
@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.module.ticket.controller.admin.clients;
|
||||
|
||||
import cn.iocoder.yudao.module.ticket.controller.admin.clients.vo.AuthLoginReqVO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient("system-server")
|
||||
public interface LoginClient {
|
||||
@PostMapping("/admin-api/system/auth/login")
|
||||
ResponseEntity<String> getToken(@RequestBody AuthLoginReqVO reqVO, @RequestHeader("Tenant-Id") String tenantId);
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package cn.iocoder.yudao.module.ticket.controller.admin.clients.vo;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.AssertTrue;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@Schema(description = "管理后台 - 账号密码登录 Request VO,如果登录并绑定社交用户,需要传递 social 开头的参数")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AuthLoginReqVO {
|
||||
|
||||
@Schema(description = "账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudaoyuanma")
|
||||
@NotEmpty(message = "登录账号不能为空")
|
||||
@Length(min = 4, max = 16, message = "账号长度为 4-16 位")
|
||||
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao")
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||
private String password;
|
||||
|
||||
// ========== 图片验证码相关 ==========
|
||||
|
||||
@Schema(description = "验证码,验证码开启时,需要传递", requiredMode = Schema.RequiredMode.REQUIRED,
|
||||
example = "PfcH6mgr8tpXuMWFjvW6YVaqrswIuwmWI5dsVZSg7sGpWtDCUbHuDEXl3cFB1+VvCC/rAkSwK8Fad52FSuncVg==")
|
||||
@NotEmpty(message = "验证码不能为空", groups = CodeEnableGroup.class)
|
||||
private String captchaVerification;
|
||||
|
||||
// ========== 绑定社交登录时,需要传递如下参数 ==========
|
||||
|
||||
@Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
@InEnum(SocialTypeEnum.class)
|
||||
private Integer socialType;
|
||||
|
||||
@Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private String socialCode;
|
||||
|
||||
@Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62")
|
||||
private String socialState;
|
||||
|
||||
/**
|
||||
* 开启验证码的 Group
|
||||
*/
|
||||
public interface CodeEnableGroup {}
|
||||
|
||||
@AssertTrue(message = "授权码不能为空")
|
||||
public boolean isSocialCodeValid() {
|
||||
return socialType == null || StrUtil.isNotEmpty(socialCode);
|
||||
}
|
||||
|
||||
@AssertTrue(message = "授权 state 不能为空")
|
||||
public boolean isSocialState() {
|
||||
return socialType == null || StrUtil.isNotEmpty(socialState);
|
||||
}
|
||||
|
||||
}
|
@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/heart")
|
||||
@RequestMapping("/ticket/heart")
|
||||
public class HeartbeatController {
|
||||
@Resource
|
||||
private HeartbeatService heartbeatService;
|
||||
|
@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.annotation.security.PermitAll;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@ -34,7 +35,8 @@ public class LoginController {
|
||||
@Resource
|
||||
private LoginService loginService;
|
||||
|
||||
@PostMapping("/login")
|
||||
@PostMapping("/ticket/login")
|
||||
@PermitAll
|
||||
public CommonResult login(@RequestBody LoginBody loginBody) {
|
||||
return loginService.login(loginBody);
|
||||
}
|
||||
|
@ -4,16 +4,25 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.ticket.api.assetLoginLog.vo.AssetLoginLogVO;
|
||||
import cn.iocoder.yudao.module.ticket.api.heartbeat.vo.AssetVO;
|
||||
import cn.iocoder.yudao.module.ticket.controller.admin.clients.LoginClient;
|
||||
import cn.iocoder.yudao.module.ticket.controller.admin.clients.vo.AuthLoginReqVO;
|
||||
import cn.iocoder.yudao.module.ticket.controller.admin.login.domain.LoginBody;
|
||||
import cn.iocoder.yudao.module.ticket.controller.admin.login.domain.LoginResult;
|
||||
import cn.iocoder.yudao.module.ticket.dal.dataobject.asset.AssetDO;
|
||||
import cn.iocoder.yudao.module.ticket.dal.mongodb.login.LoginRepository;
|
||||
import cn.iocoder.yudao.module.ticket.dal.mongodb.login.SysuserRepository;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
@ -28,6 +37,8 @@ public class LoginServiceImpl implements LoginService {
|
||||
// private JwtUtils jwtUtils;
|
||||
@Autowired
|
||||
private LoginRepository loginRepository;
|
||||
@Resource
|
||||
private LoginClient loginClient;
|
||||
|
||||
@Override
|
||||
public CommonResult login(LoginBody loginBody) {
|
||||
@ -66,9 +77,20 @@ public class LoginServiceImpl implements LoginService {
|
||||
map.put("identificationCode", loginBody.getIdentificationCode());
|
||||
//返回登录成功信息
|
||||
LoginResult result = new LoginResult();
|
||||
// result.setUserId(sysuser.getId());
|
||||
// result.setUsername(sysuser.getUsername());
|
||||
// result.setToken(JWTUtil.sign(map));
|
||||
AuthLoginReqVO loginReqVO = new AuthLoginReqVO();
|
||||
loginReqVO.setPassword("mt@6688");
|
||||
loginReqVO.setUsername("admin");
|
||||
ResponseEntity<String> response = loginClient.getToken(loginReqVO,"1");
|
||||
String responseBody = response.getBody();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
JsonNode jsonNode = objectMapper.readTree(responseBody);
|
||||
System.out.println("accessToken:::::::::" + jsonNode.path("data").path("accessToken"));
|
||||
result.setToken(jsonNode.path("data").path("accessToken").asText());
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 用正则提取 accessToken
|
||||
loginLog.setStatus("1");
|
||||
loginLog.setLoginRemark("登录成功");
|
||||
loginRepository.save(loginLog);
|
||||
|
Loading…
Reference in New Issue
Block a user