Authored by zhaoyue

Merge branch 'zhaoyue-dev4' into 'master'

Zhaoyue dev4



See merge request !66
@@ -11,10 +11,12 @@ import com.xkl.domain.User; @@ -11,10 +11,12 @@ import com.xkl.domain.User;
11 import com.xkl.domain.XklAdminEntity; 11 import com.xkl.domain.XklAdminEntity;
12 import com.xkl.domain.XklMemberEntity; 12 import com.xkl.domain.XklMemberEntity;
13 import com.xkl.model.ResultModel; 13 import com.xkl.model.ResultModel;
  14 +import com.xkl.model.UsrInfoModelForUSPIH;
14 import com.xkl.repository.UserRepository; 15 import com.xkl.repository.UserRepository;
15 import com.xkl.repository.XklMemberRespository; 16 import com.xkl.repository.XklMemberRespository;
16 import com.xkl.security.AntiXSS; 17 import com.xkl.security.AntiXSS;
17 import com.xkl.security.SecurityTool; 18 import com.xkl.security.SecurityTool;
  19 +import com.xkl.tools.DatetimeTools;
18 import org.springframework.beans.factory.annotation.Autowired; 20 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.http.HttpStatus; 21 import org.springframework.http.HttpStatus;
20 import org.springframework.http.ResponseEntity; 22 import org.springframework.http.ResponseEntity;
@@ -25,6 +27,8 @@ import org.springframework.web.bind.annotation.RequestParam; @@ -25,6 +27,8 @@ import org.springframework.web.bind.annotation.RequestParam;
25 import org.springframework.web.bind.annotation.RestController; 27 import org.springframework.web.bind.annotation.RestController;
26 28
27 import javax.servlet.http.HttpServletRequest; 29 import javax.servlet.http.HttpServletRequest;
  30 +import java.text.SimpleDateFormat;
  31 +import java.util.Date;
28 32
29 /** 33 /**
30 * @author zhaoyue 34 * @author zhaoyue
@@ -34,7 +38,9 @@ import javax.servlet.http.HttpServletRequest; @@ -34,7 +38,9 @@ import javax.servlet.http.HttpServletRequest;
34 public class UserAccountController { 38 public class UserAccountController {
35 @Autowired 39 @Autowired
36 private UserRepository userRepository; 40 private UserRepository userRepository;
37 - 41 + @Autowired
  42 + private XklMemberRespository memberRespository;
  43 + private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//小写的mm表示的是分钟
38 44
39 @RequestMapping(method = RequestMethod.GET) 45 @RequestMapping(method = RequestMethod.GET)
40 @AntiXSS 46 @AntiXSS
@@ -47,7 +53,17 @@ public class UserAccountController { @@ -47,7 +53,17 @@ public class UserAccountController {
47 if (user == null) {//用户未找到 53 if (user == null) {//用户未找到
48 return new ResponseEntity<>(ResultModel.error(ResultStatus.USER_NOT_FOUND), HttpStatus.OK); 54 return new ResponseEntity<>(ResultModel.error(ResultStatus.USER_NOT_FOUND), HttpStatus.OK);
49 } 55 }
50 - return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK); 56 + XklMemberEntity xklMemberEntity = memberRespository.findOne((long) user.getMemberId());
  57 + Date birthDate = new Date();
  58 + try {
  59 + birthDate = sdf.parse(xklMemberEntity.getBirthDate());
  60 + } catch (Exception e) {
  61 + e.printStackTrace();
  62 + }
  63 + int age = DatetimeTools.getAge(birthDate, new Date());
  64 + UsrInfoModelForUSPIH usrInfo = new UsrInfoModelForUSPIH(xklMemberEntity.getName(), xklMemberEntity.isSex() ?
  65 + 1 : 0, age);
  66 + return new ResponseEntity<>(ResultModel.ok(usrInfo), HttpStatus.OK);
51 } 67 }
52 68
53 69
  1 +package com.xkl.model;
  2 +
  3 +import lombok.Data;
  4 +
  5 +/**
  6 + * USPIH用户验证时返回的用户信息
  7 + */
  8 +@Data
  9 +public class UsrInfoModelForUSPIH {
  10 + private String name;
  11 + private int sex;
  12 + private int age;
  13 +
  14 + public UsrInfoModelForUSPIH(String name, int sex, int age) {
  15 + this.name = name;
  16 + this.sex = sex;
  17 + this.age = age;
  18 + }
  19 +}