Authored by fangyeqing

ADD:add get userinfo interface

@@ -12,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -12,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
13 13
14 import javax.servlet.http.HttpServletRequest; 14 import javax.servlet.http.HttpServletRequest;
15 -import java.nio.file.AccessDeniedException;  
16 import java.util.Collections; 15 import java.util.Collections;
17 import java.util.List; 16 import java.util.List;
18 import java.util.Map; 17 import java.util.Map;
@@ -38,7 +38,7 @@ public class TokenController { @@ -38,7 +38,7 @@ public class TokenController {
38 38
39 //@Sign 39 //@Sign
40 @RequestMapping(method = RequestMethod.POST) 40 @RequestMapping(method = RequestMethod.POST)
41 - @ApiOperation(value = "登录") 41 + @ApiOperation(value = "用户登录接口")
42 public ResponseEntity<ResultModel> login(HttpServletRequest request,@RequestParam String username, @RequestParam String password, 42 public ResponseEntity<ResultModel> login(HttpServletRequest request,@RequestParam String username, @RequestParam String password,
43 @RequestParam String sign,@RequestParam long t,@RequestParam int type) { 43 @RequestParam String sign,@RequestParam long t,@RequestParam int type) {
44 Assert.notNull(username, "username can not be empty"); 44 Assert.notNull(username, "username can not be empty");
@@ -6,8 +6,10 @@ import com.xkl.authorization.annotation.Sign; @@ -6,8 +6,10 @@ import com.xkl.authorization.annotation.Sign;
6 import com.xkl.authorization.manager.ITokenManager; 6 import com.xkl.authorization.manager.ITokenManager;
7 import com.xkl.config.ResultStatus; 7 import com.xkl.config.ResultStatus;
8 import com.xkl.domain.User; 8 import com.xkl.domain.User;
  9 +import com.xkl.domain.XklMemberEntity;
9 import com.xkl.model.ResultModel; 10 import com.xkl.model.ResultModel;
10 import com.xkl.repository.UserRepository; 11 import com.xkl.repository.UserRepository;
  12 +import com.xkl.repository.XklMemberRespository;
11 import com.xkl.security.AntiXSS; 13 import com.xkl.security.AntiXSS;
12 import com.wordnik.swagger.annotations.ApiImplicitParam; 14 import com.wordnik.swagger.annotations.ApiImplicitParam;
13 import com.wordnik.swagger.annotations.ApiImplicitParams; 15 import com.wordnik.swagger.annotations.ApiImplicitParams;
@@ -34,11 +36,13 @@ public class UserInfoController { @@ -34,11 +36,13 @@ public class UserInfoController {
34 private UserRepository userRepository; 36 private UserRepository userRepository;
35 @Autowired 37 @Autowired
36 private ITokenManager tokenManager; 38 private ITokenManager tokenManager;
  39 + @Autowired
  40 + private XklMemberRespository xklMemberRespository;
37 41
38 @AntiXSS 42 @AntiXSS
39 //@Sign 43 //@Sign
40 @RequestMapping(method = RequestMethod.POST) 44 @RequestMapping(method = RequestMethod.POST)
41 - @ApiOperation(value = "注册") 45 + @ApiOperation(value = "用户注册接口")
42 public ResponseEntity<ResultModel> register(HttpServletRequest request,@RequestParam String username, @RequestParam String password, 46 public ResponseEntity<ResultModel> register(HttpServletRequest request,@RequestParam String username, @RequestParam String password,
43 @RequestParam String sign,@RequestParam long t,@RequestParam int type) { 47 @RequestParam String sign,@RequestParam long t,@RequestParam int type) {
44 Assert.notNull(username, "username can not be empty"); 48 Assert.notNull(username, "username can not be empty");
@@ -51,7 +55,10 @@ public class UserInfoController { @@ -51,7 +55,10 @@ public class UserInfoController {
51 String salt= SecurityTool.genSalt(); 55 String salt= SecurityTool.genSalt();
52 String pass=SecurityTool.getPassword(username,password,salt); 56 String pass=SecurityTool.getPassword(username,password,salt);
53 user = new User(); 57 user = new User();
54 - user.setMember_id(123); 58 + /**
  59 + * TODO:暂时都为1
  60 + */
  61 + user.setMember_id(1);
55 user.setUsername(username); 62 user.setUsername(username);
56 user.setPassword(pass); 63 user.setPassword(pass);
57 user.setSalt(salt); 64 user.setSalt(salt);
@@ -66,7 +73,7 @@ public class UserInfoController { @@ -66,7 +73,7 @@ public class UserInfoController {
66 @AntiXSS 73 @AntiXSS
67 //@Sign 74 //@Sign
68 @RequestMapping(method = RequestMethod.PUT) 75 @RequestMapping(method = RequestMethod.PUT)
69 - @ApiOperation(value = "修改用户密码") 76 + @ApiOperation(value = "用户密码修改接口")
70 @ApiImplicitParams({ 77 @ApiImplicitParams({
71 @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), 78 @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
72 }) 79 })
@@ -84,13 +91,15 @@ public class UserInfoController { @@ -84,13 +91,15 @@ public class UserInfoController {
84 91
85 @RequestMapping(method = RequestMethod.GET) 92 @RequestMapping(method = RequestMethod.GET)
86 @Authorization 93 @Authorization
87 - @ApiOperation(value = "获取用户id") 94 + @ApiOperation(value = "个人信息查询接口")
88 @ApiImplicitParams({ 95 @ApiImplicitParams({
89 @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), 96 @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
90 }) 97 })
91 - public ResponseEntity<ResultModel> getUserNickName(@CurrentUser User user) { 98 + public ResponseEntity<ResultModel> getUserInfo(HttpServletRequest request,@CurrentUser User user,
  99 + @RequestParam String sign,@RequestParam long t,@RequestParam int type) {
92 long member_id=user.getMember_id(); 100 long member_id=user.getMember_id();
93 - return new ResponseEntity<>(ResultModel.ok(member_id), HttpStatus.OK); 101 + XklMemberEntity xklMemberEntity=xklMemberRespository.findOne(member_id);
  102 + return new ResponseEntity<>(ResultModel.ok(xklMemberEntity), HttpStatus.OK);
94 } 103 }
95 104
96 } 105 }
1 package com.xkl.domain; 1 package com.xkl.domain;
2 2
  3 +import lombok.Data;
  4 +
3 import javax.persistence.*; 5 import javax.persistence.*;
4 import java.io.Serializable; 6 import java.io.Serializable;
5 import java.sql.Date; 7 import java.sql.Date;
@@ -7,12 +9,13 @@ import java.sql.Date; @@ -7,12 +9,13 @@ import java.sql.Date;
7 /** 9 /**
8 * Created by win7 on 2016/11/20. 10 * Created by win7 on 2016/11/20.
9 */ 11 */
  12 +@Data
10 @Entity 13 @Entity
11 @Table(name = "xkl_member", schema = "hanhe_test", catalog = "") 14 @Table(name = "xkl_member", schema = "hanhe_test", catalog = "")
12 public class XklMemberEntity { 15 public class XklMemberEntity {
13 @Id 16 @Id
14 @Column(name = "id") 17 @Column(name = "id")
15 - private int id; 18 + private long id;
16 @Basic 19 @Basic
17 @Column(name = "name") 20 @Column(name = "name")
18 private String name; 21 private String name;
  1 +package com.xkl.repository;
  2 +
  3 +import com.xkl.domain.XklMemberEntity;
  4 +import org.springframework.data.repository.CrudRepository;
  5 +
  6 +/**
  7 + * Created by win7 on 2016/11/20.
  8 + */
  9 +public interface XklMemberRespository extends CrudRepository<XklMemberEntity, Long> {
  10 +
  11 +}