diff --git a/pom.xml b/pom.xml index dad4ca9..7e5fc07 100644 --- a/pom.xml +++ b/pom.xml @@ -67,6 +67,20 @@ pagehelper ${pagehelper.version} + + + + com.alibaba + fastjson + 1.2.73 + + + + org.apache.httpcomponents + httpclient + 4.3.5 + + diff --git a/src/main/java/cn/com/tenlion/businesscard/BusinessCardApplication.java b/src/main/java/cn/com/tenlion/businesscard/BusinessCardApplication.java index a5b42c7..12fa8fe 100644 --- a/src/main/java/cn/com/tenlion/businesscard/BusinessCardApplication.java +++ b/src/main/java/cn/com/tenlion/businesscard/BusinessCardApplication.java @@ -2,8 +2,10 @@ package cn.com.tenlion.businesscard; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; @SpringBootApplication +@ComponentScan("cn.com") public class BusinessCardApplication { public static void main(String[] args) { 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 new file mode 100644 index 0000000..e3ae14a --- /dev/null +++ b/src/main/java/cn/com/tenlion/controller/apis/carduser/CardUserController.java @@ -0,0 +1,105 @@ +package cn.com.tenlion.controller.apis.carduser; +import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO; +import cn.com.tenlion.pojo.vos.carduser.CardUserVO; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.mvc.AbstractController; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * @ClassName: CardUserController + * @Description: 用户表 + * @Author: WenG + * @Date: 2021-01-26 10:55 + * @Version: 1.0 + **/ +@RestController +@RequestMapping("/carduser") +public class CardUserController { +/* + @Autowired + private ICardUserService cardUserService;*/ +/* + @ApiOperation(value = "新增用户表", notes = "新增用户表接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("savecarduser") + @CheckRequestBodyAnnotation + public SuccessResult saveCardUser(@RequestBody CardUserVO cardUserVO) throws Exception { + return cardUserService.saveCardUser(cardUserVO); + } + + @ApiOperation(value = "删除用户表(id列表)", notes = "删除用户表(id列表)接口") + @ApiImplicitParams({ + @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(@PathVariable("ids") String ids) throws RemoveException { + return cardUserService.removeCardUser(ids); + } + + @ApiOperation(value = "修改用户表", notes = "修改用户表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "cardUserId", value = "用户表ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PutMapping("updatecarduser/{cardUserId}") + @CheckRequestBodyAnnotation + public SuccessResult updateCardUser(@PathVariable("cardUserId") String cardUserId, @RequestBody CardUserVO cardUserVO) throws Exception { + return cardUserService.updateCardUser(cardUserId, cardUserVO); + } + + @ApiOperation(value = "用户表详情(通过ID)", notes = "用户表详情(通过ID)接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "cardUserId", value = "用户表ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("getcarduserbyid/{cardUserId}") + public CardUserDTO getCardUserById(@PathVariable("cardUserId") String cardUserId) throws SearchException { + return cardUserService.getCardUserById(cardUserId); + } + + @ApiOperation(value = "用户表列表", notes = "用户表列表接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("listcarduser") + public List listCardUser() throws SearchException { + Map params = requestParams(); + return cardUserService.listCardUser(params); + } + + @ApiOperation(value = "用户表分页列表", notes = "用户表分页列表接口") + @ApiImplicitParams({ + @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(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 = "当前用户id信息", notes = "当前用户id信息接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("getcurrentuseridinfo") + public CurrentUserIdInfoDTO getCurrentUserIdInfo() { + return securityComponent.getCurrentUserIdInfo(); + }*/ + +} \ No newline at end of file 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 new file mode 100644 index 0000000..3a6f1be --- /dev/null +++ b/src/main/java/cn/com/tenlion/controller/app/apis/carduser/CardUserAppController.java @@ -0,0 +1,113 @@ +/* +package cn.com.tenlion.controller.app.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 org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.mvc.AbstractController; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +*/ +/** + * @ClassName: CardUserAppController + * @Description: 用户表 + * @Author: WenG + * @Date: 2021-01-26 10:55 + * @Version: 1.0 + **//* + +@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "用户表接口") +@RestController +@RequestMapping(ISystemConstant.APP_PREFIX + "/carduser") +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); + } + + @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); + } + +}*/ 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 new file mode 100644 index 0000000..db99238 --- /dev/null +++ b/src/main/java/cn/com/tenlion/controller/app/apis/weixinlogin/WeiXinLoginAppController.java @@ -0,0 +1,40 @@ +package cn.com.tenlion.controller.app.apis.weixinlogin; + +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 String weiXinLoginBySmallRoutine (@PathVariable("vxCode") String vxCode) throws Exception{ + return weiXinLoginService.weiXinLoginBySmallRoutine(vxCode); + + } + + + + + + + +} diff --git a/src/main/java/cn/com/tenlion/controller/resources/carduser/CardUserResourceController.java b/src/main/java/cn/com/tenlion/controller/resources/carduser/CardUserResourceController.java new file mode 100644 index 0000000..b5af850 --- /dev/null +++ b/src/main/java/cn/com/tenlion/controller/resources/carduser/CardUserResourceController.java @@ -0,0 +1,114 @@ +/* +package cn.com.tenlion.controller.resources.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 io.swagger.annotations.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +*/ +/** + * @ClassName: CardUserResourceController + * @Description: 用户表 + * @Author: WenG + * @Date: 2021-01-26 10:55 + * @Version: 1.0 + **//* + +@Api(tags = ISystemConstant.API_TAGS_RESOURCE_PREFIX + "用户表接口") +@RestController +@RequestMapping(ISystemConstant.RESOURCE_PREFIX + "/carduser") +public class CardUserResourceController extends AbstractController { + + @Autowired + private ICardUserService cardUserService; + + @ApiOperation(value = "新增用户表", notes = "新增用户表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("savecarduser") + @CheckRequestBodyAnnotation + public SuccessResult saveCardUser(@RequestBody CardUserVO cardUserVO) throws Exception { + return cardUserService.saveCardUser(cardUserVO); + } + + @ApiOperation(value = "删除用户表(id列表)", notes = "删除用户表(id列表)接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), + @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(@PathVariable("ids") String ids) throws RemoveException { + return cardUserService.removeCardUser(ids); + } + + @ApiOperation(value = "修改用户表", notes = "修改用户表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), + @ApiImplicitParam(name = "cardUserId", value = "用户表ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PutMapping("updatecarduser/{cardUserId}") + @CheckRequestBodyAnnotation + public SuccessResult updateCardUser(@PathVariable("cardUserId") String cardUserId, @RequestBody CardUserVO cardUserVO) throws Exception { + return cardUserService.updateCardUser(cardUserId, cardUserVO); + } + + @ApiOperation(value = "用户表详情(通过ID)", notes = "用户表详情(通过ID)接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), + @ApiImplicitParam(name = "cardUserId", value = "用户表ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("getcarduserbyid/{cardUserId}") + public CardUserDTO getCardUserById(@PathVariable("cardUserId") String cardUserId) throws SearchException { + return cardUserService.getCardUserById(cardUserId); + } + + @ApiOperation(value = "用户表列表", notes = "用户表列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("listcarduser") + public List listCardUser() throws SearchException { + Map params = requestParams(); + return cardUserService.listCardUser(params); + } + + @ApiOperation(value = "用户表分页列表", notes = "用户表分页列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), + @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(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); + } + +}*/ diff --git a/src/main/java/cn/com/tenlion/dao/carduser/ICardUserDao.java b/src/main/java/cn/com/tenlion/dao/carduser/ICardUserDao.java new file mode 100644 index 0000000..605ed8f --- /dev/null +++ b/src/main/java/cn/com/tenlion/dao/carduser/ICardUserDao.java @@ -0,0 +1,79 @@ +package cn.com.tenlion.dao.carduser; + + +import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName: ICardUserDao + * @Description: 用户表 + * @Author: WenG + * @Date: 2021-01-26 10:55 + * @Version: 1.0 + **/ +@Repository +public interface ICardUserDao { + + /** + * 新增用户表 + * + * @param params + * @throws Exception + */ + void saveCardUser(Map params) throws Exception; + + /** + * 删除用户表 + * + * @param params + * @throws Exception + */ + void removeCardUser(Map params) throws Exception; + + /** + * 删除用户表(物理) + * + * @param params + * @throws Exception + */ + void deleteCardUser(Map params) throws Exception; + + /** + * 修改用户表 + * + * @param params + * @throws Exception + */ + void updateCardUser(Map params) throws Exception; + + /** + * 用户表详情 + * + * @param params + * @return + * @throws Exception + */ + CardUserDTO getCardUser(Map params) throws Exception; + + /** + * 用户表列表 + * + * @param params + * @return + * @throws Exception + */ + List listCardUser(Map params) throws Exception; + + /** + * 用户表统计 + * + * @param params + * @return + * @throws Exception + */ + Integer countCardUser(Map params) throws Exception; + +} \ 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 new file mode 100644 index 0000000..730e53d --- /dev/null +++ b/src/main/java/cn/com/tenlion/pojo/dtos/carduser/CardUserDTO.java @@ -0,0 +1,76 @@ +package cn.com.tenlion.pojo.dtos.carduser; + + +/** + * + * @ClassName: CardUserDTO + * @Description: 用户表 + * @Author: WenG + * @Date: 2021-01-26 10:55 + * @Version: 1.0 + **/ +public class CardUserDTO { + + /** + * 主键 + */ + private String cardUserId; + /** + * 用户姓名 + */ + private String userName; + /** + * 用户手机 + */ + private String userPhone; + /** + * 用户开放平台唯一标识 + */ + private String VxUnionId; + /** + * 微信用户唯一标识 + */ + private String VxOpenId; + + public String getCardUserId() { + return cardUserId == null ? "" : cardUserId.trim(); + } + + public void setCardUserId(String cardUserId) { + this.cardUserId = cardUserId; + } + + public String getUserName() { + return userName == null ? "" : userName.trim(); + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserPhone() { + return userPhone == null ? "" : userPhone.trim(); + } + + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; + } + + public String getVxUnionId() { + return VxUnionId == null ? "" : VxUnionId.trim(); + } + + public void setVxUnionId(String VxUnionId) { + this.VxUnionId = VxUnionId; + } + + public String getVxOpenId() { + return VxOpenId == null ? "" : VxOpenId.trim(); + } + + public void setVxOpenId(String VxOpenId) { + this.VxOpenId = VxOpenId; + } + + +} diff --git a/src/main/java/cn/com/tenlion/pojo/vos/carduser/CardUserVO.java b/src/main/java/cn/com/tenlion/pojo/vos/carduser/CardUserVO.java new file mode 100644 index 0000000..1755107 --- /dev/null +++ b/src/main/java/cn/com/tenlion/pojo/vos/carduser/CardUserVO.java @@ -0,0 +1,64 @@ +package cn.com.tenlion.pojo.vos.carduser; + +/** + * + * @ClassName: CardUserVO + * @Description: 用户表 + * @Author: WenG + * @Date: 2021-01-26 10:55 + * @Version: 1.0 + **/ +public class CardUserVO { + + /** + * 用户姓名 + */ + private String userName; + /** + * 用户手机 + */ + private String userPhone; + /** + * 用户开放平台唯一标识 + */ + private String VxUnionId; + /** + * 微信用户唯一标识 + */ + private String VxOpenId; + + + public String getUserName() { + return userName == null ? "" : userName.trim(); + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserPhone() { + return userPhone == null ? "" : userPhone.trim(); + } + + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; + } + + public String getVxUnionId() { + return VxUnionId == null ? "" : VxUnionId.trim(); + } + + public void setVxUnionId(String VxUnionId) { + this.VxUnionId = VxUnionId; + } + + public String getVxOpenId() { + return VxOpenId == null ? "" : VxOpenId.trim(); + } + + public void setVxOpenId(String VxOpenId) { + this.VxOpenId = VxOpenId; + } + + +} diff --git a/src/main/java/cn/com/tenlion/service/carduser/ICardUserService.java b/src/main/java/cn/com/tenlion/service/carduser/ICardUserService.java new file mode 100644 index 0000000..78f1f87 --- /dev/null +++ b/src/main/java/cn/com/tenlion/service/carduser/ICardUserService.java @@ -0,0 +1,187 @@ +/* +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 java.util.List; +import java.util.Map; + +*/ +/** + * @ClassName: ICardUserService + * @Description: 用户表 + * @Author: WenG + * @Date: 2021-01-26 10:55 + * @Version: 1.0 + **//* + +public interface ICardUserService { + + */ +/** + * 新增用户表 + * + * @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 + * @param cardUserId + * @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; + +}*/ 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 new file mode 100644 index 0000000..278b53f --- /dev/null +++ b/src/main/java/cn/com/tenlion/service/carduser/impl/CardUserServiceImpl.java @@ -0,0 +1,197 @@ +/* +package cn.com.tenlion.service.carduser.impl; + +import cn.com.tenlion.dao.carduser.ICardUserDao; + +import cn.com.tenlion.service.carduser.ICardUserService; + +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 { + + @Autowired + private ICardUserDao cardUserDao; + +*/ +/* @Override + public SuccessResult saveCardUser(CardUserVO cardUserVO) throws Exception { + saveCardUserInfo(null, cardUserVO); + return new SuccessResult(); + } + + @Override + public SuccessResult saveCardUserByToken(String token, CardUserVO cardUserVO) throws Exception { + saveCardUserInfo(token, cardUserVO); + return new SuccessResult(); + } + + @Override + public String saveCardUserReturnId(CardUserVO cardUserVO) throws Exception { + return saveCardUserInfoReturnId(null, cardUserVO); + } + + @Override + public String saveCardUserByTokenReturnId(String token, CardUserVO cardUserVO) throws Exception { + 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) { + setSaveInfo(token, params); + } else { + setSaveInfo(params); + } + cardUserDao.saveCardUser(params); + return cardUserId; + } + + @Override + public SuccessResult removeCardUser(String ids) throws RemoveException { + removeCardUserInfo(null, ids); + return new SuccessResult(); + } + + @Override + public SuccessResult removeCardUserByToken(String token, String ids) throws RemoveException { + removeCardUserInfo(token, ids); + 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) { + setUpdateInfo(token, params); + } else { + setUpdateInfo(params); + } + cardUserDao.removeCardUser(params); + } + + @Override + public void deleteCardUser(String ids) throws RemoveException { + Map params = getHashMap(3); + params.put("cardUserIds", Arrays.asList(ids.split("_"))); + cardUserDao.deleteCardUser(params); + } + + @Override + public SuccessResult updateCardUser(String cardUserId, CardUserVO cardUserVO) throws Exception { + updateCardUserInfo(null, cardUserId, cardUserVO); + return new SuccessResult(); + } + + @Override + public SuccessResult updateCardUserByToken(String token, String cardUserId, CardUserVO cardUserVO) throws Exception { + updateCardUserInfo(token, cardUserId, cardUserVO); + 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) { + setUpdateInfo(token, params); + } else { + setUpdateInfo(params); + } + cardUserDao.updateCardUser(params); + } + + @Override + public CardUserDTO getCardUserById(String cardUserId) throws SearchException { + Map params = super.getHashMap(1); + params.put("cardUserId", cardUserId); + return cardUserDao.getCardUser(params); + } + + @Override + public List listCardUser(Map params) throws SearchException { + return cardUserDao.listCardUser(params); + } + + @Override + public SuccessResultList> listPageCardUser(ListPage page) throws SearchException { + PageHelper.startPage(page.getPage(), page.getRows()); + List cardUserDTOs = cardUserDao.listCardUser(page.getParams()); + PageInfo pageInfo = new PageInfo<>(cardUserDTOs); + return new SuccessResultList<>(cardUserDTOs, pageInfo.getPageNum(), pageInfo.getTotal()); + } + + @Override + public Integer countNumberCardUser(Map params) throws SearchException { + Integer count = cardUserDao.countCardUser(params); + return count == null ? 0 : count; + } + + @Override + public SuccessResultData countCardUser(Map params) throws SearchException { + return new SuccessResultData<>(countNumberCardUser(params)); + }*//* + + +}*/ diff --git a/src/main/java/cn/com/tenlion/service/weixinlogin/IWeiXinLoginService.java b/src/main/java/cn/com/tenlion/service/weixinlogin/IWeiXinLoginService.java new file mode 100644 index 0000000..0059c84 --- /dev/null +++ b/src/main/java/cn/com/tenlion/service/weixinlogin/IWeiXinLoginService.java @@ -0,0 +1,24 @@ +package cn.com.tenlion.service.weixinlogin; + +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 + */ + String 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 new file mode 100644 index 0000000..4459e93 --- /dev/null +++ b/src/main/java/cn/com/tenlion/service/weixinlogin/impl/WeiXinLoginServiceImpl.java @@ -0,0 +1,58 @@ +package cn.com.tenlion.service.weixinlogin.impl; + +import cn.com.tenlion.service.weixinlogin.IWeiXinLoginService; +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 String 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); + if (StringUtils.isEmpty(str)) { + return ""; + } else { + JSONObject json = JSONObject.parseObject(str); + json.getString(""); + return ""; + } + } + +} diff --git a/src/main/java/cn/com/tenlion/util/WxUtil.java b/src/main/java/cn/com/tenlion/util/WxUtil.java new file mode 100644 index 0000000..9079d8b --- /dev/null +++ b/src/main/java/cn/com/tenlion/util/WxUtil.java @@ -0,0 +1,153 @@ +package cn.com.tenlion.util; + +import com.sun.org.apache.xml.internal.security.utils.Base64; +import lombok.extern.slf4j.Slf4j; +import org.apache.http.NameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import org.springframework.boot.configurationprocessor.json.JSONObject; +import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import javax.net.ssl.HttpsURLConnection; +import java.io.*; +import java.net.URI; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.StandardCharsets; +import java.security.Security; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 微信小程序工具类 + * @version 1.0 + * @author LY + * @date 2021/1/26 11:28 + */ +@Slf4j +public class WxUtil { + + + + public static String doGet(String url, Map param) { + // 创建Httpclient对象 + CloseableHttpClient httpclient = HttpClients.createDefault(); + + String resultString = ""; + CloseableHttpResponse response = null; + try { + // 创建uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + + // 创建http GET请求 + HttpGet httpGet = new HttpGet(uri); + + // 执行请求 + response = httpclient.execute(httpGet); + // 判断返回状态是否为200 + if (response.getStatusLine().getStatusCode() == 200) { + resultString = EntityUtils.toString(response.getEntity(), "UTF-8"); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (response != null) { + response.close(); + } + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return resultString; + } + + public static String doGet(String url) { + return doGet(url, null); + } + + public static String doPost(String url, Map param) { + // 创建Httpclient对象 + CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + try { + // 创建Http Post请求 + HttpPost httpPost = new HttpPost(url); + // 创建参数列表 + if (param != null) { + List paramList = new ArrayList<>(); + for (String key : param.keySet()) { + paramList.add(new BasicNameValuePair(key, param.get(key))); + } + // 模拟表单 + UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList); + httpPost.setEntity(entity); + } + // 执行http请求 + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + return resultString; + } + + public static String doPost(String url) { + return doPost(url, null); + } + + public static String doPostJson(String url, String json) { + // 创建Httpclient对象 + CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + try { + // 创建Http Post请求 + HttpPost httpPost = new HttpPost(url); + // 创建请求内容 + StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); + httpPost.setEntity(entity); + // 执行http请求 + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + return resultString; + } + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 02eed40..57acdee 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 8888 + port: 8080 servlet: context-path: /businesscard @@ -16,7 +16,7 @@ spring: db-type: mysql driver-class-name: com.mysql.cj.jdbc.Driver username: root - password: root + password: 123456 initial-size: 2 min-idle: 2 max-active: 10 diff --git a/src/main/resources/mybatis/mapper/carduser/carduser-mapper.xml b/src/main/resources/mybatis/mapper/carduser/carduser-mapper.xml new file mode 100644 index 0000000..37aec44 --- /dev/null +++ b/src/main/resources/mybatis/mapper/carduser/carduser-mapper.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + INSERT INTO gen_card_user( + card_user_id, + user_name, + user_phone, + vx_union_id, + vx_open_id, + creator, + gmt_create, + modifier, + gmt_modified, + is_delete + ) VALUES( + #{cardUserId}, + #{userName}, + #{userPhone}, + #{VxUnionId}, + #{VxOpenId}, + #{creator}, + #{gmtCreate}, + #{modifier}, + #{gmtModified}, + #{isDelete} + ) + + + + + UPDATE + gen_card_user + SET + is_delete = 1, + modifier = #{modifier}, + gmt_modified = #{gmtModified} + WHERE + card_user_id IN + + #{cardUserIds[${index}]} + + + + + + DELETE FROM + gen_card_user + WHERE + card_user_id IN + + #{cardUserIds[${index}]} + + + + + + UPDATE + gen_card_user + SET + + user_name = #{userName}, + + + user_phone = #{userPhone}, + + + vx_union_id = #{VxUnionId}, + + + vx_open_id = #{VxOpenId}, + + modifier = #{modifier}, + gmt_modified = #{gmtModified} + WHERE + card_user_id = #{cardUserId} + + + + + + + + + + + + \ No newline at end of file