Commit 272c3fc7 by 周海峰

添加公告角色方法

parent 5fc73721
...@@ -104,7 +104,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -104,7 +104,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
"/api/ps/account_sel/**", "/znzl/file/**", "/auth/v1/**", "/auth/user/**", "/api/ps/account_sel/**", "/znzl/file/**", "/auth/v1/**", "/auth/user/**",
"/error/**", "/weixin/wxuserinfo/**", "/weixin/information/**", "/auth/dt/**", "/error/**", "/weixin/wxuserinfo/**", "/weixin/information/**", "/auth/dt/**",
"/avatar/**", "/user/updateWxPlatformPersonnelByAccount", "/wechatApi/**", "/avatar/**", "/user/updateWxPlatformPersonnelByAccount", "/wechatApi/**",
"/PlatformUserFavoriteAppsController/**" "/PlatformUserFavoriteAppsController/**", "/roleuser/addUserNoticeRole"
).permitAll() ).permitAll()
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll() .antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
......
...@@ -27,17 +27,19 @@ import com.metro.auth.platform.domain.ResultJson; ...@@ -27,17 +27,19 @@ import com.metro.auth.platform.domain.ResultJson;
import com.metro.auth.platform.domain.auth.PlatformPersonnel; import com.metro.auth.platform.domain.auth.PlatformPersonnel;
import com.metro.auth.platform.domain.auth.PlatformSysRole; import com.metro.auth.platform.domain.auth.PlatformSysRole;
import com.metro.auth.platform.domain.auth.PlatformSysUserRole; import com.metro.auth.platform.domain.auth.PlatformSysUserRole;
import com.metro.auth.platform.outlineapi.PlatformUrlManager;
import com.metro.auth.platform.service.PlatformRoleUserService; import com.metro.auth.platform.service.PlatformRoleUserService;
import org.apache.catalina.LifecycleState;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
/** /**
* @ClassName: PlatformRoleUserController * @ClassName: PlatformRoleUserController
* @Description: ${description} * @Description: ${description}
* @Authror zhouy * @Authror zhouy
* @Date 2019-09-11 17:17 * @Date 2019-09-11 17:17
*/ */
...@@ -49,10 +51,10 @@ public class PlatformRoleUserController { ...@@ -49,10 +51,10 @@ public class PlatformRoleUserController {
@Resource @Resource
PlatformRoleUserService platformRoleUserService; PlatformRoleUserService platformRoleUserService;
/** /**
* 功能描述: <br>权限-用户列表 * 功能描述: <br>权限-用户列表
* 〈〉 * 〈〉
*
* @Param: [pageNum, pageSize, platformSysRole] * @Param: [pageNum, pageSize, platformSysRole]
* @Return: [pageNum, pageSize, platformSysRole] * @Return: [pageNum, pageSize, platformSysRole]
* @Author: zhouy * @Author: zhouy
...@@ -60,16 +62,17 @@ public class PlatformRoleUserController { ...@@ -60,16 +62,17 @@ public class PlatformRoleUserController {
*/ */
@GetMapping("/pagedlist") @GetMapping("/pagedlist")
public ResultJson pagedlist(@RequestParam(required=true,value="pageNum",defaultValue="1") int pageNum, public ResultJson pagedlist(@RequestParam(required = true, value = "pageNum", defaultValue = "1") int pageNum,
@RequestParam(required=true,value="pageSize",defaultValue="15") int pageSize, @RequestParam(required = true, value = "pageSize", defaultValue = "15") int pageSize,
PlatformSysRole platformSysRole){ PlatformSysRole platformSysRole) {
PageInfo<PlatformSysRole> page = platformRoleUserService.pageRoledlist(platformSysRole,pageNum,pageSize); PageInfo<PlatformSysRole> page = platformRoleUserService.pageRoledlist(platformSysRole, pageNum, pageSize);
return ResultJson.ok(page); return ResultJson.ok(page);
} }
/** /**
* 功能描述: <br>权限-用户列表 * 功能描述: <br>权限-用户列表
* 〈〉 * 〈〉
*
* @Param: [pageNum, pageSize, platformSysRole] * @Param: [pageNum, pageSize, platformSysRole]
* @Return: [pageNum, pageSize, platformSysRole] * @Return: [pageNum, pageSize, platformSysRole]
* @Author: zhouy * @Author: zhouy
...@@ -77,10 +80,10 @@ public class PlatformRoleUserController { ...@@ -77,10 +80,10 @@ public class PlatformRoleUserController {
*/ */
@GetMapping("/roleuserpagedlist") @GetMapping("/roleuserpagedlist")
public ResultJson roleuserpagedlist(@RequestParam(required=true,value="pageNum",defaultValue="1") int pageNum, public ResultJson roleuserpagedlist(@RequestParam(required = true, value = "pageNum", defaultValue = "1") int pageNum,
@RequestParam(required=true,value="pageSize",defaultValue="15") int pageSize, @RequestParam(required = true, value = "pageSize", defaultValue = "15") int pageSize,
PlatformPersonnel platformPersonnel){ PlatformPersonnel platformPersonnel) {
PageInfo<PlatformPersonnel> page = platformRoleUserService.roleuserpagedlist(platformPersonnel,pageNum,pageSize); PageInfo<PlatformPersonnel> page = platformRoleUserService.roleuserpagedlist(platformPersonnel, pageNum, pageSize);
return ResultJson.ok(page); return ResultJson.ok(page);
} }
...@@ -88,18 +91,20 @@ public class PlatformRoleUserController { ...@@ -88,18 +91,20 @@ public class PlatformRoleUserController {
/** /**
* 周海峰 * 周海峰
* 获取角色下的所有用户 * 获取角色下的所有用户
*
* @param platformPersonnel * @param platformPersonnel
* @return * @return
*/ */
@GetMapping("/roleuserlist") @GetMapping("/roleuserlist")
public ResultJson roleuserpagedlist(PlatformPersonnel platformPersonnel){ public ResultJson roleuserpagedlist(PlatformPersonnel platformPersonnel) {
List<PlatformSysUserRole> page = platformRoleUserService.roleuserlist(platformPersonnel); List<PlatformSysUserRole> page = platformRoleUserService.roleuserlist(platformPersonnel);
return ResultJson.ok(page); return ResultJson.ok(page);
} }
/** /**
* 功能描述: <br>更新权限角色 * 功能描述: <br>更新权限角色
* 〈〉 * 〈〉
*
* @Param: [platformSysRole] * @Param: [platformSysRole]
* @Return: [platformSysRole] * @Return: [platformSysRole]
* @Author: zhouy * @Author: zhouy
...@@ -107,32 +112,33 @@ public class PlatformRoleUserController { ...@@ -107,32 +112,33 @@ public class PlatformRoleUserController {
*/ */
@RequestMapping("/editroleuser") @RequestMapping("/editroleuser")
public ResultJson editroleuser(@RequestBody PlatformSysUserRole platformSysUserRole){ public ResultJson editroleuser(@RequestBody PlatformSysUserRole platformSysUserRole) {
int count =platformRoleUserService.editroleuser(platformSysUserRole); int count = platformRoleUserService.editroleuser(platformSysUserRole);
if (count>0){ if (count > 0) {
return ResultJson.ok(); return ResultJson.ok();
}else { } else {
return ResultJson.failure(ResultCode.RESPONSE_ERROR); return ResultJson.failure(ResultCode.RESPONSE_ERROR);
} }
} }
@RequestMapping("/delUserRole") @RequestMapping("/delUserRole")
public ResultJson delUserRole(@RequestBody PlatformSysUserRole platformSysUserRole){ public ResultJson delUserRole(@RequestBody PlatformSysUserRole platformSysUserRole) {
int count =platformRoleUserService.delUserRole(platformSysUserRole); int count = platformRoleUserService.delUserRole(platformSysUserRole);
if (count>0){ if (count > 0) {
return ResultJson.ok(); return ResultJson.ok();
}else { } else {
return ResultJson.failure(ResultCode.RESPONSE_ERROR); return ResultJson.failure(ResultCode.RESPONSE_ERROR);
} }
} }
@RequestMapping("/addroleuser") @RequestMapping("/addroleuser")
public ResultJson addroleuser(@RequestBody PlatformSysUserRole platformSysUserRole){ public ResultJson addroleuser(@RequestBody PlatformSysUserRole platformSysUserRole) {
int count =platformRoleUserService.addroleuser(platformSysUserRole); int count = platformRoleUserService.addroleuser(platformSysUserRole);
if (count>0){ if (count > 0) {
return ResultJson.ok(); return ResultJson.ok();
}else { } else {
return ResultJson.failure(ResultCode.RESPONSE_ERROR); return ResultJson.failure(ResultCode.RESPONSE_ERROR);
} }
...@@ -141,18 +147,47 @@ public class PlatformRoleUserController { ...@@ -141,18 +147,47 @@ public class PlatformRoleUserController {
/** /**
* 周海峰20200307 * 周海峰20200307
* 保存角色用户信息(单角色多用户) * 保存角色用户信息(单角色多用户)
*
* @param map * @param map
* @return * @return
*/ */
@RequestMapping("/editUserRoleList") @RequestMapping("/editUserRoleList")
public ResultJson editUserRoleList(@RequestBody Map<String,String> map ){ public ResultJson editUserRoleList(@RequestBody Map<String, String> map) {
int count =platformRoleUserService.editUserRoleList(map); int count = platformRoleUserService.editUserRoleList(map);
if (count>0){ if (count > 0) {
return ResultJson.ok(); return ResultJson.ok();
}else { } else {
return ResultJson.failure(ResultCode.SERVER_ERROR); return ResultJson.failure(ResultCode.SERVER_ERROR);
} }
} }
/**
* 给用户添加公告角色
*
* @param map 用户ID
*/
@PostMapping("/addUserNoticeRole")
public ResultJson addUserNoticeRole(@RequestBody Map<String, String> map) {
String roleId = PlatformUrlManager.notice_role_id;
String userId = map.get("userId");
PlatformPersonnel req = new PlatformPersonnel();
req.setId(Integer.parseInt(userId));
List<PlatformSysUserRole> platformSysUserRoles = platformRoleUserService.userRoleList(req);
List<String> collect = platformSysUserRoles.stream()
.map(PlatformSysUserRole::getRoleId)
.collect(Collectors.toList());
if (!collect.isEmpty() && collect.contains(roleId)) {
// 用户已拥有该角色,直接返回成功
return ResultJson.ok();
}
String id = UUID.randomUUID().toString().replace("-", "");
PlatformSysUserRole platformSysUserRole = new PlatformSysUserRole(id, Integer.parseInt(userId), roleId);
int count = platformRoleUserService.addUserRole(platformSysUserRole);
if (count > 0) {
return ResultJson.ok();
} else {
return ResultJson.failure(ResultCode.SERVER_ERROR);
}
}
} }
...@@ -169,6 +169,17 @@ public class PlatformUrlManager { ...@@ -169,6 +169,17 @@ public class PlatformUrlManager {
*/ */
public static String API_USER_LOGIN_URL; public static String API_USER_LOGIN_URL;
/**
* 公告发布角色ID
*/
public static String notice_role_id;
@Value("${notice-manage.notice_role_id}")
public void setNotice_role_id(String notice_role_id) {
PlatformUrlManager.notice_role_id = notice_role_id;
}
@Value("${weixin-params.wx_sToken}") @Value("${weixin-params.wx_sToken}")
public void setWxSToken(String wxSToken) {WX_sToken = wxSToken;} public void setWxSToken(String wxSToken) {WX_sToken = wxSToken;}
......
...@@ -95,11 +95,6 @@ public class PlatformApplicationsServiceImpl implements PlatformApplicationsServ ...@@ -95,11 +95,6 @@ public class PlatformApplicationsServiceImpl implements PlatformApplicationsServ
example.createCriteria().andQyflagEqualTo("1"); example.createCriteria().andQyflagEqualTo("1");
List<PlatformApplications> allApplications = platformApplicationsMapper.selectByExample(example); List<PlatformApplications> allApplications = platformApplicationsMapper.selectByExample(example);
// 2. 将所有应用转换为以ID为Key的Map,方便后续快速查找
// 使用 Collectors.toMap 是一个高效且清晰的做法
Map<Integer, PlatformApplications> appMap = allApplications.stream()
.collect(Collectors.toMap(PlatformApplications::getId, app -> app));
// 3. 安全地解析userid并查询用户角色 // 3. 安全地解析userid并查询用户角色
Set<String> roleIds = new HashSet<>(); Set<String> roleIds = new HashSet<>();
int userIdInt = Integer.parseInt(userid); int userIdInt = Integer.parseInt(userid);
......
...@@ -31,7 +31,7 @@ import java.util.Map; ...@@ -31,7 +31,7 @@ import java.util.Map;
/** /**
* @ClassName: PlatformRoleUserService * @ClassName: PlatformRoleUserService
* @Description: ${description} * @Description: ${description}
* @Authror zhouy * @Authror zhouy
* @Date 2019-09-11 17:19 * @Date 2019-09-11 17:19
*/ */
...@@ -40,9 +40,30 @@ public interface PlatformRoleUserService { ...@@ -40,9 +40,30 @@ public interface PlatformRoleUserService {
PageInfo<PlatformSysRole> pageRoledlist(PlatformSysRole platformSysRole, int pageNum, int pageSize); PageInfo<PlatformSysRole> pageRoledlist(PlatformSysRole platformSysRole, int pageNum, int pageSize);
int editroleuser(PlatformSysUserRole platformSysUserRole); int editroleuser(PlatformSysUserRole platformSysUserRole);
int delUserRole(PlatformSysUserRole platformSysUserRole); int delUserRole(PlatformSysUserRole platformSysUserRole);
int editUserRoleList(Map<String,String> map);
PageInfo<PlatformPersonnel> roleuserpagedlist(PlatformPersonnel platformPersonnel,int pageNum, int pageSize); int editUserRoleList(Map<String, String> map);
PageInfo<PlatformPersonnel> roleuserpagedlist(PlatformPersonnel platformPersonnel, int pageNum, int pageSize);
List<PlatformSysUserRole> roleuserlist(PlatformPersonnel platformPersonnel); List<PlatformSysUserRole> roleuserlist(PlatformPersonnel platformPersonnel);
int addroleuser(PlatformSysUserRole platformSysUserRole); int addroleuser(PlatformSysUserRole platformSysUserRole);
/**
* 功能描述: <br>根据用户查询用户角色列表
*
* @param platformPersonnel
* @return
*/
List<PlatformSysUserRole> userRoleList(PlatformPersonnel platformPersonnel);
/**
* 功能描述: <br>新增用户角色
*
* @param platformSysUserRole
* @return
*/
int addUserRole(PlatformSysUserRole platformSysUserRole);
} }
...@@ -119,6 +119,8 @@ metro-daily: ...@@ -119,6 +119,8 @@ metro-daily:
daily_entity_url : ${IP.url-daily}/md/MetroDailyAssembleController/metroDailyAssemble daily_entity_url : ${IP.url-daily}/md/MetroDailyAssembleController/metroDailyAssemble
#公告 #公告
notice-manage: notice-manage:
# 公告系统调用设置角色方法时,设置的角色id
notice_role_id: db0a394ec1af4ebba6cb85be1043eb7d
#栏目全部列表 #栏目全部列表
api_column_url : ${IP.url-notice}/NoticeManage/api/portalController/listColumn api_column_url : ${IP.url-notice}/NoticeManage/api/portalController/listColumn
#栏目列表-可见范围内 #栏目列表-可见范围内
......
...@@ -114,6 +114,8 @@ metro-daily: ...@@ -114,6 +114,8 @@ metro-daily:
daily_entity_url : http://10.12.111.48:6107/znzl/MetroDailyAssembleController/metroDailyAssemble daily_entity_url : http://10.12.111.48:6107/znzl/MetroDailyAssembleController/metroDailyAssemble
notice-manage: notice-manage:
# 公告系统调用设置角色方法时,设置的角色id
notice_role_id: db0a394ec1af4ebba6cb85be1043eb7d
#栏目全部列表 #栏目全部列表
api_column_url : http://localhost:9083/NoticeManage/api/portalController/listColumn api_column_url : http://localhost:9083/NoticeManage/api/portalController/listColumn
#栏目列表-可见范围内 #栏目列表-可见范围内
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论