Commit bdf3b516 by ypenglv

Merge branch 'dev' of http://gitlab.polyhome.net/polysoft-nafmii/polysoft-parent into dev

# Conflicts:
#	nafmii-app/pom.xml
#	nafmii-app/src/main/java/org/nafmii/controller/UserController.java
#	nafmii-app/src/main/java/org/nafmii/service/UserService.java
#	nafmii-app/src/main/java/org/nafmii/service/impl/UserServiceImpl.java
#	nafmii-mbg/src/main/java/org/nafmii/nafmiimbg/model/CenterRole.java
#	nafmii-mbg/src/main/java/org/nafmii/nafmiimbg/model/CenterRoleExample.java
#	nafmii-mbg/src/main/resources/org/nafmii/nafmiimbg/mapper/CenterRoleMapper.xml
1 parent 95cbb269
package org.nafmii;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
......@@ -8,6 +9,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication(scanBasePackages={"org.nafmii","org.nafmii.exception"})
@EnableEurekaClient
@EnableFeignClients
@MapperScan("org.nafmii/**/mapper")
public class NafmiiAppApplication {
public static void main(String[] args) {
......
......@@ -3,11 +3,10 @@ package org.nafmii.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.nafmii.dto.user.RegisterDto;
import org.nafmii.response.Result;
import org.nafmii.response.ApiResponse;
import org.nafmii.service.UserService;
import org.nafmii.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*;
/**
......@@ -28,16 +27,16 @@ public class UserController {
@ApiOperation( value = "模拟用户登陆",notes = "模拟用户登陆")
@PostMapping("/login")
@ResponseBody
public Result<UserVO> login (){
Result<UserVO> login = userService.login();
public ApiResponse<UserVO> login (){
ApiResponse<UserVO> login = userService.login();
return login;
}
@ApiOperation( value = "app用户注册接口",notes = "app用户注册接口")
@PostMapping("/register")
@ResponseBody
public Result register (@RequestBody RegisterDto registerDto){
Result register = userService.register(registerDto);
public ApiResponse register (@RequestBody RegisterDto registerDto){
ApiResponse register = userService.register(registerDto);
return register;
}
......
package org.nafmii.mapper.user;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.nafmii.entity.user.AppUser;
import org.nafmii.entity.user.AppUserExample;
import java.util.List;
@Mapper
public interface AppUserMapper {
long countByExample(AppUserExample example);
......
package org.nafmii.service;
import org.nafmii.dto.user.RegisterDto;
import org.nafmii.response.Result;
import org.nafmii.response.ApiResponse;
import org.nafmii.vo.UserVO;
/**
......@@ -14,7 +14,7 @@ import org.nafmii.vo.UserVO;
*/
public interface UserService {
//模拟用户登陆接口
Result<UserVO> login();
ApiResponse<UserVO> login();
//app注册接口
Result register(RegisterDto registerDto);
ApiResponse register(RegisterDto registerDto);
}
......@@ -8,7 +8,7 @@ import org.nafmii.entity.user.AppUser;
import org.nafmii.enums.UserEnum;
import org.nafmii.exception.BusinessException;
import org.nafmii.mapper.user.AppUserMapper;
import org.nafmii.response.Result;
import org.nafmii.response.ApiResponse;
import org.nafmii.service.UserService;
import org.nafmii.utils.GuavaUtil;
import org.nafmii.utils.JwtUtils;
......@@ -18,6 +18,7 @@ import org.nafmii.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -34,15 +35,15 @@ import java.util.List;
@Slf4j
public class UserServiceImpl implements UserService {
@Autowired
@Resource
private AppUserMapper appUserMapper;
/**
* 模拟用户登陆
* @return
*/
@Override
public Result<UserVO> login() {
Result result = new Result();
public ApiResponse<UserVO> login() {
ApiResponse result = new ApiResponse();
//假设验证数据通过
UserVO userVO = new UserVO();
userVO.setPassword("zzz");
......@@ -75,7 +76,7 @@ public class UserServiceImpl implements UserService {
* @return
*/
@Override
public Result register(RegisterDto registerDto) {
public ApiResponse register(RegisterDto registerDto) {
//用户实体类
AppUser appUser = new AppUser();
appUser.setId(SnowFlakeUtil.nextId());
......@@ -106,8 +107,8 @@ public class UserServiceImpl implements UserService {
int i = appUserMapper.insertSelective(appUser);
if (i<0){
return Result.failed("新增失败");
return new ApiResponse().fail("新增失败");
}
return Result.success(null);
return new ApiResponse();
}
}
<?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="org.nafmii.nafmiimbg.mapper.AppUserMapper">
<resultMap id="BaseResultMap" type="org.nafmii.nafmiimbg.model.AppUser">
<mapper namespace="org.nafmii.mapper.user.AppUserMapper">
<resultMap id="BaseResultMap" type="org.nafmii.entity.user.AppUser">
<id column="ID" jdbcType="BIGINT" property="id" />
<result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
<result column="LOGIN_PWD" jdbcType="VARCHAR" property="loginPwd" />
......@@ -81,7 +81,7 @@
ID, USER_NAME, LOGIN_PWD, REAL_NAME, PHONE, BIRTHDAY, EMAIL, HEAD_PICTURE, NATIONALITY,
UNIT_NAME, OPEN_ID, FIGERPRINT_FALG, FACEID_FALG, CREATE_TIME, UPDATE_TIME, IS_ENABLE
</sql>
<select id="selectByExample" parameterType="org.nafmii.nafmiimbg.model.AppUserExample" resultMap="BaseResultMap">
<select id="selectByExample" parameterType="org.nafmii.entity.user.AppUserExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
......
......@@ -40,7 +40,10 @@ public class ApiResponse <T> implements Serializable {
this.data = data;
}
public ApiResponse<T> fail(String msg){
return new ApiResponse<>(-1,msg);
}
public long getStatus() {
return this.status;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!