发表于: 2020-07-15 23:42:15

1 1319


改了两个表role角色表和Workshop表

Mapper

public interface RoleMapper {
boolean deleteByPrimaryKey(Long id);

   boolean insert(Role record);

   int insertSelective(Role record);

   Role selectByPrimaryKey(Long id);

   int updateByPrimaryKeySelective(Role record);

   boolean updateByPrimaryKey(Role record);

   List<Role> selectAllRole();

   boolean updateManager();
int insertSelective(Workshop record);

Workshop selectByPrimaryKey(Long id);

int updateByPrimaryKeySelective(Workshop record);

List<Workshop> selectAllWorkshopFrontDesk();

List<Workshop> selectAllWorkshopBackDesk();

boolean deleteByPrimaryKey(Long id);

boolean insert(Workshop record);

boolean updateByPrimaryKey(Workshop record);

boolean updateByPrimaryKeyForIntroduction(Workshop record);

controller

@Controller
@RequestMapping("/role")
public class RoleController {
@Autowired
RoleService roleService;
   private static final Logger log= LogManager.getLogger(RoleController.class);

   @RequestMapping(value = "/toRoleIndex")
public String findBanner(Manager manager) {
return "workshopIndex";
   }

/**
    * 查询角色列表
    * @param modelAndView
    * @return
    */
   @RequestMapping(value = "/roleList",method = RequestMethod.GET)
public ModelAndView getRoleList(ModelAndView modelAndView){
List<Role> roleList= roleService.selectAllRole();
       log.info(roleList);
       if (roleList!=null){
modelAndView.addObject("code",200);
           modelAndView.addObject("msg","查询成功");
           modelAndView.addObject("roleList",roleList);
       }else {
modelAndView.addObject("code",404);
           modelAndView.addObject("msg","操作失败");
       }
modelAndView.setViewName("roleJson2");
       return modelAndView;
   }

/**
    * 新增角色
    * @param role
    * @param modelAndView
    * @return
    */
   @RequestMapping(value ="addRole",method = RequestMethod.POST)
public ModelAndView addAccount(Role role, ModelAndView modelAndView){
log.info(role);
       if (roleService.insert(role)){
modelAndView.addObject("code",200);
           modelAndView.addObject("msg","添加成功");
       }else {
modelAndView.addObject("code",404);
           modelAndView.addObject("msg","操作失败");
       }
modelAndView.setViewName("json");
       return modelAndView;
   }

/**
    * 根据id删除单条角色
    * @param id
    * @param modelAndView
    * @return
    */
   @RequestMapping(value = "deleteRole/id={id}",method = RequestMethod.DELETE)
public ModelAndView deleteRole(@PathVariable Long id, ModelAndView modelAndView){
log.info(roleService.updateManager());
       if(roleService.deleteByPrimaryKey(id)) {
modelAndView.addObject("code", 200);
           modelAndView.addObject("msg", "删除成功");
       }else {
modelAndView.addObject("code", 404);
           modelAndView.addObject("msg", "操作失败");
       }
modelAndView.setViewName("json");
       return modelAndView;
   }

/**
    * 查询单条角色
    * @param id
    * @param modelAndView
    * @return
    */
   @RequestMapping(value = "/selectRole",method = RequestMethod.GET)
public ModelAndView getManager( Long id, ModelAndView modelAndView){
Role role=roleService.selectByPrimaryKey(id);
       log.info(role);
       if (role!=null){
modelAndView.addObject("code",200);
           modelAndView.addObject("msg","查询成功");
           modelAndView.addObject("role",role);
       }else {
modelAndView.addObject("code",404);
           modelAndView.addObject("msg","操作失败");
       }
modelAndView.setViewName("roleJson1");
       log.info(1);
       return modelAndView;
   }

/**
    *编辑角色
    * @param role
    * @param modelAndView
    * @return
    */
   @RequestMapping(value = "/updateRole/{id}",method = RequestMethod.PUT)
public ModelAndView updateBannerSetting(Role role,@PathVariable long id, ModelAndView modelAndView){
log.info(id);
       if(roleService.updateByPrimaryKey(role)){
modelAndView.addObject("code",200);
           modelAndView.addObject("msg","保存成功");
       }else {
modelAndView.addObject("code",404);
           modelAndView.addObject("msg","操作失败");
       }
modelAndView.setViewName("json");
       return modelAndView;
   }

重写  终于可以测到数据 

明日计划 配置NGINX

今日问题 暂无


返回列表 返回列表
评论

    分享到