权限校验

This commit is contained in:
ly19960718 2021-01-27 17:50:37 +08:00
parent 5a5cd82fdd
commit 6fcd8e958d
13 changed files with 304 additions and 367 deletions

View File

@ -2,6 +2,16 @@ package cn.com.tenlion.controller.apis.carduser;
import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO; import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO;
import cn.com.tenlion.pojo.vos.carduser.CardUserVO; import cn.com.tenlion.pojo.vos.carduser.CardUserVO;
import cn.com.tenlion.service.carduser.ICardUserService;
import cn.com.tenlion.util.check.CheckRequestBodyAnnotation;
import cn.com.tenlion.util.exception.RemoveException;
import cn.com.tenlion.util.exception.SearchException;
import cn.com.tenlion.util.page.ListPage;
import cn.com.tenlion.util.result.ErrorResult;
import cn.com.tenlion.util.result.SuccessResult;
import cn.com.tenlion.util.result.SuccessResultData;
import cn.com.tenlion.util.result.SuccessResultList;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.AbstractController; import org.springframework.web.servlet.mvc.AbstractController;
@ -20,10 +30,8 @@ import java.util.Map;
@RestController @RestController
@RequestMapping("/carduser") @RequestMapping("/carduser")
public class CardUserController { public class CardUserController {
/*
@Autowired @Autowired
private ICardUserService cardUserService;*/ private ICardUserService cardUserService;
/*
@ApiOperation(value = "新增用户表", notes = "新增用户表接口") @ApiOperation(value = "新增用户表", notes = "新增用户表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("savecarduser") @PostMapping("savecarduser")
@ -63,7 +71,7 @@ public class CardUserController {
return cardUserService.getCardUserById(cardUserId); return cardUserService.getCardUserById(cardUserId);
} }
@ApiOperation(value = "用户表列表", notes = "用户表列表接口") /* @ApiOperation(value = "用户表列表", notes = "用户表列表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listcarduser") @GetMapping("listcarduser")
public List<CardUserDTO> listCardUser() throws SearchException { public List<CardUserDTO> listCardUser() throws SearchException {
@ -93,9 +101,9 @@ public class CardUserController {
SuccessResultData<Integer> countCardUser() throws SearchException { SuccessResultData<Integer> countCardUser() throws SearchException {
Map<String, Object> params = requestParams(); Map<String, Object> params = requestParams();
return cardUserService.countCardUser(params); return cardUserService.countCardUser(params);
} }*/
@ApiOperation(value = "当前用户id信息", notes = "当前用户id信息接口") /* @ApiOperation(value = "当前用户id信息", notes = "当前用户id信息接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("getcurrentuseridinfo") @GetMapping("getcurrentuseridinfo")
public CurrentUserIdInfoDTO getCurrentUserIdInfo() { public CurrentUserIdInfoDTO getCurrentUserIdInfo() {

View File

@ -1,25 +1,38 @@
/*
package cn.com.tenlion.controller.app.apis.carduser; package cn.com.tenlion.controller.app.apis.carduser;
import cn.com.tenlion.accesstokenmanager.AccessTokenManager;
import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO; import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO;
import cn.com.tenlion.pojo.dtos.weixinresult.WeiXinAuthResult;
import cn.com.tenlion.pojo.vos.carduser.CardUserVO; import cn.com.tenlion.pojo.vos.carduser.CardUserVO;
import cn.com.tenlion.service.carduser.ICardUserService; import cn.com.tenlion.service.carduser.ICardUserService;
import cn.com.tenlion.util.AesUtil;
import cn.com.tenlion.util.check.CheckRequestBodyAnnotation;
import cn.com.tenlion.util.cons.ISystemConstant;
import cn.com.tenlion.util.exception.ParamsException;
import cn.com.tenlion.util.exception.RemoveException;
import cn.com.tenlion.util.exception.SearchException;
import cn.com.tenlion.util.result.ErrorResult;
import cn.com.tenlion.util.result.SuccessResult;
import cn.com.tenlion.util.result.SuccessResultData;
import cn.com.tenlion.util.vx.WxApiUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.AbstractController; import cn.com.tenlion.controller.AbstractController;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
*/
/** /**
* @ClassName: CardUserAppController * @ClassName: CardUserAppController
* @Description: 用户表 * @Description: 用户表
* @Author: WenG * @Author: LiuY
* @Date: 2021-01-26 10:55 * @Date: 2021-01-26 10:55
* @Version: 1.0 * @Version: 1.0
**//* **/
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "用户表接口") @Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "用户表接口")
@RestController @RestController
@ -29,85 +42,95 @@ public class CardUserAppController extends AbstractController {
@Autowired @Autowired
private ICardUserService cardUserService; private ICardUserService cardUserService;
@ApiOperation(value = "新增用户表", notes = "新增用户表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header")
}) /**
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) * 小程序登录
@PostMapping("savecarduser") * @return
@CheckRequestBodyAnnotation * @throws Exception
public SuccessResult saveCardUser(@RequestHeader("token") String token, @RequestBody CardUserVO cardUserVO) throws Exception { */
return cardUserService.saveCardUserByToken(token, cardUserVO); @GetMapping("weiXinLoginBySmallRoutine"+ISystemConstant.RELEASE_SUFFIX+"/{vxCode}")
public SuccessResult weiXinLoginBySmallRoutine (@PathVariable("vxCode") String vxCode) throws Exception {
WxApiUtil wxapi = new WxApiUtil();
WeiXinAuthResult austerest = wxapi.weiXinLoginGetAuth(vxCode, ISystemConstant.VX_APP_ID, ISystemConstant.VX_APP_SECRET, ISystemConstant.VX_GRANT_TYPE);
if (austerest == null) {
throw new ParamsException("系统异常-1");
}
if (!austerest.getErrcode().equals("0")) {
throw new ParamsException("系统异常-2");
}
CardUserDTO carduserdto = cardUserService.getCardUserByVxOpenId(austerest.getOpenid());
String userId;
CardUserDTO userdto = null;
if (carduserdto != null) {
userId = carduserdto.getCardUserId();
userdto = carduserdto;
} else {
CardUserVO carduservo = new CardUserVO();
carduservo.setVxOpenId(austerest.getOpenid());
carduservo.setVxUnionId(austerest.getUnionid());
userId = cardUserService.saveCardUserReturnId(carduservo);
userdto = cardUserService.getCardUserByVxOpenId(userId);
}
String token = AesUtil.aesCommonEncoder(ISystemConstant.APP_TOKEN_AES_KEY, userId);
AccessTokenManager.getInstance().setKey(token, userdto);
AccessTokenManager.getInstance().updateLastActivityTime(token);
return new SuccessResultData<>(token);
} }
@ApiOperation(value = "删除用户表(id列表)", notes = "删除用户表(id列表)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "ids", value = "ID列表用下划线分隔", paramType = "path", example = "1_2_3")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@DeleteMapping("removecarduser/{ids}")
public SuccessResult removeCardUser(@RequestHeader("token") String token, @PathVariable("ids") String ids) throws RemoveException {
return cardUserService.removeCardUserByToken(token, ids);
}
@ApiOperation(value = "修改用户表", notes = "修改用户表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "cardUserId", value = "用户表ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("updatecarduser/{cardUserId}")
@CheckRequestBodyAnnotation
public SuccessResult updateCardUser(@RequestHeader("token") String token, @PathVariable("cardUserId") String cardUserId, @RequestBody CardUserVO cardUserVO) throws Exception {
return cardUserService.updateCardUserByToken(token, cardUserId, cardUserVO);
}
@ApiOperation(value = "用户表详情(通过ID)", notes = "用户表详情(通过ID)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "cardUserId", value = "用户表ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("getcarduserbyid/{cardUserId}")
public CardUserDTO getCardUserById(@RequestHeader("token") String token, @PathVariable("cardUserId") String cardUserId) throws SearchException {
return cardUserService.getCardUserById(cardUserId);
}
@ApiOperation(value = "用户表列表", notes = "用户表列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listcarduser")
public List<CardUserDTO> listCardUser(@RequestHeader("token") String token) throws SearchException {
Map<String, Object> params = requestParams();
return cardUserService.listCardUser(params);
}
@ApiOperation(value = "用户表分页列表", notes = "用户表分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpagecarduser")
public SuccessResultList<List<CardUserDTO>> listPageCardUser(@RequestHeader("token") String token, ListPage page) throws SearchException {
Map<String, Object> params = requestParams();
page.setParams(params);
return cardUserService.listPageCardUser(page);
}
@ApiOperation(value = "用户表统计", notes = "用户表统计接口") // @ApiOperation(value = "新增用户表", notes = "新增用户表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) // @ApiImplicitParams({
@GetMapping("countcarduser") // @ApiImplicitParam(name = "token", value = "token", paramType = "header")
SuccessResultData<Integer> countCardUser() throws SearchException { // })
Map<String, Object> params = requestParams(); // @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
return cardUserService.countCardUser(params); // @PostMapping("savecarduser")
} // @CheckRequestBodyAnnotation
// public SuccessResult saveCardUser(@RequestHeader("token") String token, @RequestBody CardUserVO cardUserVO) throws Exception {
// return cardUserService.saveCardUserByToken(token, cardUserVO);
// }
//
// @ApiOperation(value = "删除用户表(id列表)", notes = "删除用户表(id列表)接口")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "token", value = "token", paramType = "header"),
// @ApiImplicitParam(name = "ids", value = "ID列表用下划线分隔", paramType = "path", example = "1_2_3")
// })
// @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
// @DeleteMapping("removecarduser/{ids}")
// public SuccessResult removeCardUser(@RequestHeader("token") String token, @PathVariable("ids") String ids) throws RemoveException {
// return cardUserService.removeCardUserByToken(token, ids);
// }
//
// @ApiOperation(value = "修改用户表", notes = "修改用户表接口")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "token", value = "token", paramType = "header"),
// @ApiImplicitParam(name = "cardUserId", value = "用户表ID", paramType = "path")
// })
// @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
// @PutMapping("updatecarduser/{cardUserId}")
// @CheckRequestBodyAnnotation
// public SuccessResult updateCardUser(@RequestHeader("token") String token, @PathVariable("cardUserId") String cardUserId, @RequestBody CardUserVO cardUserVO) throws Exception {
// return cardUserService.updateCardUserByToken(token, cardUserId, cardUserVO);
// }
//
// @ApiOperation(value = "用户表详情(通过ID)", notes = "用户表详情(通过ID)接口")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "token", value = "token", paramType = "header"),
// @ApiImplicitParam(name = "cardUserId", value = "用户表ID", paramType = "path")
// })
// @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
// @GetMapping("getcarduserbyid/{cardUserId}")
// public CardUserDTO getCardUserById(@RequestHeader("token") String token, @PathVariable("cardUserId") String cardUserId) throws SearchException {
// return cardUserService.getCardUserById(cardUserId);
// }
}*/
}

View File

@ -19,7 +19,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
@RestController @RestController
@RequestMapping("app/datadictionary") @RequestMapping("/app/datadictionary")
public class DataDictionaryAppController extends AbstractController { public class DataDictionaryAppController extends AbstractController {
@Autowired @Autowired

View File

@ -1,41 +0,0 @@
package cn.com.tenlion.controller.app.apis.weixinlogin;
import cn.com.tenlion.pojo.dtos.weixinlogin.WeiXinLoginResult;
import cn.com.tenlion.service.weixinlogin.IWeiXinLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* 微信登录
* @version 1.0
* @author LY
* @date 2021/1/26 11:08
*/
@RestController
@RequestMapping("/weixinapplogin")
public class WeiXinLoginAppController {
@Autowired
private IWeiXinLoginService weiXinLoginService;
/**
* 小程序登录
* @return
* @throws Exception
*/
@GetMapping("weiXinLoginBySmallRoutine/{vxCode}")
public WeiXinLoginResult weiXinLoginBySmallRoutine (@PathVariable("vxCode") String vxCode) throws Exception{
return weiXinLoginService.weiXinLoginBySmallRoutine(vxCode);
}
}

View File

@ -1,7 +1,10 @@
package cn.com.tenlion.dao.carduser; package cn.com.tenlion.dao.carduser;
import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO; import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO;
import cn.com.tenlion.util.exception.RemoveException;
import cn.com.tenlion.util.exception.SaveException;
import cn.com.tenlion.util.exception.SearchException;
import cn.com.tenlion.util.exception.UpdateException;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@ -17,63 +20,73 @@ import java.util.Map;
@Repository @Repository
public interface ICardUserDao { public interface ICardUserDao {
/**
* 根据微信open_id 获取用户信息
* @param params
* @return
* @throws SearchException
*/
CardUserDTO getCardUserByVxOpenId(Map<String,Object> params) throws SearchException;
/** /**
* 新增用户表 * 新增用户表
* *
* @param params * @param params
* @throws Exception * @throws SaveException
*/ */
void saveCardUser(Map<String, Object> params) throws Exception; void saveCardUser(Map<String, Object> params) throws SaveException;
/** /**
* 删除用户表 * 删除用户表
* *
* @param params * @param params
* @throws Exception * @throws RemoveException
*/ */
void removeCardUser(Map<String, Object> params) throws Exception; void removeCardUser(Map<String, Object> params) throws RemoveException;
/** /**
* 删除用户表物理 * 删除用户表物理
* *
* @param params * @param params
* @throws Exception * @throws RemoveException
*/ */
void deleteCardUser(Map<String, Object> params) throws Exception; void deleteCardUser(Map<String, Object> params) throws RemoveException;
/** /**
* 修改用户表 * 修改用户表
* *
* @param params * @param params
* @throws Exception * @throws UpdateException
*/ */
void updateCardUser(Map<String, Object> params) throws Exception; void updateCardUser(Map<String, Object> params) throws UpdateException;
/** /**
* 用户表详情 * 用户表详情
* *
* @param params * @param params
* @return * @return
* @throws Exception * @throws SearchException
*/ */
CardUserDTO getCardUser(Map<String, Object> params) throws Exception; CardUserDTO getCardUser(Map<String, Object> params) throws SearchException;
/** /**
* 用户表列表 * 用户表列表
* *
* @param params * @param params
* @return * @return
* @throws Exception * @throws SearchException
*/ */
List<CardUserDTO> listCardUser(Map<String, Object> params) throws Exception; List<CardUserDTO> listCardUser(Map<String, Object> params) throws SearchException;
/** /**
* 用户表统计 * 用户表统计
* *
* @param params * @param params
* @return * @return
* @throws Exception * @throws SearchException
*/ */
Integer countCardUser(Map<String, Object> params) throws Exception; Integer countCardUser(Map<String, Object> params) throws SearchException;
} }

View File

@ -32,6 +32,11 @@ public class CardUserDTO {
*/ */
private String VxOpenId; private String VxOpenId;
/**
* 账号最后活动时间用于token过期判断
*/
private long lastActivityTime;
public String getCardUserId() { public String getCardUserId() {
return cardUserId == null ? "" : cardUserId.trim(); return cardUserId == null ? "" : cardUserId.trim();
} }
@ -72,5 +77,11 @@ public class CardUserDTO {
this.VxOpenId = VxOpenId; this.VxOpenId = VxOpenId;
} }
public long getLastActivityTime() {
return lastActivityTime;
}
public void setLastActivityTime(long lastActivityTime) {
this.lastActivityTime = lastActivityTime;
}
} }

View File

@ -1,123 +1,112 @@
/*
package cn.com.tenlion.service.carduser; package cn.com.tenlion.service.carduser;
import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SaveException;
import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList;
import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO; import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO;
import cn.com.tenlion.pojo.vos.carduser.CardUserVO; import cn.com.tenlion.pojo.vos.carduser.CardUserVO;
import cn.com.tenlion.util.exception.RemoveException;
import cn.com.tenlion.util.exception.SearchException;
import cn.com.tenlion.util.page.ListPage;
import cn.com.tenlion.util.result.SuccessResult;
import cn.com.tenlion.util.result.SuccessResultData;
import cn.com.tenlion.util.result.SuccessResultList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
*/
/** /**
* @ClassName: ICardUserService * @ClassName: ICardUserService
* @Description: 用户表 * @Description: 用户表
* @Author: WenG * @Author: WenG
* @Date: 2021-01-26 10:55 * @Date: 2021-01-26 10:55
* @Version: 1.0 * @Version: 1.0
**//* **/
public interface ICardUserService { public interface ICardUserService {
*/ /**
/** * 根据微信open_id获取用户详情
* @param vxOpenId
* @return
* @throws SearchException
*/
CardUserDTO getCardUserByVxOpenId(String vxOpenId) throws SearchException;
/**
* 新增用户表 * 新增用户表
* *
* @param cardUserVO * @param cardUserVO
* @return * @return
* @throws Exception * @throws Exception
*//* */
SuccessResult saveCardUser(CardUserVO cardUserVO) throws Exception; SuccessResult saveCardUser(CardUserVO cardUserVO) throws Exception;
*/ /**
/**
* 新增用户表(APP) * 新增用户表(APP)
* *
* @param token * @param token
* @param cardUserVO * @param cardUserVO
* @return * @return
* @throws Exception * @throws Exception
*//* */
SuccessResult saveCardUserByToken(String token, CardUserVO cardUserVO) throws Exception; SuccessResult saveCardUserByToken(String token, CardUserVO cardUserVO) throws Exception;
*/ /**
/**
* 新增用户表 * 新增用户表
* *
* @param cardUserVO * @param cardUserVO
* @return cardUserId * @return cardUserId
* @throws Exception * @throws Exception
*//* */
String saveCardUserReturnId(CardUserVO cardUserVO) throws Exception; String saveCardUserReturnId(CardUserVO cardUserVO) throws Exception;
*/ /**
/**
* 新增用户表(APP) * 新增用户表(APP)
* *
* @param token * @param token
* @param cardUserVO * @param cardUserVO
* @return cardUserId * @return cardUserId
* @throws Exception * @throws Exception
*//* */
String saveCardUserByTokenReturnId(String token, CardUserVO cardUserVO) throws Exception; String saveCardUserByTokenReturnId(String token, CardUserVO cardUserVO) throws Exception;
*/ /**
/**
* 删除用户表 * 删除用户表
* *
* @param ids * @param ids
* @return * @return
* @throws RemoveException * @throws RemoveException
*//* */
SuccessResult removeCardUser(String ids) throws RemoveException; SuccessResult removeCardUser(String ids) throws RemoveException;
*/ /**
/**
* 删除用户表物理删除 * 删除用户表物理删除
* *
* @param ids * @param ids
* @throws RemoveException * @throws RemoveException
*//* */
void deleteCardUser(String ids) throws RemoveException; void deleteCardUser(String ids) throws RemoveException;
*/ /**
/**
* 删除用户表(APP) * 删除用户表(APP)
* *
* @param token * @param token
* @param ids * @param ids
* @return * @return
* @throws RemoveException * @throws RemoveException
*//* */
SuccessResult removeCardUserByToken(String token, String ids) throws RemoveException; SuccessResult removeCardUserByToken(String token, String ids) throws RemoveException;
*/ /**
/**
* 修改用户表 * 修改用户表
* *
* @param cardUserId * @param cardUserId
* @param cardUserVO * @param cardUserVO
* @return * @return
* @throws Exception * @throws Exception
*//* */
SuccessResult updateCardUser(String cardUserId, CardUserVO cardUserVO) throws Exception; SuccessResult updateCardUser(String cardUserId, CardUserVO cardUserVO) throws Exception;
*/ /**
/**
* 修改用户表(APP) * 修改用户表(APP)
* *
* @param token * @param token
@ -125,63 +114,52 @@ public interface ICardUserService {
* @param cardUserVO * @param cardUserVO
* @return * @return
* @throws Exception * @throws Exception
*//* */
SuccessResult updateCardUserByToken(String token, String cardUserId, CardUserVO cardUserVO) throws Exception; SuccessResult updateCardUserByToken(String token, String cardUserId, CardUserVO cardUserVO) throws Exception;
*/ /**
/**
* 用户表详情(通过ID) * 用户表详情(通过ID)
* *
* @param cardUserId * @param cardUserId
* @return * @return
* @throws SearchException * @throws SearchException
*//* */
CardUserDTO getCardUserById(String cardUserId) throws SearchException; CardUserDTO getCardUserById(String cardUserId) throws SearchException;
*/ /**
/**
* 用户表列表 * 用户表列表
* *
* @param params * @param params
* @return * @return
* @throws SearchException * @throws SearchException
*//* */
List<CardUserDTO> listCardUser(Map<String, Object> params) throws SearchException; List<CardUserDTO> listCardUser(Map<String, Object> params) throws SearchException;
*/ /**
/**
* 用户表分页列表 * 用户表分页列表
* *
* @param page * @param page
* @return * @return
* @throws SearchException * @throws SearchException
*//* */
SuccessResultList<List<CardUserDTO>> listPageCardUser(ListPage page) throws SearchException; SuccessResultList<List<CardUserDTO>> listPageCardUser(ListPage page) throws SearchException;
*/ /**
/**
* 用户表统计 * 用户表统计
* *
* @param params * @param params
* @return * @return
* @throws SearchException * @throws SearchException
*//* */
Integer countNumberCardUser(Map<String, Object> params) throws SearchException; Integer countNumberCardUser(Map<String, Object> params) throws SearchException;
*/ /**
/**
* 用户表统计 * 用户表统计
* *
* @param params * @param params
* @return * @return
* @throws SearchException * @throws SearchException
*//* */
SuccessResultData<Integer> countCardUser(Map<String, Object> params) throws SearchException; SuccessResultData<Integer> countCardUser(Map<String, Object> params) throws SearchException;
}*/ }

View File

@ -1,32 +1,54 @@
/*
package cn.com.tenlion.service.carduser.impl; package cn.com.tenlion.service.carduser.impl;
import cn.com.tenlion.dao.carduser.ICardUserDao; import cn.com.tenlion.dao.carduser.ICardUserDao;
import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO;
import cn.com.tenlion.pojo.vos.carduser.CardUserVO;
import cn.com.tenlion.service.AbstractService;
import cn.com.tenlion.service.carduser.ICardUserService; import cn.com.tenlion.service.carduser.ICardUserService;
import cn.com.tenlion.util.base.DateUtil;
import cn.com.tenlion.util.base.HashMapUtil;
import cn.com.tenlion.util.base.UUIDUtil;
import cn.com.tenlion.util.exception.RemoveException;
import cn.com.tenlion.util.exception.SearchException;
import cn.com.tenlion.util.page.ListPage;
import cn.com.tenlion.util.result.SuccessResult;
import cn.com.tenlion.util.result.SuccessResultData;
import cn.com.tenlion.util.result.SuccessResultList;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
*/
/** /**
* @ClassName: CardUserServiceImpl * @ClassName: CardUserServiceImpl
* @Description: 用户表 * @Description: 用户表
* @Author: WenG * @Author: WenG
* @Date: 2021-01-26 10:55 * @Date: 2021-01-26 10:55
* @Version: 1.0 * @Version: 1.0
**//* **/
@Service @Service
public class CardUserServiceImpl implements ICardUserService { public class CardUserServiceImpl extends AbstractService implements ICardUserService {
@Autowired @Autowired
private ICardUserDao cardUserDao; private ICardUserDao cardUserDao;
*/ /**
/* @Override * 根据微信open_id获取用户详情
* @param vxOpenId
* @return
* @throws SearchException
*/
public CardUserDTO getCardUserByVxOpenId(String vxOpenId) throws SearchException{
Map<String, Object> params = new HashMap<>();
params.put("vxOpenId", vxOpenId);
return cardUserDao.getCardUserByVxOpenId(params);
}
@Override
public SuccessResult saveCardUser(CardUserVO cardUserVO) throws Exception { public SuccessResult saveCardUser(CardUserVO cardUserVO) throws Exception {
saveCardUserInfo(null, cardUserVO); saveCardUserInfo(null, cardUserVO);
return new SuccessResult(); return new SuccessResult();
@ -48,42 +70,35 @@ public class CardUserServiceImpl implements ICardUserService {
return saveCardUserInfoReturnId(token, cardUserVO); return saveCardUserInfoReturnId(token, cardUserVO);
} }
*//* /**
*/
/**
* 新增用户表 * 新增用户表
* *
* @param token * @param token
* @param cardUserVO * @param cardUserVO
* @throws Exception * @throws Exception
*//* */
*/
/*
private void saveCardUserInfo(String token, CardUserVO cardUserVO) throws Exception { private void saveCardUserInfo(String token, CardUserVO cardUserVO) throws Exception {
saveCardUserInfoReturnId(token, cardUserVO); saveCardUserInfoReturnId(token, cardUserVO);
} }
*//* /**
*/
/**
* 新增用户表 * 新增用户表
* *
* @param token * @param token
* @param cardUserVO * @param cardUserVO
* @return cardUserId * @return cardUserId
* @throws Exception * @throws Exception
*//* */
*/
/*
private String saveCardUserInfoReturnId(String token, CardUserVO cardUserVO) throws Exception { private String saveCardUserInfoReturnId(String token, CardUserVO cardUserVO) throws Exception {
String cardUserId = UUIDUtil.getUUID(); String cardUserId = UUIDUtil.getUUID();
Map<String, Object> params = HashMapUtil.beanToMap(cardUserVO); Map<String, Object> params = HashMapUtil.beanToMap(cardUserVO);
params.put("cardUserId", cardUserId); params.put("cardUserId", cardUserId);
if (token != null) { params.put("gmtCreate", DateUtil.getTime());
/* if (token != null) {
setSaveInfo(token, params); setSaveInfo(token, params);
} else { } else {
setSaveInfo(params); setSaveInfo(params);
} }*/
cardUserDao.saveCardUser(params); cardUserDao.saveCardUser(params);
return cardUserId; return cardUserId;
} }
@ -100,29 +115,26 @@ public class CardUserServiceImpl implements ICardUserService {
return new SuccessResult(); return new SuccessResult();
} }
*//* /**
*/
/**
* 删除用户表 * 删除用户表
* *
* @param token * @param token
* @param ids * @param ids
*//* */
*/
/*
private void removeCardUserInfo(String token, String ids) { private void removeCardUserInfo(String token, String ids) {
Map<String, Object> params = getHashMap(3); Map<String, Object> params = getHashMap(3);
params.put("cardUserIds", Arrays.asList(ids.split("_"))); params.put("cardUserIds", Arrays.asList(ids.split("_")));
if (token != null) { params.put("gmtModified",DateUtil.getTime());
/* if (token != null) {
setUpdateInfo(token, params); setUpdateInfo(token, params);
} else { } else {
setUpdateInfo(params); setUpdateInfo(params);
} }*/
cardUserDao.removeCardUser(params); cardUserDao.removeCardUser(params);
} }
@Override @Override
public void deleteCardUser(String ids) throws RemoveException { public void deleteCardUser(String ids) throws RemoveException{
Map<String, Object> params = getHashMap(3); Map<String, Object> params = getHashMap(3);
params.put("cardUserIds", Arrays.asList(ids.split("_"))); params.put("cardUserIds", Arrays.asList(ids.split("_")));
cardUserDao.deleteCardUser(params); cardUserDao.deleteCardUser(params);
@ -140,25 +152,22 @@ public class CardUserServiceImpl implements ICardUserService {
return new SuccessResult(); return new SuccessResult();
} }
*//* /**
*/
/**
* 修改用户表 * 修改用户表
* *
* @param token * @param token
* @param cardUserId * @param cardUserId
* @param cardUserVO * @param cardUserVO
*//* */
*/
/*
private void updateCardUserInfo(String token, String cardUserId, CardUserVO cardUserVO) throws Exception { private void updateCardUserInfo(String token, String cardUserId, CardUserVO cardUserVO) throws Exception {
Map<String, Object> params = HashMapUtil.beanToMap(cardUserVO); Map<String, Object> params = HashMapUtil.beanToMap(cardUserVO);
params.put("cardUserId", cardUserId); params.put("cardUserId", cardUserId);
if (token != null) { params.put("gmtModified",DateUtil.getTime());
/* if (token != null) {
setUpdateInfo(token, params); setUpdateInfo(token, params);
} else { } else {
setUpdateInfo(params); setUpdateInfo(params);
} }*/
cardUserDao.updateCardUser(params); cardUserDao.updateCardUser(params);
} }
@ -191,7 +200,6 @@ public class CardUserServiceImpl implements ICardUserService {
@Override @Override
public SuccessResultData<Integer> countCardUser(Map<String, Object> params) throws SearchException { public SuccessResultData<Integer> countCardUser(Map<String, Object> params) throws SearchException {
return new SuccessResultData<>(countNumberCardUser(params)); return new SuccessResultData<>(countNumberCardUser(params));
}*//* }
}
}*/

View File

@ -1,25 +0,0 @@
package cn.com.tenlion.service.weixinlogin;
import cn.com.tenlion.pojo.dtos.weixinlogin.WeiXinLoginResult;
import com.alibaba.fastjson.JSONObject;
/**
* TODO
* @version 1.0
* @author LY
* @date 2021/1/26 11:19
*/
public interface IWeiXinLoginService {
/**
* 微信小程序登录
* @param code
* @return
* @throws Exception
*/
WeiXinLoginResult weiXinLoginBySmallRoutine(String code) throws Exception;
}

View File

@ -1,72 +0,0 @@
package cn.com.tenlion.service.weixinlogin.impl;
import cn.com.tenlion.pojo.dtos.weixinlogin.WeiXinLoginResult;
import cn.com.tenlion.service.weixinlogin.IWeiXinLoginService;
import cn.com.tenlion.util.AesUtil;
import cn.com.tenlion.util.WxUtil;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* 微信登录
* @version 1.0
* @author LY
* @date 2021/1/26 11:20
*/
@Service
public class WeiXinLoginServiceImpl implements IWeiXinLoginService {
/**微信小程序获取session key 接口*/
private static String VX_SMALL_ROUTINE_SESSION_KEY = "https://api.weixin.qq.com/sns/jscode2session";
/**小程序 appId*/
private static String APP_ID = "wxa49a60262e53d305 ";
/**小程序 appSecret*/
private static String APP_SECRET = "fcb567e070d48fbb937b192fcc2a0b5b";
/**小程序授权类型*/
private static String GRANT_TYPE = "authorization_code";
/**
* 微信小程序登录
* @param code
* @return
* @throws Exception
*/
public WeiXinLoginResult weiXinLoginBySmallRoutine(String code) throws Exception{
if(StringUtils.isEmpty(code)){
throw new Exception("code不能为空");
}
// 配置请求参数
Map<String, String> param = new HashMap<>();
param.put("appid", APP_ID);
param.put("secret", APP_SECRET);
param.put("js_code", code);
param.put("grant_type", GRANT_TYPE);
String str = WxUtil.doGet(VX_SMALL_ROUTINE_SESSION_KEY, param);
JSONObject json = JSONObject.parseObject(str);
Integer errcode = json.getInteger("errcode");
WeiXinLoginResult initResult = new WeiXinLoginResult();
if (errcode == 0) {
String skye = json.getString("session_key");
String openId = json.getString("openid");
String unionId = json.getString("unionid");
String token = AesUtil.aesCommonEncoder(skye,openId+unionId);
initResult.setCode("200");
initResult.setMsg("success");
initResult.setToken(token);
// json.getString("errmsg");
return initResult;
} else {
initResult.setCode("500");
initResult.setMsg("系统异常");
return initResult;
}
}
}

View File

@ -196,4 +196,18 @@ public interface ISystemConstant {
String DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; String DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
/**
* 小程序 appId*
*/
String VX_APP_ID = "wxa49a60262e53d305 ";
/**
* 小程序 appSecret
*/
String VX_APP_SECRET = "fcb567e070d48fbb937b192fcc2a0b5b";
/**
* 小程序授权类型
*/
String VX_GRANT_TYPE = "authorization_code";
} }

View File

@ -1,4 +1,4 @@
package cn.com.tenlion.util; package cn.com.tenlion.util.vx;
import com.sun.org.apache.xml.internal.security.utils.Base64; import com.sun.org.apache.xml.internal.security.utils.Base64;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;

View File

@ -10,9 +10,29 @@
<result column="vx_open_id" property="VxOpenId"/> <result column="vx_open_id" property="VxOpenId"/>
</resultMap> </resultMap>
<!-- 根据微信openId获取用户表详情 -->
<select id="getCardUserByVxOpenId" parameterType="map" resultMap="cardUserDTO">
SELECT
t1.user_name,
t1.user_phone,
t1.vx_union_id,
t1.vx_open_id,
t1.card_user_id
FROM
card_user t1
WHERE
t1.is_delete = 0
<if test="vxOpenId != null and vxOpenId != ''">
AND
t1.vx_open_id = #{vxOpenId}
</if>
</select>
<!-- 新增用户表 --> <!-- 新增用户表 -->
<insert id="saveCardUser" parameterType="map"> <insert id="saveCardUser" parameterType="map">
INSERT INTO gen_card_user( INSERT INTO card_user(
card_user_id, card_user_id,
user_name, user_name,
user_phone, user_phone,
@ -40,7 +60,7 @@
<!-- 删除用户表 --> <!-- 删除用户表 -->
<update id="removeCardUser" parameterType="map"> <update id="removeCardUser" parameterType="map">
UPDATE UPDATE
gen_card_user card_user
SET SET
is_delete = 1, is_delete = 1,
modifier = #{modifier}, modifier = #{modifier},
@ -55,7 +75,7 @@
<!-- 删除用户表(物理) --> <!-- 删除用户表(物理) -->
<update id="deleteCardUser" parameterType="map"> <update id="deleteCardUser" parameterType="map">
DELETE FROM DELETE FROM
gen_card_user card_user
WHERE WHERE
card_user_id IN card_user_id IN
<foreach collection="cardUserIds" index="index" open="(" separator="," close=")"> <foreach collection="cardUserIds" index="index" open="(" separator="," close=")">
@ -66,7 +86,7 @@
<!-- 修改用户表 --> <!-- 修改用户表 -->
<update id="updateCardUser" parameterType="map"> <update id="updateCardUser" parameterType="map">
UPDATE UPDATE
gen_card_user card_user
SET SET
<if test="userName != null and userName != ''"> <if test="userName != null and userName != ''">
user_name = #{userName}, user_name = #{userName},
@ -95,7 +115,7 @@
t1.vx_open_id, t1.vx_open_id,
t1.card_user_id t1.card_user_id
FROM FROM
gen_card_user t1 card_user t1
WHERE WHERE
t1.is_delete = 0 t1.is_delete = 0
<if test="cardUserId != null and cardUserId != ''"> <if test="cardUserId != null and cardUserId != ''">
@ -113,7 +133,7 @@
t1.vx_open_id, t1.vx_open_id,
t1.card_user_id t1.card_user_id
FROM FROM
gen_card_user t1 card_user t1
WHERE WHERE
t1.is_delete = 0 t1.is_delete = 0
<if test="keywords != null and keywords != ''"> <if test="keywords != null and keywords != ''">
@ -146,7 +166,7 @@
SELECT SELECT
COUNT(*) COUNT(*)
FROM FROM
gen_card_user t1 card_user t1
WHERE WHERE
t1.is_delete = 0 t1.is_delete = 0
</select> </select>