From 6fcd8e958d7d952633af9017b9563c8c307688fb Mon Sep 17 00:00:00 2001 From: ly19960718 <1622779752@qq.com> Date: Wed, 27 Jan 2021 17:50:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apis/carduser/CardUserController.java | 20 +- .../apis/carduser/CardUserAppController.java | 181 ++++++++++-------- .../DataDictionaryAppController.java | 2 +- .../weixinlogin/WeiXinLoginAppController.java | 41 ---- .../tenlion/dao/carduser/ICardUserDao.java | 61 +++--- .../pojo/dtos/carduser/CardUserDTO.java | 11 ++ .../service/carduser/ICardUserService.java | 114 +++++------ .../carduser/impl/CardUserServiceImpl.java | 94 ++++----- .../weixinlogin/IWeiXinLoginService.java | 25 --- .../impl/WeiXinLoginServiceImpl.java | 72 ------- .../tenlion/util/cons/ISystemConstant.java | 14 ++ .../cn/com/tenlion/util/{ => vx}/WxUtil.java | 2 +- .../mapper/carduser/carduser-mapper.xml | 34 +++- 13 files changed, 304 insertions(+), 367 deletions(-) delete mode 100644 src/main/java/cn/com/tenlion/controller/app/apis/weixinlogin/WeiXinLoginAppController.java delete mode 100644 src/main/java/cn/com/tenlion/service/weixinlogin/IWeiXinLoginService.java delete mode 100644 src/main/java/cn/com/tenlion/service/weixinlogin/impl/WeiXinLoginServiceImpl.java rename src/main/java/cn/com/tenlion/util/{ => vx}/WxUtil.java (99%) diff --git a/src/main/java/cn/com/tenlion/controller/apis/carduser/CardUserController.java b/src/main/java/cn/com/tenlion/controller/apis/carduser/CardUserController.java index e3ae14a..3958c3c 100644 --- a/src/main/java/cn/com/tenlion/controller/apis/carduser/CardUserController.java +++ b/src/main/java/cn/com/tenlion/controller/apis/carduser/CardUserController.java @@ -2,6 +2,16 @@ package cn.com.tenlion.controller.apis.carduser; import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO; 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.web.bind.annotation.*; import org.springframework.web.servlet.mvc.AbstractController; @@ -20,10 +30,8 @@ import java.util.Map; @RestController @RequestMapping("/carduser") public class CardUserController { -/* @Autowired - private ICardUserService cardUserService;*/ -/* + private ICardUserService cardUserService; @ApiOperation(value = "新增用户表", notes = "新增用户表接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @PostMapping("savecarduser") @@ -63,7 +71,7 @@ public class CardUserController { return cardUserService.getCardUserById(cardUserId); } - @ApiOperation(value = "用户表列表", notes = "用户表列表接口") +/* @ApiOperation(value = "用户表列表", notes = "用户表列表接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("listcarduser") public List listCardUser() throws SearchException { @@ -93,9 +101,9 @@ public class CardUserController { SuccessResultData countCardUser() throws SearchException { Map params = requestParams(); return cardUserService.countCardUser(params); - } + }*/ - @ApiOperation(value = "当前用户id信息", notes = "当前用户id信息接口") +/* @ApiOperation(value = "当前用户id信息", notes = "当前用户id信息接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("getcurrentuseridinfo") public CurrentUserIdInfoDTO getCurrentUserIdInfo() { diff --git a/src/main/java/cn/com/tenlion/controller/app/apis/carduser/CardUserAppController.java b/src/main/java/cn/com/tenlion/controller/app/apis/carduser/CardUserAppController.java index 3a6f1be..0914c0c 100644 --- a/src/main/java/cn/com/tenlion/controller/app/apis/carduser/CardUserAppController.java +++ b/src/main/java/cn/com/tenlion/controller/app/apis/carduser/CardUserAppController.java @@ -1,25 +1,38 @@ -/* 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.weixinresult.WeiXinAuthResult; import cn.com.tenlion.pojo.vos.carduser.CardUserVO; 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.web.bind.annotation.*; -import org.springframework.web.servlet.mvc.AbstractController; +import cn.com.tenlion.controller.AbstractController; import java.util.Arrays; import java.util.List; import java.util.Map; -*/ /** * @ClassName: CardUserAppController * @Description: 用户表 - * @Author: WenG + * @Author: LiuY * @Date: 2021-01-26 10:55 * @Version: 1.0 - **//* + **/ + + @Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "用户表接口") @RestController @@ -29,85 +42,95 @@ public class CardUserAppController extends AbstractController { @Autowired private ICardUserService cardUserService; - @ApiOperation(value = "新增用户表", notes = "新增用户表接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "token", value = "token", paramType = "header") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PostMapping("savecarduser") - @CheckRequestBodyAnnotation - public SuccessResult saveCardUser(@RequestHeader("token") String token, @RequestBody CardUserVO cardUserVO) throws Exception { - return cardUserService.saveCardUserByToken(token, cardUserVO); + + + + /** + * 小程序登录 + * @return + * @throws Exception + */ + @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 listCardUser(@RequestHeader("token") String token) throws SearchException { - Map 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> listPageCardUser(@RequestHeader("token") String token, ListPage page) throws SearchException { - Map params = requestParams(); - page.setParams(params); - return cardUserService.listPageCardUser(page); - } - @ApiOperation(value = "用户表统计", notes = "用户表统计接口") - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("countcarduser") - SuccessResultData countCardUser() throws SearchException { - Map params = requestParams(); - return cardUserService.countCardUser(params); - } +// @ApiOperation(value = "新增用户表", notes = "新增用户表接口") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "token", value = "token", paramType = "header") +// }) +// @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) +// @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); +// } -}*/ + + + +} diff --git a/src/main/java/cn/com/tenlion/controller/app/apis/datadictionary/DataDictionaryAppController.java b/src/main/java/cn/com/tenlion/controller/app/apis/datadictionary/DataDictionaryAppController.java index 744b0d3..3f96fbd 100644 --- a/src/main/java/cn/com/tenlion/controller/app/apis/datadictionary/DataDictionaryAppController.java +++ b/src/main/java/cn/com/tenlion/controller/app/apis/datadictionary/DataDictionaryAppController.java @@ -19,7 +19,7 @@ import java.util.List; import java.util.Map; @RestController -@RequestMapping("app/datadictionary") +@RequestMapping("/app/datadictionary") public class DataDictionaryAppController extends AbstractController { @Autowired diff --git a/src/main/java/cn/com/tenlion/controller/app/apis/weixinlogin/WeiXinLoginAppController.java b/src/main/java/cn/com/tenlion/controller/app/apis/weixinlogin/WeiXinLoginAppController.java deleted file mode 100644 index 2235b5d..0000000 --- a/src/main/java/cn/com/tenlion/controller/app/apis/weixinlogin/WeiXinLoginAppController.java +++ /dev/null @@ -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); - - } - - - - - - - -} diff --git a/src/main/java/cn/com/tenlion/dao/carduser/ICardUserDao.java b/src/main/java/cn/com/tenlion/dao/carduser/ICardUserDao.java index 605ed8f..dda0be7 100644 --- a/src/main/java/cn/com/tenlion/dao/carduser/ICardUserDao.java +++ b/src/main/java/cn/com/tenlion/dao/carduser/ICardUserDao.java @@ -1,7 +1,10 @@ package cn.com.tenlion.dao.carduser; - 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 java.util.List; @@ -17,63 +20,73 @@ import java.util.Map; @Repository public interface ICardUserDao { + + /** + * 根据微信open_id 获取用户信息 + * @param params + * @return + * @throws SearchException + */ + CardUserDTO getCardUserByVxOpenId(Map params) throws SearchException; + + /** * 新增用户表 * * @param params - * @throws Exception + * @throws SaveException */ - void saveCardUser(Map params) throws Exception; + void saveCardUser(Map params) throws SaveException; /** * 删除用户表 * * @param params - * @throws Exception + * @throws RemoveException */ - void removeCardUser(Map params) throws Exception; + void removeCardUser(Map params) throws RemoveException; /** - * 删除用户表(物理) - * - * @param params - * @throws Exception - */ - void deleteCardUser(Map params) throws Exception; + * 删除用户表(物理) + * + * @param params + * @throws RemoveException + */ + void deleteCardUser(Map params) throws RemoveException; /** * 修改用户表 * * @param params - * @throws Exception + * @throws UpdateException */ - void updateCardUser(Map params) throws Exception; + void updateCardUser(Map params) throws UpdateException; /** * 用户表详情 * * @param params * @return - * @throws Exception + * @throws SearchException */ - CardUserDTO getCardUser(Map params) throws Exception; + CardUserDTO getCardUser(Map params) throws SearchException; /** * 用户表列表 * * @param params * @return - * @throws Exception + * @throws SearchException */ - List listCardUser(Map params) throws Exception; + List listCardUser(Map params) throws SearchException; /** - * 用户表统计 - * - * @param params - * @return - * @throws Exception - */ - Integer countCardUser(Map params) throws Exception; + * 用户表统计 + * + * @param params + * @return + * @throws SearchException + */ + Integer countCardUser(Map params) throws SearchException; } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/pojo/dtos/carduser/CardUserDTO.java b/src/main/java/cn/com/tenlion/pojo/dtos/carduser/CardUserDTO.java index 730e53d..92948aa 100644 --- a/src/main/java/cn/com/tenlion/pojo/dtos/carduser/CardUserDTO.java +++ b/src/main/java/cn/com/tenlion/pojo/dtos/carduser/CardUserDTO.java @@ -32,6 +32,11 @@ public class CardUserDTO { */ private String VxOpenId; + /** + * 账号最后活动时间(用于token过期判断) + */ + private long lastActivityTime; + public String getCardUserId() { return cardUserId == null ? "" : cardUserId.trim(); } @@ -72,5 +77,11 @@ public class CardUserDTO { this.VxOpenId = VxOpenId; } + public long getLastActivityTime() { + return lastActivityTime; + } + public void setLastActivityTime(long lastActivityTime) { + this.lastActivityTime = lastActivityTime; + } } diff --git a/src/main/java/cn/com/tenlion/service/carduser/ICardUserService.java b/src/main/java/cn/com/tenlion/service/carduser/ICardUserService.java index 78f1f87..81d5eda 100644 --- a/src/main/java/cn/com/tenlion/service/carduser/ICardUserService.java +++ b/src/main/java/cn/com/tenlion/service/carduser/ICardUserService.java @@ -1,123 +1,112 @@ -/* 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.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.Map; -*/ /** * @ClassName: ICardUserService * @Description: 用户表 * @Author: WenG * @Date: 2021-01-26 10:55 * @Version: 1.0 - **//* - + **/ public interface ICardUserService { - */ -/** + /** + * 根据微信open_id获取用户详情 + * @param vxOpenId + * @return + * @throws SearchException + */ + CardUserDTO getCardUserByVxOpenId(String vxOpenId) throws SearchException; + + + /** * 新增用户表 * * @param cardUserVO * @return * @throws Exception - *//* - + */ SuccessResult saveCardUser(CardUserVO cardUserVO) throws Exception; - */ -/** + /** * 新增用户表(APP) * * @param token * @param cardUserVO * @return * @throws Exception - *//* - + */ SuccessResult saveCardUserByToken(String token, CardUserVO cardUserVO) throws Exception; - */ -/** + /** * 新增用户表 * * @param cardUserVO * @return cardUserId * @throws Exception - *//* - + */ String saveCardUserReturnId(CardUserVO cardUserVO) throws Exception; - */ -/** + /** * 新增用户表(APP) * * @param token * @param cardUserVO * @return cardUserId * @throws Exception - *//* - + */ String saveCardUserByTokenReturnId(String token, CardUserVO cardUserVO) throws Exception; - */ -/** + /** * 删除用户表 * * @param ids * @return * @throws RemoveException - *//* - + */ SuccessResult removeCardUser(String ids) throws RemoveException; - */ -/** + /** * 删除用户表(物理删除) * * @param ids * @throws RemoveException - *//* - + */ void deleteCardUser(String ids) throws RemoveException; - */ -/** + /** * 删除用户表(APP) * * @param token * @param ids * @return * @throws RemoveException - *//* - + */ SuccessResult removeCardUserByToken(String token, String ids) throws RemoveException; - */ -/** + /** * 修改用户表 * * @param cardUserId * @param cardUserVO * @return * @throws Exception - *//* - + */ SuccessResult updateCardUser(String cardUserId, CardUserVO cardUserVO) throws Exception; - */ -/** + /** * 修改用户表(APP) * * @param token @@ -125,63 +114,52 @@ public interface ICardUserService { * @param cardUserVO * @return * @throws Exception - *//* - + */ SuccessResult updateCardUserByToken(String token, String cardUserId, CardUserVO cardUserVO) throws Exception; - */ -/** + /** * 用户表详情(通过ID) * * @param cardUserId * @return * @throws SearchException - *//* - + */ CardUserDTO getCardUserById(String cardUserId) throws SearchException; - */ -/** + /** * 用户表列表 * * @param params * @return * @throws SearchException - *//* - + */ List listCardUser(Map params) throws SearchException; - */ -/** + /** * 用户表分页列表 * * @param page * @return * @throws SearchException - *//* - + */ SuccessResultList> listPageCardUser(ListPage page) throws SearchException; - */ -/** + /** * 用户表统计 * * @param params * @return * @throws SearchException - *//* - + */ Integer countNumberCardUser(Map params) throws SearchException; - */ -/** + /** * 用户表统计 * * @param params * @return * @throws SearchException - *//* - + */ SuccessResultData countCardUser(Map params) throws SearchException; -}*/ +} \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/service/carduser/impl/CardUserServiceImpl.java b/src/main/java/cn/com/tenlion/service/carduser/impl/CardUserServiceImpl.java index 278b53f..cb2c366 100644 --- a/src/main/java/cn/com/tenlion/service/carduser/impl/CardUserServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/carduser/impl/CardUserServiceImpl.java @@ -1,32 +1,54 @@ -/* package cn.com.tenlion.service.carduser.impl; + 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.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.stereotype.Service; import java.util.*; -*/ /** * @ClassName: CardUserServiceImpl * @Description: 用户表 * @Author: WenG * @Date: 2021-01-26 10:55 * @Version: 1.0 - **//* - + **/ @Service -public class CardUserServiceImpl implements ICardUserService { +public class CardUserServiceImpl extends AbstractService implements ICardUserService { @Autowired private ICardUserDao cardUserDao; -*/ -/* @Override + /** + * 根据微信open_id获取用户详情 + * @param vxOpenId + * @return + * @throws SearchException + */ + public CardUserDTO getCardUserByVxOpenId(String vxOpenId) throws SearchException{ + Map params = new HashMap<>(); + params.put("vxOpenId", vxOpenId); + return cardUserDao.getCardUserByVxOpenId(params); + } + + + @Override public SuccessResult saveCardUser(CardUserVO cardUserVO) throws Exception { saveCardUserInfo(null, cardUserVO); return new SuccessResult(); @@ -48,42 +70,35 @@ public class CardUserServiceImpl implements ICardUserService { return saveCardUserInfoReturnId(token, cardUserVO); } - *//* -*/ -/** + /** * 新增用户表 * * @param token * @param cardUserVO * @throws Exception - *//* -*/ -/* + */ private void saveCardUserInfo(String token, CardUserVO cardUserVO) throws Exception { saveCardUserInfoReturnId(token, cardUserVO); } - *//* -*/ -/** + /** * 新增用户表 * * @param token * @param cardUserVO * @return cardUserId * @throws Exception - *//* -*/ -/* + */ private String saveCardUserInfoReturnId(String token, CardUserVO cardUserVO) throws Exception { String cardUserId = UUIDUtil.getUUID(); Map params = HashMapUtil.beanToMap(cardUserVO); params.put("cardUserId", cardUserId); - if (token != null) { + params.put("gmtCreate", DateUtil.getTime()); + /* if (token != null) { setSaveInfo(token, params); } else { setSaveInfo(params); - } + }*/ cardUserDao.saveCardUser(params); return cardUserId; } @@ -100,29 +115,26 @@ public class CardUserServiceImpl implements ICardUserService { return new SuccessResult(); } - *//* -*/ -/** + /** * 删除用户表 * * @param token * @param ids - *//* -*/ -/* + */ private void removeCardUserInfo(String token, String ids) { Map params = getHashMap(3); params.put("cardUserIds", Arrays.asList(ids.split("_"))); - if (token != null) { + params.put("gmtModified",DateUtil.getTime()); + /* if (token != null) { setUpdateInfo(token, params); } else { setUpdateInfo(params); - } + }*/ cardUserDao.removeCardUser(params); } @Override - public void deleteCardUser(String ids) throws RemoveException { + public void deleteCardUser(String ids) throws RemoveException{ Map params = getHashMap(3); params.put("cardUserIds", Arrays.asList(ids.split("_"))); cardUserDao.deleteCardUser(params); @@ -140,25 +152,22 @@ public class CardUserServiceImpl implements ICardUserService { return new SuccessResult(); } - *//* -*/ -/** + /** * 修改用户表 * * @param token * @param cardUserId * @param cardUserVO - *//* -*/ -/* + */ private void updateCardUserInfo(String token, String cardUserId, CardUserVO cardUserVO) throws Exception { Map params = HashMapUtil.beanToMap(cardUserVO); params.put("cardUserId", cardUserId); - if (token != null) { + params.put("gmtModified",DateUtil.getTime()); + /* if (token != null) { setUpdateInfo(token, params); } else { setUpdateInfo(params); - } + }*/ cardUserDao.updateCardUser(params); } @@ -191,7 +200,6 @@ public class CardUserServiceImpl implements ICardUserService { @Override public SuccessResultData countCardUser(Map params) throws SearchException { return new SuccessResultData<>(countNumberCardUser(params)); - }*//* + } - -}*/ +} \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/service/weixinlogin/IWeiXinLoginService.java b/src/main/java/cn/com/tenlion/service/weixinlogin/IWeiXinLoginService.java deleted file mode 100644 index fa6ed1e..0000000 --- a/src/main/java/cn/com/tenlion/service/weixinlogin/IWeiXinLoginService.java +++ /dev/null @@ -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; - -} diff --git a/src/main/java/cn/com/tenlion/service/weixinlogin/impl/WeiXinLoginServiceImpl.java b/src/main/java/cn/com/tenlion/service/weixinlogin/impl/WeiXinLoginServiceImpl.java deleted file mode 100644 index 38555c5..0000000 --- a/src/main/java/cn/com/tenlion/service/weixinlogin/impl/WeiXinLoginServiceImpl.java +++ /dev/null @@ -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 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; - } - } - -} diff --git a/src/main/java/cn/com/tenlion/util/cons/ISystemConstant.java b/src/main/java/cn/com/tenlion/util/cons/ISystemConstant.java index a1ebc82..edd93c0 100644 --- a/src/main/java/cn/com/tenlion/util/cons/ISystemConstant.java +++ b/src/main/java/cn/com/tenlion/util/cons/ISystemConstant.java @@ -196,4 +196,18 @@ public interface ISystemConstant { 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"; + + } diff --git a/src/main/java/cn/com/tenlion/util/WxUtil.java b/src/main/java/cn/com/tenlion/util/vx/WxUtil.java similarity index 99% rename from src/main/java/cn/com/tenlion/util/WxUtil.java rename to src/main/java/cn/com/tenlion/util/vx/WxUtil.java index 403201e..9d4637d 100644 --- a/src/main/java/cn/com/tenlion/util/WxUtil.java +++ b/src/main/java/cn/com/tenlion/util/vx/WxUtil.java @@ -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 lombok.extern.slf4j.Slf4j; diff --git a/src/main/resources/mybatis/mapper/carduser/carduser-mapper.xml b/src/main/resources/mybatis/mapper/carduser/carduser-mapper.xml index 37aec44..fedb65a 100644 --- a/src/main/resources/mybatis/mapper/carduser/carduser-mapper.xml +++ b/src/main/resources/mybatis/mapper/carduser/carduser-mapper.xml @@ -10,9 +10,29 @@ + + + + + - INSERT INTO gen_card_user( + INSERT INTO card_user( card_user_id, user_name, user_phone, @@ -40,7 +60,7 @@ UPDATE - gen_card_user + card_user SET is_delete = 1, modifier = #{modifier}, @@ -55,7 +75,7 @@ DELETE FROM - gen_card_user + card_user WHERE card_user_id IN @@ -66,7 +86,7 @@ UPDATE - gen_card_user + card_user SET user_name = #{userName}, @@ -95,7 +115,7 @@ t1.vx_open_id, t1.card_user_id FROM - gen_card_user t1 + card_user t1 WHERE t1.is_delete = 0 @@ -113,7 +133,7 @@ t1.vx_open_id, t1.card_user_id FROM - gen_card_user t1 + card_user t1 WHERE t1.is_delete = 0 @@ -146,7 +166,7 @@ SELECT COUNT(*) FROM - gen_card_user t1 + card_user t1 WHERE t1.is_delete = 0