package com.dsh.account.controller;
|
|
|
import com.dsh.account.entity.TAppUser;
|
import com.dsh.account.feignclient.other.SysLogClient;
|
import com.dsh.account.model.vo.userBenefitDetail.AppUserDetailsVo;
|
import com.dsh.account.model.vo.userBenefitDetail.BillingDetailsVo;
|
import com.dsh.account.model.vo.userBenefitDetail.IndexOfUserBenefirVo;
|
import com.dsh.account.service.TAppUserService;
|
import com.dsh.account.util.ResultUtil;
|
import com.dsh.account.util.TokenUtil;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.text.SimpleDateFormat;
|
|
/**
|
* 使用福利 控制器
|
*/
|
|
@RestController
|
@RequestMapping("")
|
public class UseBenefitsController {
|
|
|
@Autowired
|
private TAppUserService tauService;
|
|
@Autowired
|
private TokenUtil tokenUtil;
|
|
@Autowired
|
private SysLogClient slClient;
|
|
private final SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
@ResponseBody
|
@PostMapping("/api/useBenefit/indexOfAppUser")
|
@ApiOperation(value = "福利主页", tags = {"APP-使用福利"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
public ResultUtil<IndexOfUserBenefirVo> queryAppUserUser(){
|
try {
|
Integer appUserId = tokenUtil.getUserIdFormRedis();
|
if(null == appUserId){
|
return ResultUtil.tokenErr();
|
}
|
return ResultUtil.success(tauService.queryBenefitDetails(appUserId));
|
}catch (Exception e){
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/api/useBenefit/userDetails")
|
@ApiOperation(value = "用户个人信息", tags = {"APP-使用福利"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
public ResultUtil<AppUserDetailsVo> queryAppUserDetails(){
|
try {
|
AppUserDetailsVo detailsVo = new AppUserDetailsVo();
|
Integer appUserId = tokenUtil.getUserIdFormRedis();
|
if(null == appUserId){
|
return ResultUtil.tokenErr();
|
}
|
TAppUser tAppUser = tauService.getBaseMapper().selectById(appUserId);
|
if (null != tAppUser){
|
detailsVo.setUserImage(tAppUser.getHeadImg());
|
detailsVo.setUserName(tAppUser.getName());
|
detailsVo.setUserPhone(tAppUser.getPhone());
|
detailsVo.setSex(tAppUser.getGender() == 1 ? "男" : "女");
|
detailsVo.setBirthday(format1.format(tAppUser.getBirthday()));
|
detailsVo.setAddress(tAppUser.getProvince()+tAppUser.getCity());
|
detailsVo.setMemberLifespan(format1.format(tAppUser.getVipEndTime()));
|
}
|
return ResultUtil.success(detailsVo);
|
}catch (Exception e){
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/useBenefit/cancellation")
|
@ApiOperation(value = "个人信息-注销账号", tags = {"APP-使用福利"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
public ResultUtil cancellationAccount(){
|
try {
|
Integer appUserId = tokenUtil.getUserIdFormRedis();
|
if(null == appUserId){
|
return ResultUtil.tokenErr();
|
}
|
// 变更账号的状态为删除
|
tauService.cancellation(appUserId);
|
// 增加一条注销账号的日志
|
slClient.cancellation(appUserId);
|
// 删除redis中用户key
|
tokenUtil.logout();
|
return ResultUtil.success();
|
}catch (Exception e){
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/useBenefit/logOut")
|
@ApiOperation(value = "个人信息-退出登录", tags = {"APP-使用福利"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
public ResultUtil logOutAccount(){
|
try {
|
Integer appUserId = tokenUtil.getUserIdFormRedis();
|
if(null == appUserId){
|
return ResultUtil.tokenErr();
|
}
|
// 增加一条退出账号的日志
|
slClient.logOut(appUserId);
|
// 删除redis中用户key
|
tokenUtil.logout();
|
return ResultUtil.success();
|
}catch (Exception e){
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/useBenefit/userBilling")
|
@ApiOperation(value = "账单", tags = {"APP-使用福利"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
@ApiImplicitParam(value = "年月", name = "yearMonth", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "记录id", name = "recordId", required = true, dataType = "int"),
|
})
|
public ResultUtil<BillingDetailsVo> getUserBillingDetails(@RequestBody String yearMonth,@RequestBody Integer recordId){
|
try {
|
Integer appUserId = tokenUtil.getUserIdFormRedis();
|
if(null == appUserId){
|
return ResultUtil.tokenErr();
|
}
|
return ResultUtil.success(tauService.queryUserBillingDetails(yearMonth,recordId));
|
}catch (Exception e){
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
|
|
}
|