Ver código fonte

修改id类型

yaobo 7 anos atrás
pai
commit
9e29c0fd0e

+ 6 - 4
src/main/java/cn/efunbox/audio/controller/DeviceController.java

@@ -26,10 +26,10 @@ public class DeviceController {
     @Autowired
     DeviceService deviceService;
 
-    @RequestMapping(value = "/login" ,method = RequestMethod.POST)
-    public Map Login(@RequestParam int id, @RequestParam String token){
-        Device device = deviceService.Login(id, token);
+    @RequestMapping(value = "/token" ,method = RequestMethod.POST)
+    public Map Login(@RequestParam long id, @RequestParam String token){
         Map map = new HashMap<>();
+        Device device = deviceService.Login(id, token);
         if(device==null){
             map.put("code", ApiCode.INVALID_TOKEN.getCode());
             map.put("msg", ApiCode.INVALID_TOKEN.getCode());
@@ -38,6 +38,7 @@ public class DeviceController {
 
         map.put("code", ApiCode.OK.getCode());
         Map data = new HashMap<>();
+        data.put("id", device.getId());
         data.put("token", device.getTokenNew());
         map.put("data", data);
 
@@ -46,9 +47,9 @@ public class DeviceController {
 
     @RequestMapping(value = "/register" ,method = RequestMethod.POST)
     public Map Register(HttpServletRequest request){
+        Map map = new HashMap<>();
         String idChannel = request.getParameter("idChannel");
         String idDevice = request.getParameter("idDevice");
-        Map map = new HashMap<>();
         if(idChannel==null || idDevice==null){
             map.put("code", ApiCode.PARAMETER_ERROR.getCode());
             map.put("msg", ApiCode.PARAMETER_ERROR.getMessage());
@@ -63,6 +64,7 @@ public class DeviceController {
         if(device!=null){
             map.put("code", ApiCode.OK.getCode());
             Map data = new HashMap<>();
+            data.put("id", device.getId());
             data.put("token", device.getTokenNew());
             map.put("data", data);
         }

+ 1 - 1
src/main/java/cn/efunbox/audio/impl/DeviceServiceImpl.java

@@ -46,7 +46,7 @@ public class DeviceServiceImpl implements DeviceService {
     }
 
     @Override
-    public Device Login(int id, String token){
+    public Device Login(Long id, String token){
         Device device = deviceRepo.findById(id);
         if(device==null)
             return null;

+ 1 - 1
src/main/java/cn/efunbox/audio/repository/DeviceRepo.java

@@ -14,7 +14,7 @@ import java.util.List;
 @Repository
 public interface DeviceRepo extends JpaRepository<Device, Long> {
 
-    Device findById(int id);
+    Device findById(Long id);
 
     @Query("from Device d where d.idDevice=:idDevice")
     List<Device> findByDevice(@Param("idDevice")String idDevice);

+ 1 - 1
src/main/java/cn/efunbox/audio/service/DeviceService.java

@@ -11,6 +11,6 @@ public interface DeviceService {
 
     public Device Register(String idChannel, String idDevice);
 
-    public Device Login(int id, String token);
+    public Device Login(Long id, String token);
 
 }