|
@@ -0,0 +1,217 @@
|
|
|
+package com.lemon.lifecenter.controller;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
+
|
|
|
+import com.lemon.lifecenter.common.LifeCenterController;
|
|
|
+import com.lemon.lifecenter.dto.RoleDTO;
|
|
|
+import com.lemon.lifecenter.service.RoleService;
|
|
|
+
|
|
|
+@Controller
|
|
|
+@RequestMapping("/role")
|
|
|
+public class RoleController extends LifeCenterController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RoleService roleService;
|
|
|
+
|
|
|
+ @RequestMapping( "/list" )
|
|
|
+ public ModelAndView list() {
|
|
|
+
|
|
|
+ RoleDTO dto = new RoleDTO();
|
|
|
+
|
|
|
+ int total = roleService.selectGroupListCount(dto);
|
|
|
+
|
|
|
+ List<RoleDTO> roleList = new ArrayList<RoleDTO>();
|
|
|
+
|
|
|
+ if( total > 0 ) {
|
|
|
+ roleList = roleService.selectGroupList(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ ModelAndView mv = setMV( "role/list" );
|
|
|
+
|
|
|
+ mv.addObject( "total", total );
|
|
|
+ mv.addObject( "roleList", roleList );
|
|
|
+
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping( "/new" )
|
|
|
+ public ModelAndView insert() {
|
|
|
+
|
|
|
+ RoleDTO dto = new RoleDTO();
|
|
|
+
|
|
|
+ List<RoleDTO> menuList = roleService.selectMenuListOneDepth( dto );
|
|
|
+
|
|
|
+ ModelAndView mv = setMV( "role/new" );
|
|
|
+ mv.addObject( "menuList", menuList );
|
|
|
+
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value="/new/insert", method = RequestMethod.POST)
|
|
|
+ @Transactional(propagation=Propagation.REQUIRED)
|
|
|
+ public String newInsert(
|
|
|
+ @RequestParam(value="groupName", required = true) String groupName,
|
|
|
+ @RequestParam(value="useYn", required = true) String useYn,
|
|
|
+ @RequestParam(value="menuCode", required=false, defaultValue="") String[] menuCode,
|
|
|
+ @RequestParam(value="createYn", required=false, defaultValue="") String[] createYn,
|
|
|
+ @RequestParam(value="readYn", required=false, defaultValue="") String[] readYn,
|
|
|
+ @RequestParam(value="updateYn", required=false, defaultValue="") String[] updateYn,
|
|
|
+ @RequestParam(value="deleteYn", required=false, defaultValue="") String[] deleteYn ) {
|
|
|
+
|
|
|
+ RoleDTO dto = new RoleDTO();
|
|
|
+
|
|
|
+ dto.setGroupName( groupName );
|
|
|
+ dto.setUseYn( useYn );
|
|
|
+
|
|
|
+ roleService.insertGroupList( dto );
|
|
|
+
|
|
|
+ for( int i = 0; i < menuCode.length; i ++ ) {
|
|
|
+ dto.setMenuCode( menuCode[i] );
|
|
|
+ dto.setCreateYn( "N" );
|
|
|
+ dto.setReadYn( "N" );
|
|
|
+ dto.setUpdateYn( "N" );
|
|
|
+ dto.setDeleteYn( "N" );
|
|
|
+
|
|
|
+ for( int j = 0; j < createYn.length; j ++ ) {
|
|
|
+ if( createYn[j].equals( menuCode[i] ) ) {
|
|
|
+ dto.setCreateYn( "Y" );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for( int k = 0; k < readYn.length; k ++ ) {
|
|
|
+ if( readYn[k].equals( menuCode[i] ) ) {
|
|
|
+ dto.setReadYn( "Y" );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for( int l = 0; l < updateYn.length; l ++ ) {
|
|
|
+ if( updateYn[l].equals( menuCode[i] ) ) {
|
|
|
+ dto.setUpdateYn( "Y" );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for( int q = 0; q < deleteYn.length; q ++ ) {
|
|
|
+ if( deleteYn[q].equals( menuCode[i] ) ) {
|
|
|
+ dto.setDeleteYn( "Y" );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ roleService.insertMenuRole(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ return "redirect:/role/list";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping( "/info" )
|
|
|
+ public ModelAndView info( @RequestParam( value = "groupIdx", required = true ) int groupIdx ) {
|
|
|
+
|
|
|
+ RoleDTO dto = new RoleDTO();
|
|
|
+ dto.setGroupIdx( groupIdx );
|
|
|
+
|
|
|
+ ModelAndView mv = setMV( "role/info" );
|
|
|
+
|
|
|
+ RoleDTO groupData = roleService.selectGroupInfo(dto);
|
|
|
+ List<RoleDTO> roleData = roleService.selectMenuRole(dto);
|
|
|
+
|
|
|
+ int total = roleService.selectGroupListCount(dto);
|
|
|
+
|
|
|
+ List<RoleDTO> roleList = new ArrayList<RoleDTO>();
|
|
|
+
|
|
|
+ if( total > 0 ) {
|
|
|
+ roleList = roleService.selectGroupList(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ mv.addObject( "roleList", roleList );
|
|
|
+ mv.addObject( "roleData", roleData );
|
|
|
+ mv.addObject( "groupData", groupData );
|
|
|
+ mv.addObject( "groupIdx", groupIdx );
|
|
|
+
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value="/edit", method = RequestMethod.POST)
|
|
|
+ public ModelAndView edit(
|
|
|
+ @RequestParam( value = "groupIdx", required = true ) int groupIdx ) {
|
|
|
+ RoleDTO dto = new RoleDTO();
|
|
|
+ dto.setGroupIdx( groupIdx );
|
|
|
+
|
|
|
+ RoleDTO groupData = roleService.selectGroupInfo(dto);
|
|
|
+ List<RoleDTO> roleData = roleService.selectMenuRole(dto);
|
|
|
+
|
|
|
+ ModelAndView mv = setMV( "role/edit" );
|
|
|
+
|
|
|
+ mv.addObject( "groupIdx", groupIdx );
|
|
|
+ mv.addObject( "roleData", roleData );
|
|
|
+ mv.addObject( "groupData", groupData );
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping(value="/edit/update", method = RequestMethod.POST)
|
|
|
+ @Transactional(propagation=Propagation.REQUIRED)
|
|
|
+ public String update(
|
|
|
+ @RequestParam(value="groupIdx", required = true) int groupIdx,
|
|
|
+ @RequestParam(value="groupName", required = true) String groupName,
|
|
|
+ @RequestParam(value="useYn", required = true) String useYn,
|
|
|
+ @RequestParam(value="menuCode", required=false, defaultValue="") String[] menuCode,
|
|
|
+ @RequestParam(value="createYn", required=false, defaultValue="") String[] createYn,
|
|
|
+ @RequestParam(value="readYn", required=false, defaultValue="") String[] readYn,
|
|
|
+ @RequestParam(value="updateYn", required=false, defaultValue="") String[] updateYn,
|
|
|
+ @RequestParam(value="deleteYn", required=false, defaultValue="") String[] deleteYn ) {
|
|
|
+
|
|
|
+ RoleDTO dto = new RoleDTO();
|
|
|
+
|
|
|
+ dto.setGroupIdx( groupIdx );
|
|
|
+ dto.setGroupName( groupName );
|
|
|
+ dto.setUseYn( useYn );
|
|
|
+
|
|
|
+ roleService.updateGroupList( dto );
|
|
|
+ roleService.deleteMenuRole( dto );
|
|
|
+
|
|
|
+ for( int i = 0; i < menuCode.length; i ++ ) {
|
|
|
+ dto.setMenuCode( menuCode[i] );
|
|
|
+ dto.setCreateYn( "N" );
|
|
|
+ dto.setReadYn( "N" );
|
|
|
+ dto.setUpdateYn( "N" );
|
|
|
+ dto.setDeleteYn( "N" );
|
|
|
+
|
|
|
+ for( int j = 0; j < createYn.length; j ++ ) {
|
|
|
+ if( createYn[j].equals( menuCode[i] ) ) {
|
|
|
+ dto.setCreateYn( "Y" );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for( int k = 0; k < readYn.length; k ++ ) {
|
|
|
+ if( readYn[k].equals( menuCode[i] ) ) {
|
|
|
+ dto.setReadYn( "Y" );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for( int l = 0; l < updateYn.length; l ++ ) {
|
|
|
+ if( updateYn[l].equals( menuCode[i] ) ) {
|
|
|
+ dto.setUpdateYn( "Y" );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for( int q = 0; q < deleteYn.length; q ++ ) {
|
|
|
+ if( deleteYn[q].equals( menuCode[i] ) ) {
|
|
|
+ dto.setDeleteYn( "Y" );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ roleService.insertMenuRole(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ return "redirect:/role/info?groupIdx=" + groupIdx;
|
|
|
+ }
|
|
|
+}
|