Authored by fangyeqing

ADD:add get userinfo interface

... ... @@ -12,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.nio.file.AccessDeniedException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
... ...
... ... @@ -38,7 +38,7 @@ public class TokenController {
//@Sign
@RequestMapping(method = RequestMethod.POST)
@ApiOperation(value = "登录")
@ApiOperation(value = "用户登录接口")
public ResponseEntity<ResultModel> login(HttpServletRequest request,@RequestParam String username, @RequestParam String password,
@RequestParam String sign,@RequestParam long t,@RequestParam int type) {
Assert.notNull(username, "username can not be empty");
... ...
... ... @@ -6,8 +6,10 @@ import com.xkl.authorization.annotation.Sign;
import com.xkl.authorization.manager.ITokenManager;
import com.xkl.config.ResultStatus;
import com.xkl.domain.User;
import com.xkl.domain.XklMemberEntity;
import com.xkl.model.ResultModel;
import com.xkl.repository.UserRepository;
import com.xkl.repository.XklMemberRespository;
import com.xkl.security.AntiXSS;
import com.wordnik.swagger.annotations.ApiImplicitParam;
import com.wordnik.swagger.annotations.ApiImplicitParams;
... ... @@ -34,11 +36,13 @@ public class UserInfoController {
private UserRepository userRepository;
@Autowired
private ITokenManager tokenManager;
@Autowired
private XklMemberRespository xklMemberRespository;
@AntiXSS
//@Sign
@RequestMapping(method = RequestMethod.POST)
@ApiOperation(value = "注册")
@ApiOperation(value = "用户注册接口")
public ResponseEntity<ResultModel> register(HttpServletRequest request,@RequestParam String username, @RequestParam String password,
@RequestParam String sign,@RequestParam long t,@RequestParam int type) {
Assert.notNull(username, "username can not be empty");
... ... @@ -51,7 +55,10 @@ public class UserInfoController {
String salt= SecurityTool.genSalt();
String pass=SecurityTool.getPassword(username,password,salt);
user = new User();
user.setMember_id(123);
/**
* TODO:暂时都为1
*/
user.setMember_id(1);
user.setUsername(username);
user.setPassword(pass);
user.setSalt(salt);
... ... @@ -66,7 +73,7 @@ public class UserInfoController {
@AntiXSS
//@Sign
@RequestMapping(method = RequestMethod.PUT)
@ApiOperation(value = "修改用户密码")
@ApiOperation(value = "用户密码修改接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
})
... ... @@ -84,13 +91,15 @@ public class UserInfoController {
@RequestMapping(method = RequestMethod.GET)
@Authorization
@ApiOperation(value = "获取用户id")
@ApiOperation(value = "个人信息查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
})
public ResponseEntity<ResultModel> getUserNickName(@CurrentUser User user) {
public ResponseEntity<ResultModel> getUserInfo(HttpServletRequest request,@CurrentUser User user,
@RequestParam String sign,@RequestParam long t,@RequestParam int type) {
long member_id=user.getMember_id();
return new ResponseEntity<>(ResultModel.ok(member_id), HttpStatus.OK);
XklMemberEntity xklMemberEntity=xklMemberRespository.findOne(member_id);
return new ResponseEntity<>(ResultModel.ok(xklMemberEntity), HttpStatus.OK);
}
}
... ...
package com.xkl.domain;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Date;
... ... @@ -7,12 +9,13 @@ import java.sql.Date;
/**
* Created by win7 on 2016/11/20.
*/
@Data
@Entity
@Table(name = "xkl_member", schema = "hanhe_test", catalog = "")
public class XklMemberEntity {
@Id
@Column(name = "id")
private int id;
private long id;
@Basic
@Column(name = "name")
private String name;
... ...
package com.xkl.repository;
import com.xkl.domain.XklMemberEntity;
import org.springframework.data.repository.CrudRepository;
/**
* Created by win7 on 2016/11/20.
*/
public interface XklMemberRespository extends CrudRepository<XklMemberEntity, Long> {
}
... ...