From ed0549c7d5cc724bc8dba8a006b7552908a9b57e Mon Sep 17 00:00:00 2001 From: twy <2301620162@qq.com> Date: Wed, 19 Jul 2023 15:15:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=9D=83=E9=99=90=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxUserGrantController.java | 35 ++++++++-- .../iformall/domain/po/WxCUserAuthority.java | 29 ++------- .../mapper/WxCUserAuthorityMapper.java | 15 +++++ .../service/WxCUserAuthorityService.java | 7 ++ .../impl/WxCUserAuthorityServiceImpl.java | 65 +++++++++++++++++++ .../mapper/WxCUserAuthorityMapper.xml | 29 +++++++++ 6 files changed, 153 insertions(+), 27 deletions(-) create mode 100644 suimangService/src/main/java/com/iformall/mapper/WxCUserAuthorityMapper.java create mode 100644 suimangService/src/main/java/com/iformall/service/WxCUserAuthorityService.java create mode 100644 suimangService/src/main/java/com/iformall/service/impl/WxCUserAuthorityServiceImpl.java create mode 100644 suimangService/src/main/resources/mapper/WxCUserAuthorityMapper.xml diff --git a/suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java b/suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java index 3e95aef..2a5b581 100644 --- a/suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java +++ b/suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java @@ -86,7 +86,7 @@ public class WxUserGrantController extends BaseController { WxMallService mallService; @Autowired - WxCLiveUserBasicInfoService wxCLiveUserBasicInfoService; + private WxCLiveUserBasicInfoService wxCLiveUserBasicInfoService; @Autowired @@ -103,6 +103,9 @@ public class WxUserGrantController extends BaseController { @Autowired private UserConsumptionPackageService userConsumptionPackageService; + @Autowired + private WxCUserAuthorityService wxCUserAuthorityService; + @AuthIgnore @ApiOperation("验证码") @@ -370,10 +373,34 @@ public class WxUserGrantController extends BaseController { } /** - * 需要效验用户及图片验证码 - * @param phone - * @return + * 资源权限查询 + * */ + + @AuthIgnore + @ApiOperation(value = "资源权限查询", notes = "{\"username\",\"string\",\"code\",\"string\",\"type\",\"int\",\"resource_id\",\"long\"}") + @PostMapping("/author") + public ResultData getAuthor(@RequestBody Map params, HttpServletResponse response) { + String ipaddress = getIpAddr(); + logger.debug("[" + ipaddress + "] WxUserGrantController::getAuthor"); + String username = params.get("username"); + String code = params.get("code"); + Integer type = Integer.parseInt(params.get("type")); + Long resourceId = Long.valueOf(params.get("resource_id")); + + + return wxCUserAuthorityService.getAuthor(username,code,type,resourceId); + } + + + + + + /** + * 需要效验用户及图片验证码 + * @param phone + * @return + */ @AuthIgnore @ApiOperation("发送修改密码验证码") @GetMapping("sendPhoneCode") diff --git a/suimangService/src/main/java/com/iformall/domain/po/WxCUserAuthority.java b/suimangService/src/main/java/com/iformall/domain/po/WxCUserAuthority.java index c656f93..65e4ca0 100644 --- a/suimangService/src/main/java/com/iformall/domain/po/WxCUserAuthority.java +++ b/suimangService/src/main/java/com/iformall/domain/po/WxCUserAuthority.java @@ -13,33 +13,16 @@ public class WxCUserAuthority { @TableField(exist = false) private String userName; + @TableField(exist = false) //数字人 0 声纹 1 + private String type; + @TableField(exist = false) + private String resourceId; + @TableField(exist = false) //共享 0 定制 1 + private String classType; @TableField(exist = false) private String currentTime; @TableField(exist = false) private String expireTime; - @io.swagger.annotations.ApiModelProperty(value = "地区名称", name = "local_name") - private String localelName; - @io.swagger.annotations.ApiModelProperty(value = "地区显示名称", name = "local_display_name") - private String localDisPlayName; - - @io.swagger.annotations.ApiModelProperty(value = "声纹ID", name = "voice_id") - private int voiceId; - @io.swagger.annotations.ApiModelProperty(value = "声纹名称(用于调微软接口)", name = "voice_name") - private String voiceName; - @io.swagger.annotations.ApiModelProperty(value = "声纹展示名称", name = "voice_display_name") - private String voiceDisplayName; - @io.swagger.annotations.ApiModelProperty(value = "性别(男1 女0)", name = "gender") - private int gender; - @io.swagger.annotations.ApiModelProperty(value = "声纹类型 共享:0 定制:1", name = "class") - private int voiceType; - - @io.swagger.annotations.ApiModelProperty(value = "声纹风格名称(用于微软接口)", name = "style_name") - private String styleName; - @io.swagger.annotations.ApiModelProperty(value = "声纹风格展示名称", name = "style_display_name") - private String styleDisplayName; - @io.swagger.annotations.ApiModelProperty(value = "声纹风格样例文件链接", name = "style_demo") - private String styleDemo; - } diff --git a/suimangService/src/main/java/com/iformall/mapper/WxCUserAuthorityMapper.java b/suimangService/src/main/java/com/iformall/mapper/WxCUserAuthorityMapper.java new file mode 100644 index 0000000..a29688a --- /dev/null +++ b/suimangService/src/main/java/com/iformall/mapper/WxCUserAuthorityMapper.java @@ -0,0 +1,15 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.WxCUserAuthority; + +import java.util.List; + + +public interface WxCUserAuthorityMapper extends CommonMapper { + + + List getAuthorAvatar(String username, int i, Long resourceId); + + List getAuthorVoice(String username, int i, Long resourceId); +} diff --git a/suimangService/src/main/java/com/iformall/service/WxCUserAuthorityService.java b/suimangService/src/main/java/com/iformall/service/WxCUserAuthorityService.java new file mode 100644 index 0000000..3c72e3e --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/WxCUserAuthorityService.java @@ -0,0 +1,7 @@ +package com.iformall.service; + +import com.iformall.common.ResultData; + +public interface WxCUserAuthorityService { + ResultData getAuthor(String username, String code, Integer type, Long resourceId); +} diff --git a/suimangService/src/main/java/com/iformall/service/impl/WxCUserAuthorityServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/WxCUserAuthorityServiceImpl.java new file mode 100644 index 0000000..02017d9 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/impl/WxCUserAuthorityServiceImpl.java @@ -0,0 +1,65 @@ +package com.iformall.service.impl; + +import com.iformall.common.ResultData; +import com.iformall.domain.po.WxCUserAuthority; +import com.iformall.mapper.WxCUserAuthorityMapper; +import com.iformall.service.WxCUserAuthorityService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +@Service +public class WxCUserAuthorityServiceImpl implements WxCUserAuthorityService { + + @Autowired + private WxCUserAuthorityMapper wxCUserAuthorityMapper; + + + @Override + public ResultData getAuthor(String username, String code, Integer type, Long resourceId) { + List resultList = new ArrayList(); + + if (type==0){ + //查询数字人相关权限 + resultList = wxCUserAuthorityMapper.getAuthorAvatar(username,0,resourceId); + } + if (type==1){ + //查询声纹相关权限 + resultList = wxCUserAuthorityMapper.getAuthorVoice(username,1,resourceId); + } + + if (resourceId==null){ + //若资源id没有传入那就展示所有当前类型资源权限 + HashMap resultMap = new HashMap<>(); + List authorList = new ArrayList(); + for (WxCUserAuthority wxCUserAuthority : resultList) { + HashMap author = new HashMap<>(); + author.put("username",wxCUserAuthority.getUserName()); + author.put("type",wxCUserAuthority.getType()); + author.put("resource_id",wxCUserAuthority.getResourceId()); + author.put("class",wxCUserAuthority.getClassType()); + author.put("current_time",new Date(System.currentTimeMillis())); + author.put("expire_time",wxCUserAuthority.getExpireTime()); + authorList.add(author); + } + resultMap.put("authorList",authorList); + } + HashMap resultMap = new HashMap<>(); + + for (WxCUserAuthority wxCUserAuthority : resultList) { + resultMap.put("username",wxCUserAuthority.getUserName()); + resultMap.put("type",wxCUserAuthority.getType()); + resultMap.put("resource_id",wxCUserAuthority.getResourceId()); + resultMap.put("class",wxCUserAuthority.getClassType()); + resultMap.put("current_time",new Date(System.currentTimeMillis())); + resultMap.put("expire_time",wxCUserAuthority.getExpireTime()); + + } + + return new ResultData(resultMap); + } +} diff --git a/suimangService/src/main/resources/mapper/WxCUserAuthorityMapper.xml b/suimangService/src/main/resources/mapper/WxCUserAuthorityMapper.xml new file mode 100644 index 0000000..9c90330 --- /dev/null +++ b/suimangService/src/main/resources/mapper/WxCUserAuthorityMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + +