Commit b6f402c7 authored by 张大伟's avatar 张大伟

添加新功能

parent 44fe55af
This diff is collapsed.
...@@ -214,7 +214,6 @@ ...@@ -214,7 +214,6 @@
<artifactId>spring-boot-starter-jdbc</artifactId> <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
...@@ -226,29 +225,6 @@ ...@@ -226,29 +225,6 @@
<version>4.5.2</version> <version>4.5.2</version>
</dependency> </dependency>
<dependency>
<groupId>com.adc</groupId>
<artifactId>cvdecs-service</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/lib/cvde-service.jar</systemPath>
</dependency>
<dependency>
<groupId>com.adc</groupId>
<artifactId>cvdecs-part</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/lib/cvdecs-part-1.0.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.adc</groupId>
<artifactId>cvdecs-setvec</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/lib/cvdecs-setvec-1.0.0.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>org.jvnet.hudson</groupId> <groupId>org.jvnet.hudson</groupId>
<artifactId>ganymed-ssh2</artifactId> <artifactId>ganymed-ssh2</artifactId>
......
package com.adc.da.znks.controller;
import com.adc.da.base.web.BaseController;
import com.adc.da.znks.entity.Gateway;
import com.adc.da.znks.entity.ResponseEntity;
import com.adc.da.znks.service.GatewayService;
import com.adc.da.znks.util.GenResponse;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author David
*/
@RestController
@RequestMapping("/api/gateway")
@Api(description = "| Gateway |")
public class GatewayController extends BaseController<Gateway> {
@Autowired
private GatewayService gatewayService;
@PostMapping("")
public ResponseEntity addGateway(Gateway gateway) {
return GenResponse.success();
}
}
package com.adc.da.znks.controller; package com.adc.da.znks.controller;
import com.adc.da.base.web.BaseController; import com.adc.da.base.web.BaseController;
import com.adc.da.util.http.PageInfo; import com.adc.da.znks.entity.ResponseEntity;
import com.adc.da.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import com.adc.da.znks.entity.User; import com.adc.da.znks.entity.User;
import com.adc.da.znks.page.UserPage;
import com.adc.da.znks.service.UserService; import com.adc.da.znks.service.UserService;
import com.adc.da.znks.util.GenResponse;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -16,9 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -16,9 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController @RestController
@RequestMapping("/api/entity/users") @RequestMapping("/api/entity/users")
@Api(description = "|User|") @Api(description = "|User|")
...@@ -30,54 +24,34 @@ public class UserController extends BaseController<User> { ...@@ -30,54 +24,34 @@ public class UserController extends BaseController<User> {
private static final Logger log = LoggerFactory.getLogger(UserController.class); private static final Logger log = LoggerFactory.getLogger(UserController.class);
// @ApiOperation(value = "|User|分页查询")
// @GetMapping("/page")
// public ResponseMessage<PageInfo<User>> page(UserPage page) throws Exception {
// List<User> rows = userService.queryByPage(page);
// return Result.success(getPageInfo(page.getPager(), rows));
// }
//
// @ApiOperation(value = "|User|查询")
// @GetMapping("")
// public ResponseMessage<List<User>> list(UserPage page) throws Exception {
// return Result.success(userService.queryByList(page));
// }
// @ApiOperation(value = "|User|详情")
// @GetMapping("/user/{id}")
// public ResponseMessage<User> find(@PathVariable Integer id) throws Exception {
// return Result.success(userService.selectByPrimaryKey(id));
// }
@ApiOperation(value = "|User|登录或者注册用户") @ApiOperation(value = "|User|登录或者注册用户")
@PostMapping(value = {"/loginOrRegisterUser"}) @PostMapping(value = {"/loginOrRegisterUser"})
public ResponseMessage<String> loginOrRegisterUser(@RequestBody User user) throws Exception { public ResponseEntity<String> loginOrRegisterUser(@RequestBody User user) throws Exception {
log.info("user: {}", user); log.info("user: {}", user);
String id = userService.loginOrRegister(user.getTemphone(), user.getPlainPassword()); String id = userService.loginOrRegister(user.getTemphone(), user.getPlainPassword());
if (id != null) { if (id != null) {
return Result.success(String.valueOf(HttpStatus.OK.value()), "登录或者注册用户成功", id); return GenResponse.success(String.valueOf(HttpStatus.OK.value()), "登录或者注册用户成功", id);
} else { } else {
return Result.error(String.valueOf(HttpStatus.OK.value()), "登录或者注册用户失败", id); return GenResponse.fail("登录或者注册用户失败");
} }
} }
@ApiOperation(value = "|User|登录或者注册用户")
@GetMapping(value = {"/isRegister"})
public ResponseEntity<Boolean> isRegister(String phoneNumber) {
boolean flag = userService.getUserByPhoneNumber(phoneNumber);
return GenResponse.success(String.valueOf(HttpStatus.OK.value()), "登录或者注册用户成功", flag);
}
@ApiOperation(value = "|User|更新密码") @ApiOperation(value = "|User|更新密码")
@PostMapping("/updatePassword") @PostMapping("/updatePassword")
public ResponseMessage<String> update(@RequestBody User user) throws Exception { public ResponseEntity<String> update(@RequestBody User user) throws Exception {
String id = userService.updatePassword(user); String id = userService.updatePassword(user);
if (id != null) { if (id != null) {
return Result.success(String.valueOf(HttpStatus.OK.value()), "更新密码成功", id); return GenResponse.success(String.valueOf(HttpStatus.OK.value()), "更新密码成功", id);
} else { } else {
return Result.error(String.valueOf(HttpStatus.OK.value()), "更新密码失败", id); return GenResponse.fail("更新密码失败");
} }
} }
// @ApiOperation(value = "|User|删除")
// @DeleteMapping("/user/{id}")
// public ResponseMessage delete(@PathVariable Integer id) throws Exception {
// userService.deleteByPrimaryKey(id);
// log.info("delete from tb_user where id = {}", id);
// return Result.success();
// }
} }
package com.adc.da.znks.dao;
import com.adc.da.base.dao.BaseDao;
import com.adc.da.znks.entity.Gateway;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface GatewayDao extends BaseDao<Gateway> {
/**
* 根据手机号查询网关相关信息
* @param phoneNumber
* @return
*/
Gateway getByPhoneNumber(String phoneNumber);
}
...@@ -4,6 +4,8 @@ package com.adc.da.znks.dao; ...@@ -4,6 +4,8 @@ package com.adc.da.znks.dao;
import com.adc.da.base.dao.BaseDao; import com.adc.da.base.dao.BaseDao;
import com.adc.da.znks.entity.User; import com.adc.da.znks.entity.User;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/** /**
* *
...@@ -13,4 +15,7 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -13,4 +15,7 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface UserDao extends BaseDao<User> { public interface UserDao extends BaseDao<User> {
@Select("SELECT * FROM tb_user WHERE tempphone = #{phoneNumber}")
User getUserByPhoneNumber(@Param("phoneNumber") String phoneNumber);
} }
package com.adc.da.znks.entity;
import com.adc.da.base.entity.BaseEntity;
/**
* @author David
*/
public class Gateway extends BaseEntity {
private int id;
private String macAddress;
private String ip;
private int userId;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getMacAddress() {
return macAddress;
}
public void setMacAddress(String macAddress) {
this.macAddress = macAddress;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
}
package com.adc.da.znks.entity;
/**
* <pre>
* author : David
* e-mail : 990860210@qq.com
* time : 2018/08/14
* desc :
* version: 1.0
* </pre>
*/
public class ResponseEntity<T> {
private String respCode;
private T data;
private boolean ok;
private String message;
public String getRespCode() {
return respCode;
}
public void setRespCode(String respCode) {
this.respCode = respCode;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public boolean isOk() {
return ok;
}
public void setOk(boolean ok) {
this.ok = ok;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public String toString() {
return "ResponseEntity{" +
"respCode='" + respCode + '\'' +
", data=" + data +
", ok=" + ok +
", message='" + message + '\'' +
'}';
}
}
package com.adc.da.znks.service;
import com.adc.da.base.dao.BaseDao;
import com.adc.da.base.service.BaseService;
import com.adc.da.znks.dao.GatewayDao;
import com.adc.da.znks.entity.Gateway;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* @author David
*/
@Service("userService")
@Transactional(value = "transactionManager", propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class GatewayService extends BaseService<Gateway, Integer> {
private static final Logger logger = LoggerFactory.getLogger(GatewayService.class);
@Autowired(required = false)
private GatewayDao dao;
@Override
public BaseDao<Gateway> getDao() {
return dao;
}
}
...@@ -35,10 +35,20 @@ public class UserService extends BaseService<User, String> { ...@@ -35,10 +35,20 @@ public class UserService extends BaseService<User, String> {
@Autowired(required = false) @Autowired(required = false)
private UserDao dao; private UserDao dao;
@Override
public UserDao getDao() { public UserDao getDao() {
return dao; return dao;
} }
public Boolean getUserByPhoneNumber(String phoneNumber) {
Boolean flag = false;
User user = dao.getUserByPhoneNumber(phoneNumber);
if(user != null) {
flag = true;
}
return flag;
}
/** /**
* update password * update password
**/ **/
......
package com.adc.da.znks.util;
import com.adc.da.znks.entity.ResponseEntity;
public class GenResponse {
public static <T> ResponseEntity<T> success(String respCode, String messgae, T data) {
ResponseEntity responseEntity = new ResponseEntity();
responseEntity.setData(data);
responseEntity.setOk(true);
responseEntity.setMessage(messgae);
responseEntity.setRespCode(respCode);
return responseEntity;
}
public static <T> ResponseEntity<T> success() {
ResponseEntity responseEntity = new ResponseEntity();
responseEntity.setOk(true);
return responseEntity;
}
public static ResponseEntity fail(String messgae) {
ResponseEntity responseEntity = new ResponseEntity();
responseEntity.setOk(false);
responseEntity.setMessage(messgae);
return responseEntity;
}
}
<?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="com.adc.da.znks.dao.GatewayDao">
<!-- Result Map-->
<resultMap id="BaseResultMap" type="com.adc.da.znks.entity.Gateway">
<id column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="mac_address" property="macAddress"/>
<result column="ip" property="ip"/>
</resultMap>
<!-- tb_position table all fields -->
<sql id="Base_Column_List">
id, user_id, mac_address, ip
</sql>
<select id="getByPhoneNumber" resultType="com.adc.da.znks.entity.Gateway">
select * from tb_gateway,tb_user
where tb_gateway.user_id = tb_user.id
and tb_user.temphone = #{phoneNumber}
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment