基于SpringBoot+Redis的系统JSP+MYSQL网上商城管理员分权限商品分页

1.包含源程序,数据库脚本。代码和数据库脚本都有详细注释。
2.课题设计仅供参考学习使用,可以在此基础上进行扩展完善

代码已经上传github,下载地址https://github.com/21503882/net-shopp
开发环境:
Eclipse ,MYSQL,JDK1.8,Tomcat 8.5
涉及技术点:
MVC模式、SpringBoot、Mybatis、Redis、HTML、log4j、druid、Bootstrap、
Semantic UI、Thymeleaf、JavaScript、CSS、JQUERY、Ajax等
适合学习J2EE的一段时间的熟手,代码思路清晰,注解详细,数据库用的是mysql5.1,服务器用的tomcat8.5,JDK版本1.8. 编程软件Eclispe J2EE版本。是典型MVC架构,并且前后台分离
主要功能:

package com.example.solicitude.controller;

import com.example.solicitude.pojo.Department;
import com.example.solicitude.service.DepartmentService;
import com.example.solicitude.utils.SzpJsonResult;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.ResultType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Auther: SualLabel
 * @Date: 2019-02-25 20:41
 * @Description: SualLabel, Write down some description!!!
 */
@RestController
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;

    @ApiOperation("添加department")
    @PostMapping("/insertDepartment.action")
    public SzpJsonResult insertDepartment(@RequestBody Department department) {
        Long userId = department.getUserId();
        List<Department> departmentByUserId = departmentService.findDepartmentByUserId(userId);
        if (departmentByUserId==null||departmentByUserId.size()==0){
            departmentService.insertDepartment(department);
            return SzpJsonResult.ok();
        }else {
            return SzpJsonResult.errorMsg("已经添加过了,无法再添加");
        }


    }

    @ApiOperation("通过主键id删除department")
    @DeleteMapping("/deleteDepartmentById.action")
    public SzpJsonResult deleteDepartmentById(@RequestBody long id) {

        departmentService.deleteDepartmentById(id);
        return SzpJsonResult.ok();
    }

    //根据主键跟新,值不为null的字段
    @ApiOperation("根据主键跟新,值不为null的字段")
    @PutMapping("/updateDepartmentById.action")
    public SzpJsonResult updateDepartmentById(@RequestBody Department department) {
        Department departmentById = departmentService.findDepartmentById(department.getId());
        department.setUserId(departmentById.getUserId());
        departmentService.updateDepartmentById(department);
        return SzpJsonResult.ok();
    }

    //通过主键id找到
    @ApiOperation("通过主键id找到")
    @GetMapping("/findDepartmentById.action")
    public SzpJsonResult findDepartmentById(long id) {

        Department departmentById = departmentService.findDepartmentById(id);
        return SzpJsonResult.ok(departmentById);
    }

    //通过userId找到
    @ApiOperation("通过userId找到")
    @GetMapping("/findDepartmentByUserId.action")
    public SzpJsonResult findDepartmentByUserId(long userId) {

        List<Department> departmentByUserId = departmentService.findDepartmentByUserId(userId);
        if (departmentByUserId!=null&&departmentByUserId.size()!=0) {
            return SzpJsonResult.ok(departmentByUserId.get(0));
        }else {
            return SzpJsonResult.errorMsg("没有找到");
        }
    }

    //通过机构名称找到
    @ApiOperation("通过机构名称找到")
    @GetMapping("/findDepartmentName.action")
    public SzpJsonResult findDepartmentName(String departmentName) {

        List<Department> departmentName1 = departmentService.findDepartmentName(departmentName);
        return SzpJsonResult.ok(departmentName1);
    }

    @ApiOperation("显示全部机构")
    @GetMapping("/findAllDepartment.action")
    public SzpJsonResult findAllDepartment() {
        List<Department> allDepartment = departmentService.findAllDepartment();
        return SzpJsonResult.ok(allDepartment);
    }
}
package com.example.solicitude.controller;

import com.example.solicitude.pojo.User;
import com.example.solicitude.service.UserService;
import com.example.solicitude.utils.SzpJsonResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.SimpleTimeZone;

/**
 * @Auther: SualLabel
 * @Date: 2019-02-27 00:03
 * @Description: SualLabel, Write down some description!!!
 */
@RestController
public class UserController {
    @Autowired
    private UserService userService;
    @ApiOperation("添加user")
    @PostMapping("/insertUser.action")
    public SzpJsonResult insertUser(@RequestBody User user){
        userService.insertUser(user);
        return SzpJsonResult.ok();
    }
    @ApiOperation("通过id删除user")
    @DeleteMapping("/deleteUserById.action")
    public SzpJsonResult deleteUserById(@RequestBody long id){
        userService.deleteUserById(id);
        return SzpJsonResult.ok();
    }
    @ApiOperation("根据主键跟新,值不为null的字段")
    @PutMapping("/updateUserById.action")
    public SzpJsonResult updateUserById(@RequestBody User user){
        userService.updateUserById(user);
        return SzpJsonResult.ok();
    }
    //通过主键id找到user
    @ApiOperation("通过主键id找到user")
    @GetMapping("/findUserById.action")
    public SzpJsonResult findUserById(long id){

        User userById = userService.findUserById(id);
        return SzpJsonResult.ok(userById);
    }
    //通过昵称找到user
    @ApiOperation("通过昵称找到user")
    @GetMapping("/findUserByNickName.action")
    public SzpJsonResult findUserByNickName(String nickName){
        List<User> userByNickName = userService.findUserByNickName(nickName);
        return SzpJsonResult.ok(userByNickName);
    }
    //通过username找到user
    @ApiOperation("通过username找到user")
    @GetMapping("/findUserByUsername.action")
    public SzpJsonResult findUserByUsername(String username){
        List<User> userByUsername = userService.findUserByUsername(username);
        if (userByUsername!=null&&userByUsername.size()!=0){
            return SzpJsonResult.ok(userByUsername.get(0));
        }
        return SzpJsonResult.ok("没有该用户");
    }
    //登录
    @ApiOperation("登录")
    @GetMapping("/findUserByUsernameAndPassword.action")
    public SzpJsonResult findUserByUsernameAndPassword(String username,
                                                       String password){
        List<User> userByUsernameAndPassword = userService.findUserByUsernameAndPassword(username, password);
        if (userByUsernameAndPassword.size()!=0&&userByUsernameAndPassword!=null) {
            return SzpJsonResult.ok(userByUsernameAndPassword.get(0));
        }else {
            return SzpJsonResult.errorMsg("请重新检查密码");
        }
    }
}
发布了38 篇原创文章 · 获赞 10 · 访问量 4142

猜你喜欢

转载自blog.csdn.net/QQ21503882/article/details/103314478