|
@@ -1,24 +1,24 @@
|
|
|
package com.miaxis.app.controller.user;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import com.miaxis.common.core.domain.entity.UserInfo;
|
|
|
-import io.swagger.annotations.*;
|
|
|
+import com.miaxis.common.core.controller.BaseController;
|
|
|
import com.miaxis.common.core.domain.Response;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import com.miaxis.common.core.domain.entity.UserInfo;
|
|
|
+import com.miaxis.common.utils.SecurityUtils;
|
|
|
+import com.miaxis.user.service.IUserInfoService;
|
|
|
+import com.miaxis.user.vo.UserVipInfoVO;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
-import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
-import com.miaxis.common.annotation.Log;
|
|
|
-import com.miaxis.common.core.controller.BaseController;
|
|
|
-import com.miaxis.common.enums.BusinessTypeEnum;
|
|
|
-import com.miaxis.user.service.IUserInfoService;
|
|
|
-import com.miaxis.common.core.page.ResponsePageInfo;
|
|
|
+
|
|
|
+import java.security.KeyFactory;
|
|
|
+import java.security.PrivateKey;
|
|
|
+import java.security.Signature;
|
|
|
+import java.security.spec.PKCS8EncodedKeySpec;
|
|
|
+import java.util.Base64;
|
|
|
|
|
|
/**
|
|
|
* 【用户】Controller
|
|
@@ -33,46 +33,49 @@ public class UserInfoController extends BaseController{
|
|
|
@Autowired
|
|
|
private IUserInfoService userInfoService;
|
|
|
|
|
|
- /**
|
|
|
- * 查询用户列表
|
|
|
- */
|
|
|
-
|
|
|
- @GetMapping("/list")
|
|
|
- @ApiOperation("查询用户列表")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
|
|
|
- @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
|
|
|
- })
|
|
|
- public ResponsePageInfo<UserInfo> list(@ModelAttribute UserInfo userInfo){
|
|
|
- startPage();
|
|
|
- List<UserInfo> list = userInfoService.selectUserInfoList(userInfo);
|
|
|
- return toResponsePageInfo(list);
|
|
|
- }
|
|
|
+ private String rsaPrivateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMLNHTgsyYOXDJVF8r4qCyb+8Uw4" +
|
|
|
+ "XKq8aThAhUIaPYIop+HJxETGbXk3e0o46i4iOX8RTv0i3jmhL6W0mSxy9ismfXPP7VtKgEt6VnMm" +
|
|
|
+ "ufsrQ2kcXyRsKmuwUd3rTH5gniXwLdIPF8V5ujiSq94nPHok1krDMWbss8Q7lcH2kQFHAgMBAAEC" +
|
|
|
+ "gYBh6Eu2TzRdMg79+7EciO8gA2Tt5SoWGipcPnl7lsqxX5O5dPpzgrPFB/CshlyVIVh6mA12Rw8g" +
|
|
|
+ "MfZLt7CA2asFdgGHfgCvMjsCnL2U1Nf1QFnsnGXmFXeVUvdy7XPILi75rVyOEAw+/f3KzjSA7B3w" +
|
|
|
+ "URE8M2QlIUcjm8LLyCVC4QJBAO+taJH7pVZGVn2upsOk14X08QU0lsQ7ufe/8VXe+IujwGMh34U6" +
|
|
|
+ "BHGV7grodtA7TvQ3mDggQLHB2+IxBWdDCrcCQQDQEVMI+CD7afEyN9rK/MAJwevtxNaTyEd1bhKw" +
|
|
|
+ "t6WKr1YbAdUz2gvnpCQjD1Gqt5yXHKu279msX9W4euXePG3xAkBUCYZn4UdIp+L9sHZSlQLoukik" +
|
|
|
+ "HZtbdOGw58Ez7blSJPl5CNB5wyz5sqtDcdzvCEyXvsKFs3FbonB5r9yIJ26jAkEAugGC1dXcxmWj" +
|
|
|
+ "dl1wf18M3qw6GkmJ+ntlRpmso8bJev3cYDB3RO99DQw0MhOT0qZqmrzK1bP+SJc0HMPhk5c6QQJA" +
|
|
|
+ "WRLIxmeM/P9X2mDjMrI46Wnn27QoKGgYSHdPxmLD0y7NUytf5HyCsY2vhA9FZcnikibax7SwzC/B" +
|
|
|
+ "D7yOXFAy/Q==";
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取用户详细信息
|
|
|
*/
|
|
|
- @GetMapping(value = "/{id}")
|
|
|
- @ApiOperation("获取用户详细信息")
|
|
|
- public Response<UserInfo> getInfo(
|
|
|
- @ApiParam(name = "id", value = "用户参数", required = true)
|
|
|
- @PathVariable("id") Long id
|
|
|
- ){
|
|
|
- return Response.success(userInfoService.getById(id));
|
|
|
+ @GetMapping(value = "/vipInfo")
|
|
|
+ @ApiOperation("vip信息")
|
|
|
+ public Response<UserVipInfoVO> getInfo(
|
|
|
+ ) throws Exception {
|
|
|
+ UserInfo student = SecurityUtils.getLoginUser().getStudent();
|
|
|
+ UserInfo dbUserInfo = userInfoService.getById(student.getId());
|
|
|
+ UserVipInfoVO userVipInfoVO = new UserVipInfoVO();
|
|
|
+ userVipInfoVO.setIsVip(dbUserInfo.getIsVip());
|
|
|
+ userVipInfoVO.setOpenid(dbUserInfo.getOpenid());
|
|
|
+ userVipInfoVO.setSign(getSign(dbUserInfo.getIsVip(),dbUserInfo.getOpenid()));
|
|
|
+ return Response.success(userVipInfoVO);
|
|
|
}
|
|
|
|
|
|
+ private String getSign(Integer isVip, String openid) throws Exception {
|
|
|
+ String str = openid+isVip;
|
|
|
+ // 进行签名服务
|
|
|
+ Signature signature = Signature.getInstance("SHA256withRSA");
|
|
|
+ KeyFactory kf = KeyFactory.getInstance("RSA");
|
|
|
+ PrivateKey privateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(Base64.getDecoder().decode(rsaPrivateKey)));
|
|
|
+ signature.initSign(privateKey);
|
|
|
+ signature.update(str.getBytes("UTF-8"));
|
|
|
+ byte[] signedData = signature.sign();
|
|
|
+ return Base64.getEncoder().encodeToString(signedData);
|
|
|
+
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 修改用户
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('user:info:edit')")
|
|
|
- @Log(title = "用户", businessType = BusinessTypeEnum.UPDATE)
|
|
|
- @PutMapping
|
|
|
- @ApiOperation("修改用户")
|
|
|
- public Response<Integer> edit(@RequestBody UserInfo userInfo){
|
|
|
- return toResponse(userInfoService.updateById(userInfo) ? 1 : 0);
|
|
|
}
|
|
|
|
|
|
|