多语言-公会-公会权限

This commit is contained in:
khalil
2024-04-18 15:13:57 +08:00
parent bb049e92da
commit bfe2899dde
8 changed files with 66 additions and 282 deletions

View File

@@ -1,10 +1,14 @@
package com.accompany.business.vo; package com.accompany.business.vo;
import com.accompany.common.annotation.ReplaceAppDomain; import com.accompany.common.annotation.ReplaceAppDomain;
import com.accompany.core.annotation.I18n;
import lombok.Data;
@Data
public class HallMemberAuthVo { public class HallMemberAuthVo {
private String code; private String code;
@I18n(className = "HallMemberAuth")
private String name; private String name;
@ReplaceAppDomain @ReplaceAppDomain
@@ -20,55 +24,4 @@ public class HallMemberAuthVo {
private Byte sort; private Byte sort;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getMinImage() {
return minImage;
}
public void setMinImage(String minImage) {
this.minImage = minImage;
}
public String getMaxImage() {
return maxImage;
}
public void setMaxImage(String maxImage) {
this.maxImage = maxImage;
}
public String getDescription() {return description;}
public void setDescription(String description) {this.description = description;}
public Byte getSort() {
return sort;
}
public void setSort(Byte sort) {
this.sort = sort;
}
} }

View File

@@ -1,23 +0,0 @@
package com.accompany.business.vo.clan;
import com.accompany.business.vo.hall.HallVo;
import lombok.Data;
import java.util.List;
import java.util.Map;
@Data
public class ClanHallMemberGoldFlowTotalVO {
private Double total = 0d;
private Map<Long, HallMemberGoldFlowTotalVO> hallMemberMap;
private List<HallVo> hallVoList;
private Double totalRemainGolds = 0d;
private Double totalEarnGolds = 0d;
private Double totalGiftGolds = 0d;
private Double totalExchangeGolds = 0d;
}

View File

@@ -1,17 +0,0 @@
package com.accompany.business.vo.clan;
import com.accompany.business.vo.hall.HallVo;
import lombok.Data;
import java.util.List;
@Data
public class ClanHallMemberGoldSettlementTotalVO {
private Double total = 0d;
private List<ClanHallMemberGoldSettlementVO> memberSettlement;
private List<HallVo> hallVoList;
}

View File

@@ -1,21 +0,0 @@
package com.accompany.business.vo.clan;
import com.accompany.common.annotation.ReplaceAppDomain;
import lombok.Data;
@Data
public class ClanHallMemberGoldSettlementVO {
private Long uid;
private String nick;
@ReplaceAppDomain
private String avatar;
private Double exchangeGolds;
private Double settlementGolds;
private Long hallId;
private Long hallOwnerUid;
private String hallAvatar;
private String hallName;
}

View File

@@ -1,33 +0,0 @@
/*
* 文 件 名: ClanMemberListVO
* 版 权:
* 描 述: <描述>
* 创建人: H1
* 创建时间: 2020/11/19
* 修改人:
* 修改内容:
* 修改时间:
*/
package com.accompany.business.vo.clan;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* <br>类描述:
* <br>功能详细描述:
*
* @author H1
* @date [2020/11/19]
*/
@ApiModel
@Data
public class ClanMemberListVO {
@ApiModelProperty(value = "成员列表")
private List<ClanMemberVO> members;
@ApiModelProperty(value = "成员总数")
private Integer count;
}

View File

@@ -1,14 +0,0 @@
package com.accompany.business.vo.clan;
import lombok.Data;
import java.util.List;
@Data
public class HallMemberGoldFlowTotalVO {
private Double total = 0d;
private List<HallMemberGoldFlowVO> hallMember;
}

View File

@@ -14,6 +14,7 @@ import com.accompany.business.vo.message.HallMessage;
import com.accompany.common.constant.Constant; import com.accompany.common.constant.Constant;
import com.accompany.common.redis.RedisKey; import com.accompany.common.redis.RedisKey;
import com.accompany.common.status.BusiStatus; import com.accompany.common.status.BusiStatus;
import com.accompany.core.exception.ServiceException;
import com.accompany.core.service.base.BaseService; import com.accompany.core.service.base.BaseService;
import com.accompany.core.util.StringUtils; import com.accompany.core.util.StringUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
@@ -59,9 +60,6 @@ public class HallAuthService extends BaseService {
@Autowired @Autowired
private HallRoleAuthBizService hallRoleAuthBizService; private HallRoleAuthBizService hallRoleAuthBizService;
@Autowired
private HallMemberService hallMemberService;
/** /**
* 查询模厅首页 * 查询模厅首页
* *
@@ -70,36 +68,33 @@ public class HallAuthService extends BaseService {
*/ */
public List<HallMemberAuthVo> getHallMenusByUid(Long uid) { public List<HallMemberAuthVo> getHallMenusByUid(Long uid) {
Set<String> menus = this.jedisService.zrangeMembers(RedisKey.hall_member_menus.getKey(uid.toString()), 0, -1); Set<String> menus = this.jedisService.zrangeMembers(RedisKey.hall_member_menus.getKey(uid.toString()), 0, -1);
if (CollectionUtils.isEmpty(menus)) { if (!CollectionUtils.isEmpty(menus)) {
List<Byte> list = new ArrayList(2); return menus.stream().map(menu->JSON.parseObject(menu, HallMemberAuthVo.class)).collect(Collectors.toList());
list.add(Constant.HallAuthType.MENU);
list.add(Constant.HallAuthType.RESOURCE_MENU);
HallMemberAuthExample example = new HallMemberAuthExample();
example.createCriteria().andUidEqualTo(uid).andAuthTypeIn(list).andStatusEqualTo(Constant.HallAuthStatus.AUTH_EXISTS);
example.setOrderByClause("sort asc");
List<HallMemberAuth> memberAuths = this.hallMemberAuthMapper.selectByExample(example);
List<HallMemberAuthVo> authVoList = Lists.newArrayList();
if (CollectionUtils.isEmpty(memberAuths)) {
return null;
}
Map<String, Double> sortSetMap = new HashMap<String, Double>();
memberAuths.stream().forEach(memberAuth -> {
HallMemberAuthVo authVo = converToHallMemberAuthVo(memberAuth);
authVoList.add(authVo);
sortSetMap.put(JSON.toJSONString(authVo), Double.parseDouble(authVo.getSort() == null ? "0" : authVo.getSort().toString()));
});
this.jedisService.zadd(RedisKey.hall_member_menus.getKey(uid.toString()), sortSetMap, true);
this.jedisService.expire(RedisKey.hall_member_menus.getKey(uid.toString()), Constant.HallKeySaveDate.hall_member_menus);
return authVoList;
} else {
List<HallMemberAuthVo> authVoList = Lists.newArrayList();
menus.stream().forEach(menu -> authVoList.add(JSON.parseObject(menu, HallMemberAuthVo.class)));
return authVoList;
} }
List<Byte> list = new ArrayList(2);
list.add(Constant.HallAuthType.MENU);
list.add(Constant.HallAuthType.RESOURCE_MENU);
HallMemberAuthExample example = new HallMemberAuthExample();
example.createCriteria().andUidEqualTo(uid).andAuthTypeIn(list).andStatusEqualTo(Constant.HallAuthStatus.AUTH_EXISTS);
example.setOrderByClause("sort asc");
List<HallMemberAuth> memberAuths = this.hallMemberAuthMapper.selectByExample(example);
if (CollectionUtils.isEmpty(memberAuths)) {
return null;
}
List<HallMemberAuthVo> authVoList = Lists.newArrayList();
Map<String, Double> sortSetMap = new HashMap<String, Double>();
memberAuths.stream().forEach(memberAuth -> {
HallMemberAuthVo authVo = converToHallMemberAuthVo(memberAuth);
authVoList.add(authVo);
sortSetMap.put(JSON.toJSONString(authVo), Double.parseDouble(authVo.getSort() == null ? "0" : authVo.getSort().toString()));
});
this.jedisService.zadd(RedisKey.hall_member_menus.getKey(uid.toString()), sortSetMap, true);
this.jedisService.expire(RedisKey.hall_member_menus.getKey(uid.toString()), Constant.HallKeySaveDate.hall_member_menus);
return authVoList;
} }
@@ -203,22 +198,22 @@ public class HallAuthService extends BaseService {
* @return authSets不包含"高管成员通用"的权限,所以在添加权限时,要把"高管成员通用"权限也设置进去 * @return authSets不包含"高管成员通用"的权限,所以在添加权限时,要把"高管成员通用"权限也设置进去
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int setHallManagerAuths(Long uid, Long managerUid, Long hallId, List<String> authSets) throws Exception { public void setHallManagerAuths(Long uid, Long managerUid, Long hallId, List<String> authSets) {
if (CollectionUtils.isEmpty(authSets)) { if (CollectionUtils.isEmpty(authSets)) {
setMemberAuthIsNull(hallId, authSets, managerUid); setMemberAuthIsNull(hallId, authSets, managerUid);
return BusiStatus.SUCCESS.value(); return ;
} }
byte[] roles = {Constant.HallAuthRoleType.OWNER_MANAGER, Constant.HallAuthRoleType.MANAGER, Constant.HallAuthRoleType.CLAN_ELDER_OWNER_MANAGER}; byte[] roles = {Constant.HallAuthRoleType.OWNER_MANAGER, Constant.HallAuthRoleType.MANAGER, Constant.HallAuthRoleType.CLAN_ELDER_OWNER_MANAGER};
List<HallAuth> auths = getHallAuths(roles, null); List<HallAuth> auths = getHallAuths(roles, null);
if (CollectionUtils.isEmpty(auths)) { if (CollectionUtils.isEmpty(auths)) {
return BusiStatus.HALL_MANAGER_NOT_FOUND_MENU_AUTH.value(); throw new ServiceException(BusiStatus.HALL_MANAGER_NOT_FOUND_MENU_AUTH);
} }
HallMember hallmember = hallService.getHallMember(managerUid); HallMember hallmember = hallService.getHallMember(managerUid);
if (hallmember == null || !hallmember.getRoleType().equals(Constant.HallRoleType.MANAGER)) { if (hallmember == null || !hallmember.getRoleType().equals(Constant.HallRoleType.MANAGER)) {
return BusiStatus.HALL_MANAGER_NOT_FOUND.value(); throw new ServiceException(BusiStatus.HALL_MANAGER_NOT_FOUND);
} }
if (!hallmember.getHallId().equals(hallId)) { if (!hallmember.getHallId().equals(hallId)) {
return BusiStatus.HALL_MANAGER_NOT_BELONG.value(); throw new ServiceException(BusiStatus.HALL_MANAGER_NOT_BELONG);
} }
Map<String, String> memberAuthMap = authSets.stream().collect(Collectors.toMap(String::toString, a -> a, (k1, k2) -> k1)); Map<String, String> memberAuthMap = authSets.stream().collect(Collectors.toMap(String::toString, a -> a, (k1, k2) -> k1));
Map<String, Double> sortSetMap = new HashMap<>(); Map<String, Double> sortSetMap = new HashMap<>();
@@ -295,7 +290,6 @@ public class HallAuthService extends BaseService {
this.jedisService.zadd(RedisKey.hall_member_menus.getKey(managerUid.toString()), sortSetMap, true); this.jedisService.zadd(RedisKey.hall_member_menus.getKey(managerUid.toString()), sortSetMap, true);
this.jedisService.expire(RedisKey.hall_member_menus.getKey(uid.toString()), Constant.HallKeySaveDate.hall_member_menus); this.jedisService.expire(RedisKey.hall_member_menus.getKey(uid.toString()), Constant.HallKeySaveDate.hall_member_menus);
} }
return BusiStatus.SUCCESS.value();
} }
/** /**
@@ -420,7 +414,7 @@ public class HallAuthService extends BaseService {
* @throws Exception * @throws Exception
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void addAuth(HallAuth auth, Boolean ownerNeedSet) throws Exception { public void addAuth(HallAuth auth, Boolean ownerNeedSet) {
auth.setCreateTime(new Date()); auth.setCreateTime(new Date());
hallAuthMapper.insert(auth); hallAuthMapper.insert(auth);
List<HallMemberAuth> list = null; List<HallMemberAuth> list = null;

View File

@@ -4,6 +4,7 @@ package com.accompany.business.controller.hall;
* Created by wangChuangBiao on 2018/12/29. * Created by wangChuangBiao on 2018/12/29.
*/ */
import com.accompany.business.common.BaseController;
import com.accompany.business.model.HallAuth; import com.accompany.business.model.HallAuth;
import com.accompany.business.model.HallMember; import com.accompany.business.model.HallMember;
import com.accompany.business.service.hall.HallAuthService; import com.accompany.business.service.hall.HallAuthService;
@@ -15,6 +16,7 @@ import com.accompany.common.annotation.MemberAuth;
import com.accompany.common.constant.Constant; import com.accompany.common.constant.Constant;
import com.accompany.common.result.BusiResult; import com.accompany.common.result.BusiResult;
import com.accompany.common.status.BusiStatus; import com.accompany.common.status.BusiStatus;
import com.accompany.core.exception.ServiceException;
import com.accompany.core.util.StringUtils; import com.accompany.core.util.StringUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -30,7 +32,7 @@ import java.util.stream.Collectors;
@RequestMapping("/hallAuth") @RequestMapping("/hallAuth")
@RestController @RestController
public class HallAuthController { public class HallAuthController extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(HallAuthController.class); private static final Logger logger = LoggerFactory.getLogger(HallAuthController.class);
@@ -42,28 +44,10 @@ public class HallAuthController {
@RequestMapping(value = "getHallMenusByUid", method = RequestMethod.POST) @RequestMapping(value = "getHallMenusByUid", method = RequestMethod.POST)
@Authorization @Authorization
public BusiResult getHallMenusByUid(Long uid, HttpServletRequest request) { public BusiResult getHallMenusByUid(HttpServletRequest request) {
logger.info("getHallMenusByUid, uid={}", uid); Long uid = getUid(request);
BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); List<HallMemberAuthVo> vos = hallAuthService.getHallMenusByUid(uid);
if (uid == null || uid == 0L) { return BusiResult.success(vos);
busiResult.setCode(BusiStatus.PARAMETERILLEGAL.value());
return busiResult;
}
try {
List<HallMemberAuthVo> vos = hallAuthService.getHallMenusByUid(uid);
if (!CollectionUtils.isEmpty(vos)) {
if ((StringUtils.isNotEmpty(request.getParameter("os"))
&& "ios".equals(request.getParameter("os").toLowerCase())
) || vos.size() > 3) {
vos = vos.stream().filter(vo -> !vo.getCode().equals(Constant.HallAuthCode.HALL_BUILD)).collect(Collectors.toList());
}
}
busiResult.setData(vos);
} catch (Exception e) {
logger.error("Failed to getHallMenusByUid. Cause by {}", e.getMessage());
return new BusiResult(BusiStatus.SERVERERROR);
}
return busiResult;
} }
/** /**
@@ -75,43 +59,29 @@ public class HallAuthController {
@Authorization @Authorization
public BusiResult getHallManagerAuths(Long uid, Long managerUid) { public BusiResult getHallManagerAuths(Long uid, Long managerUid) {
logger.info("getHallManagerAuths, uid={},managerUid{}", uid, managerUid); logger.info("getHallManagerAuths, uid={},managerUid{}", uid, managerUid);
BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS);
if (uid == null || uid == 0L && managerUid == null || managerUid == 0L) { if (uid == null || uid == 0L && managerUid == null || managerUid == 0L) {
busiResult.setCode(BusiStatus.PARAMETERILLEGAL.value()); throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
busiResult.setMessage("参数异常");
return busiResult;
} }
try { List<HallManagerAuthVo> managerAuthVos = hallAuthService.getHallManagerAuths(uid, managerUid);
List<HallManagerAuthVo> managerAuthVos = hallAuthService.getHallManagerAuths(uid, managerUid); if (managerAuthVos == null) {
if (managerAuthVos == null) { throw new ServiceException(BusiStatus.HALL_MANAGER_NOT_FOUND_MENU_AUTH);
busiResult.setCode(BusiStatus.HALL_MANAGER_NOT_FOUND_MENU_AUTH.value());
busiResult.setMessage("高管权限为空");
} else {
busiResult.setData(managerAuthVos);
}
} catch (Exception e) {
logger.error("Failed to getHallManagerAuths. Cause by " + e.getMessage(), e);
return new BusiResult(BusiStatus.SERVERERROR);
} }
return busiResult; return BusiResult.success(managerAuthVos);
} }
@PostMapping("getHallAuths") @PostMapping("getHallAuths")
@Authorization @Authorization
public BusiResult<List<HallManagerAuthVo>> getHallAuths(Long uid, Integer roleType, Long hallId) { public BusiResult<List<HallManagerAuthVo>> getHallAuths(HttpServletRequest request) {
logger.info("getHallAuths, uid={},roleType{}", uid, roleType); Long uid = getUid(request);
if (uid == null || uid == 0L) { if (uid == null || uid == 0L) {
return BusiResult.fail(BusiStatus.PARAMETERILLEGAL); throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
} }
HallMember hallMember = hallService.getHallMember(uid); HallMember hallMember = hallService.getHallMember(uid);
if (null != hallMember) { if (null == hallMember){
roleType = hallMember.getRoleType().intValue(); return BusiResult.success();
if (null == hallId) {
hallId = hallMember.getHallId();
}
} }
List<HallManagerAuthVo> managerAuths = hallAuthService.getHallAuths(uid, roleType, hallId); List<HallManagerAuthVo> managerAuths = hallAuthService.getHallAuths(uid, hallMember.getRoleType().intValue(), hallMember.getHallId());
if (managerAuths == null) { if (managerAuths == null) {
return BusiResult.fail(BusiStatus.HALL_MANAGER_NOT_FOUND_MENU_AUTH); return BusiResult.fail(BusiStatus.HALL_MANAGER_NOT_FOUND_MENU_AUTH);
} }
@@ -127,21 +97,12 @@ public class HallAuthController {
@Authorization @Authorization
@MemberAuth(authCode = Constant.HallAuthCode.HALL_MANAGER_SET) @MemberAuth(authCode = Constant.HallAuthCode.HALL_MANAGER_SET)
public BusiResult<Void> setHallManagerAuths(Long uid, Long managerUid, Long hallId, String authStr) { public BusiResult<Void> setHallManagerAuths(Long uid, Long managerUid, Long hallId, String authStr) {
logger.info("setHallManagerAuths, uid={},managerUid{},authStr={}", uid, managerUid, authStr);
BusiResult<Void> busiResult = new BusiResult<>(BusiStatus.SUCCESS);
if (uid == null || uid == 0L && managerUid == null || managerUid == 0L) { if (uid == null || uid == 0L && managerUid == null || managerUid == 0L) {
busiResult.setCode(BusiStatus.PARAMETERILLEGAL.value()); throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
busiResult.setMessage("参数异常");
return busiResult;
} }
try { List<String> authSets = Arrays.stream(authStr.split(",")).filter(string -> !string.isEmpty()).collect(Collectors.toList());
List<String> authSets = Arrays.stream(authStr.split(",")).filter(string -> !string.isEmpty()).collect(Collectors.toList()); hallAuthService.setHallManagerAuths(uid, managerUid, hallId, authSets);
busiResult.setCode(hallAuthService.setHallManagerAuths(uid, managerUid, hallId, authSets)); return BusiResult.success();
} catch (Exception e) {
logger.error("Failed to setHallManagerAuths. Cause by :" + e.getMessage(), e);
return new BusiResult<>(BusiStatus.SERVERERROR);
}
return busiResult;
} }
@@ -154,34 +115,18 @@ public class HallAuthController {
*/ */
@RequestMapping(value = "addAuth", method = RequestMethod.POST) @RequestMapping(value = "addAuth", method = RequestMethod.POST)
@Authorization @Authorization
public BusiResult addAuth(@RequestBody HallAuth auth, @RequestParam(defaultValue = "true") Boolean needOwnerSet) { public BusiResult<Void> addAuth(@RequestBody HallAuth auth, @RequestParam(defaultValue = "true") Boolean needOwnerSet) {
logger.info("addAuth, addAuth={}", JSON.toJSONString(auth));
BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS);
if (auth == null || StringUtils.isEmpty(auth.getCode()) || StringUtils.isEmpty(auth.getName()) || auth.getRoleType() == null) { if (auth == null || StringUtils.isEmpty(auth.getCode()) || StringUtils.isEmpty(auth.getName()) || auth.getRoleType() == null) {
busiResult.setCode(BusiStatus.PARAMETERILLEGAL.value()); throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
busiResult.setMessage("参数异常");
return busiResult;
} }
try { hallAuthService.addAuth(auth, needOwnerSet);
hallAuthService.addAuth(auth, needOwnerSet); return BusiResult.success();
} catch (Exception e) {
logger.error("Failed to setHallManagerAuths. Cause by :" + e.getMessage(), e);
return new BusiResult(BusiStatus.SERVERERROR);
}
return busiResult;
} }
@RequestMapping(value = "updateData", method = RequestMethod.POST) @RequestMapping(value = "updateData", method = RequestMethod.POST)
@Authorization @Authorization
public BusiResult updateAuth() { public BusiResult<Void> updateAuth() {
BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); hallAuthService.updateData();
return BusiResult.success();
try {
hallAuthService.updateData();
} catch (Exception e) {
logger.error("Failed to updateAuth. Cause by {}", e.getMessage());
return new BusiResult(BusiStatus.SERVERERROR);
}
return busiResult;
} }
} }