diff --git a/playlet-admin/src/main/java/com/playlet/web/controller/app/PlayletUserAppController.java b/playlet-admin/src/main/java/com/playlet/web/controller/app/PlayletUserAppController.java index 6c4848f..e6256af 100644 --- a/playlet-admin/src/main/java/com/playlet/web/controller/app/PlayletUserAppController.java +++ b/playlet-admin/src/main/java/com/playlet/web/controller/app/PlayletUserAppController.java @@ -1,5 +1,6 @@ package com.playlet.web.controller.app; +import com.github.pagehelper.PageInfo; import com.playlet.common.core.domain.Result; import com.playlet.system.domain.PlayletUser; import com.playlet.web.req.PlayUserReq; @@ -23,10 +24,11 @@ public class PlayletUserAppController { @ResponseBody @PostMapping(value = "/loginByOpenid") - @ApiOperation(value = "小程序通过openid登录系统", httpMethod = "POST") - public Result loginByOpenid(@RequestParam(value = "openid") String openid){ + @ApiOperation(value = "小程序通过openid登录系统(可选择是否带分销入参)", httpMethod = "POST") + public Result loginByOpenid(@RequestParam(value = "openid") String openid, + @RequestParam(value = "parentId", required = false) String parentId){ try { - return Result.success(playletUserAppService.getByOpenId(openid)); + return Result.success(playletUserAppService.getByOpenId(openid, parentId)); }catch (Exception e){ return Result.error(e.getMessage()); } @@ -66,6 +68,19 @@ public class PlayletUserAppController { } } + @ResponseBody + @PostMapping(value = "/getPlayletUserPage") + @ApiOperation(value = "分页查询用户数据(暂分销列表使用)", httpMethod = "POST") + public Result> getPlayletUserPage(@RequestBody PlayletUser playletUser, + @RequestParam(value = "pageNum") Integer pageNum, + @RequestParam(value = "pageSize") Integer pageSize){ + try { + return Result.success(playletUserAppService.getPlayletUserPage(playletUser, pageNum, pageSize)); + }catch (Exception e){ + return Result.error(e.getMessage()); + } + } + @ResponseBody @PostMapping(value = "/updatePasswordByCode") @ApiOperation(value = "验证码修改密码", httpMethod = "POST") diff --git a/playlet-admin/src/main/java/com/playlet/web/service/app/PlayletUserAppService.java b/playlet-admin/src/main/java/com/playlet/web/service/app/PlayletUserAppService.java index 3020771..2daabd5 100644 --- a/playlet-admin/src/main/java/com/playlet/web/service/app/PlayletUserAppService.java +++ b/playlet-admin/src/main/java/com/playlet/web/service/app/PlayletUserAppService.java @@ -1,5 +1,6 @@ package com.playlet.web.service.app; +import com.github.pagehelper.PageInfo; import com.playlet.system.domain.PlayletUser; import com.playlet.web.req.PlayUserReq; @@ -13,7 +14,7 @@ public interface PlayletUserAppService { * @param openid 微信唯一凭证 * @return 短剧用户 */ - PlayletUser getByOpenId(String openid); + PlayletUser getByOpenId(String openid, String parentId); /** * @param playUserReq 手机号登陆 @@ -37,4 +38,10 @@ public interface PlayletUserAppService { */ void updatePasswordByCode(PlayUserReq playUserReq) throws Exception; + /** + * @param playletUser 分页查询列表 + * @return 查询结果 + */ + PageInfo getPlayletUserPage(PlayletUser playletUser, Integer pageNum, Integer pageSize); + } diff --git a/playlet-admin/src/main/java/com/playlet/web/service/app/impl/PlayletUserAppServiceImpl.java b/playlet-admin/src/main/java/com/playlet/web/service/app/impl/PlayletUserAppServiceImpl.java index 9901dd2..4fdf8e4 100644 --- a/playlet-admin/src/main/java/com/playlet/web/service/app/impl/PlayletUserAppServiceImpl.java +++ b/playlet-admin/src/main/java/com/playlet/web/service/app/impl/PlayletUserAppServiceImpl.java @@ -1,6 +1,8 @@ package com.playlet.web.service.app.impl; import cn.hutool.core.util.ObjectUtil; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.playlet.common.constant.PlayletConstants; import com.playlet.common.constant.RedisConstants; import com.playlet.system.domain.PlayletUser; @@ -15,6 +17,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import java.util.Date; +import java.util.List; @Slf4j @Service @@ -26,13 +29,16 @@ public class PlayletUserAppServiceImpl implements PlayletUserAppService { private final StringRedisTemplate stringRedisTemplate; @Override - public PlayletUser getByOpenId(String openid) { + public PlayletUser getByOpenId(String openid, String parentId) { PlayletUser playletUser = iPlayletUserService.lambdaQuery().eq(PlayletUser::getOpenId, openid).one(); if(ObjectUtil.isNull(playletUser)){ playletUser = new PlayletUser(); playletUser.setOpenId(openid); playletUser.setCreateBy(PlayletConstants.DEFAULT_CREATE); playletUser.setCreateTime(new Date()); + if(parentId != null){ + playletUser.setParentId(parentId); + } iPlayletUserService.save(playletUser); playletUser.setCode("PLAYLET_" + playletUser.getId()); iPlayletUserService.updateById(playletUser); @@ -89,4 +95,11 @@ public class PlayletUserAppServiceImpl implements PlayletUserAppService { } } + + @Override + public PageInfo getPlayletUserPage(PlayletUser playletUser, Integer pageNum, Integer pageSize) { + PageHelper.startPage(pageNum, pageSize); + List list = iPlayletUserService.selectPlayletUserList(playletUser); + return PageInfo.of(list); + } } diff --git a/playlet-system/src/main/java/com/playlet/system/domain/PlayletUserExpandAccount.java b/playlet-system/src/main/java/com/playlet/system/domain/PlayletUserExpandAccount.java index 12a5a86..354d9fd 100644 --- a/playlet-system/src/main/java/com/playlet/system/domain/PlayletUserExpandAccount.java +++ b/playlet-system/src/main/java/com/playlet/system/domain/PlayletUserExpandAccount.java @@ -49,4 +49,13 @@ public class PlayletUserExpandAccount extends BaseEntity @ApiModelProperty(value = "审核状态 01.待审核 02.审核通过 03.审核拒绝") private String status; + @ApiModelProperty(value = "openId") + private String openId; + + @ApiModelProperty(value = "unionId") + private String unionId; + + @ApiModelProperty(value = "头像") + private String avatar; + } diff --git a/playlet-system/src/main/resources/mapper/system/PlayletUserExpandAccountMapper.xml b/playlet-system/src/main/resources/mapper/system/PlayletUserExpandAccountMapper.xml index b09e7f3..2feaa20 100644 --- a/playlet-system/src/main/resources/mapper/system/PlayletUserExpandAccountMapper.xml +++ b/playlet-system/src/main/resources/mapper/system/PlayletUserExpandAccountMapper.xml @@ -10,6 +10,9 @@ + + + @@ -18,7 +21,7 @@ - select id, name, account, type, status, create_by, create_time, update_by, update_time, remark from playlet_user_expand_account + select id, name, account, type, status,open_id, union_id, avatar, create_by, create_time, update_by, update_time, remark from playlet_user_expand_account @@ -43,6 +47,9 @@ account, type, status, + avatar, + open_id, + union_id, create_by, create_time, update_by, @@ -54,6 +61,9 @@ #{account}, #{type}, #{status}, + #{avatar}, + #{openId}, + #{unionId}, #{createBy}, #{createTime}, #{updateBy},