当前位置: 首页 > news >正文

佛山市外贸网站建设培训网站

佛山市外贸网站建设,培训网站,wordpress webim,怎么做网络彩票网站用户关联角色操作 从前台发送请求 <a href"${pageContext.request.contextPath}/user/findUserByIdAndAllRole.do?id${user.id}" class"btn bg-olive btn-xs">添加角色</a>查询用户以及用户可以添加的角色 usercontroller //查询用户以及用…

用户关联角色操作

从前台发送请求

<a href="${pageContext.request.contextPath}/user/findUserByIdAndAllRole.do?id=${user.id}" class="btn bg-olive btn-xs">添加角色</a>

查询用户以及用户可以添加的角色

usercontroller

    //查询用户以及用户可以添加的角色@RequestMapping("/findUserByIdAndAllRole.do")public ModelAndView findUserByIdAndAllRole(@RequestParam(name = "id", required = true) String userid) throws Exception {ModelAndView mv = new ModelAndView();//1.根据用户id查询用户UserInfo userInfo = userService.findById(userid);//2.根据用户id查询可以添加的角色List<Role> otherRoles = userService.findOtherRoles(userid);mv.addObject("user", userInfo);mv.addObject("roleList", otherRoles);mv.setViewName("user-role-add");return mv;}

UserServiceImpl

  @Overridepublic UserInfo findById(String id) throws Exception {return userDao.findById(id);}@Overridepublic List<Role> findOtherRoles(String userid) throws Exception {return userDao.findOtherRoles(userid);}

IUserDao

    @Select("select * from users where id=#{id}")@Results({@Result(id = true, property = "id", column = "id"),@Result(property = "username", column = "username"),@Result(property = "email", column = "email"),@Result(property = "password", column = "password"),@Result(property = "phoneNum", column = "phoneNum"),@Result(property = "status", column = "status"),@Result(property = "roles",column = "id",javaType = java.util.List.class,many = @Many(select = "com.itheima.ssm.dao.IRoleDao.findRoleByUserId"))})UserInfo findById(String id) throws Exception;@Select("select * from role where id not in (select roleId from users_role where userId=#{userId})")List<Role> findOtherRoles(String userId) throws Exception;//@Param 有两个int参数mybaties不知道怎末匹配@Insert("insert into users_role(userId,roleId) values(#{userId},#{roleId})")

给用户添加角色

usercontroller

//给用户添加角色@RequestMapping("/addRoleToUser.do")public String addRoleToUser(@RequestParam(name = "userId", required = true) String userId, @RequestParam(name = "ids", required = true) String[] roleIds) throws Exception{userService.addRoleToUser(userId, roleIds);return "redirect:findAll.do";}

UserServiceImpl

    @Overridepublic void addRoleToUser(String userId, String[] roleIds) throws Exception {for(String roleId:roleIds){userDao.addRoleToUser(userId,roleId);}}

IUserDao

 //@Param 有两个int参数mybaties不知道怎末匹配@Insert("insert into users_role(userId,roleId) values(#{userId},#{roleId})")void addRoleToUser(@Param("userId") String userId,@Param("roleId") String roleId) throws Exception;
}

 

http://www.hkea.cn/news/133226/

相关文章:

  • 个人无网站怎样做cps广告深圳全网推广公司
  • 中国人可以做的c2c网站上海网站排名推广
  • 网站建设目标定位公司员工培训方案
  • 美工培训班学百度自然搜索排名优化
  • 网站建设自学多长时间搜索引擎营销的过程
  • 做cpa的网站源码seo的外链平台有哪些
  • 那个网站做外贸最好成都网站建设方案外包
  • 企业网站建设效益分析联合早报 即时消息
  • html5网页成品代码自媒体seo优化
  • 门户网站建设招投标网络seo啥意思
  • 游戏币销售网站建设百度热搜seo
  • 线上投票链接怎么做厦门搜索引擎优化
  • 网页设计课程主要内容seo学校
  • php 深圳 电子商务网站开发seo优化好做吗
  • 网站建设开发技术天津济南网站设计
  • 信息公开网站建设网店推广分为哪几种类型
  • 南皮网站建设价格seo搜索引擎优化方式
  • 网上购物系统的设计与实现论文长沙seo优化公司
  • 风景旅游网页制作素材seo推广灰色词
  • 网站制作网站建设网页设计页面
  • 网站开发兼容极速字体颜色推荐seo平台优化服务
  • wordpress建站流量齐三seo顾问
  • 怎么看一个网站做没做竞价公司网站怎么建立
  • seo神马网站推广器怎么做神马搜索排名seo
  • 桂林漓江景区网站优化推广排名
  • 网站首页模板设计图网络推广平台代理
  • 一女被多男做的视频网站搜全网的浏览器
  • 建设公司网站费用电脑培训课程
  • 电子商务网站建设课后题女生学网络营销这个专业好吗
  • 新疆兵团建设网站商丘seo优化