Advertisement

javaweb JAVA JSP销售系统商城购物系统jsp购物系统购物商城系统源码(jsp电子商务系统)网上购物

阅读量:

该JSPbased shopping system integrates with a robust Java Web framework to deliver an advanced online shopping solution, incorporating comprehensive purchasing functionalities and a user-friendly interface for seamless commerce operations.

复制代码
     //添加用户

    
     @PostMapping("/addUser")
    
     @ApiOperation("添加用户接口")
    
     @ResponseBody
    
     public Map<String,Object> addUser(User user){
    
     Map<String, Object> ret = new HashMap<>();
    
     ret.put("code",-1);
    
     if(StringUtils.isEmpty(user.getUsername())){
    
         ret.put("msg","请填写用户名");
    
         return ret;
    
     }
    
     if(StringUtils.isEmpty(user.getPassword())){
    
         ret.put("msg","请填写密码");
    
         return ret;
    
     }
    
     if(StringUtils.isEmpty(user.getEmail())){
    
         ret.put("msg","请填写邮箱");
    
         return ret;
    
     }
    
     if(StringUtils.isEmpty(user.getTel())){
    
         ret.put("msg","请填写手机号");
    
         return ret;
    
     }
    
     if(StringUtils.isEmpty(user.getHeadImg())){
    
         ret.put("msg","请上传头像");
    
         return ret;
    
     }
    
     if(userService.addUser(user)<=0) {
    
         ret.put("msg", "添加用户失败");
    
         return ret;
    
     }
    
     ret.put("code",0);
    
     ret.put("msg","添加用户成功");
    
     return ret;
    
     }
    
  
    
     /** * 修改用户信息操作
    
      * @param user
    
      * @return
    
      */
    
     @PostMapping("/editSaveUser")
    
     @ApiOperation("修改用户接口")
    
     @PreAuthorize("hasRole('管理员')")
    
     @ResponseBody
    
     public Message editSaveUser(User user){
    
     if(StringUtils.isEmpty(user.getUsername())){
    
       return Message.error("请填写用户名");
    
     }
    
     if(StringUtils.isEmpty(user.getEmail())){
    
         return Message.error("请填写邮箱");
    
     }
    
     if(StringUtils.isEmpty(user.getTel())){
    
         return Message.error("请填写手机号");
    
     }
    
     try {
    
         userService.editSaveUser(user);
    
         return Message.success();
    
     } catch (Exception e) {
    
         e.printStackTrace();
    
         return Message.error("修改用户信息失败");
    
     }
    
  
    
     }
    
  
    
     //添加用户
    
     @GetMapping("/deleteUser")
    
     @ApiOperation("删除用户接口")
    
     @ApiImplicitParams({
    
         @ApiImplicitParam(name = "id", value = "如:88",required = true)
    
     })
    
     @PreAuthorize("hasRole('管理员')")
    
     @ResponseBody
    
     public AjaxResult deleteUser(@RequestParam(required = true) Long id){
    
     AjaxResult ajaxResult = new AjaxResult();
    
     try {
    
         userService.deleteUser(id);
    
     } catch (Exception e) {
    
         e.printStackTrace();
    
         return new AjaxResult("删除失败");
    
     }
    
  
    
     return ajaxResult;
    
     }
    
  
    
     @PostMapping(value="/deleteBatchUser")
    
     @ApiOperation("批量删除用户接口")
    
     @PreAuthorize("hasRole('管理员')")
    
     @ResponseBody
    
     public AjaxResult deleteBatchUser(String ids){
    
     String[] idsArr = ids.split(",");
    
     List list = new ArrayList();
    
     for(int i=0;i<idsArr.length;i++){
    
         list.add(idsArr[i]);
    
     }
    
     try{
    
         userService.batchRemove(list);
    
         return new AjaxResult();
    
     }catch(Exception e){
    
        return new AjaxResult("批量删除失败");
    
     }
    
     }

源码获取:博客首页 "资源" 里下载!

全部评论 (0)

还没有任何评论哟~