An online education system based on SpringBoot "open source"

Posted by SpanKie on Wed, 15 Dec 2021 13:39:37 +0100

1. Technical introduction

  • Core technology: SpringBoot+mybatis;
  • Front end: layui;
  • Development tool: idea;
  • Database: mysql5 7;
  • Template engine: thymeleaf;
  • Security framework: Spring security;
  • Log framework: logback;
  • Database connection pool: druid;
  • Online editor: ckedit;
  • Picture rotation component: jQuery swipes slider;

2. Function introduction

The project is divided into foreground user interface function and background management function;

  • Foreground user interface functions:
  • Rolling large banners display important notices and courses or activities;
  • Display courses, recommend the latest courses, free courses and practical courses according to the actual business needs;
  • Course search: users can enter specified course keywords to search and query, or search according to course category and type;
  • Detailed presentation of the course
  • User login
  • Online payment

Background management function:

  • Administrator login
  • course management
  • Course category management
  • user management
  • Teacher management
  • Order management
  • Menu management
  • Link management
  • System attribute management
  • Custom post management
  • Rotation picture post management

3. Front end

3.1 home page

3.2 courses

Provide quick query of relevant courses according to course category, type and search box

Click on any one course, free courses can be directly viewed, vip courses need to be paid through Alipay or WeChat opened vip to watch.

3.3 login

When learning the course, you need to log in to watch relevant videos

After logging in, you can view the relevant functions of the personal center

You can view the purchased courses in my order interface

3.4 commodity exchange

3.5 course release

You can submit published course materials on the course publishing page

On my publishing page, you can view all published course related information and review status

4. Back end

4.1 login

4.2 system management

It includes user management, role management and menu management. You can view the corresponding information and add, import, modify or delete it

The role management interface can assign permissions to roles

4.3 course management

You can add courses and manage them by category: public courses, professional courses, free courses, etc

In category management, you can add course classification information

In the audit function, you can audit the uploaded video

4.4 teacher management

4.5 navigation menu

4.6 rotation management

4.7 notice management

4.8 gift management

5. Core code of the system

/**
 * Operation logging annotation
 * Created by xiaomeng 2020-03-21 17:03
  *Technical exchange v: kaifazixun
 * Operation logging annotation
 * Created by wangfan on 2020-03-21 17:03
 */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface OperLog {
 
    /**
     * modular
     */
    String value();
 
    /**
     * function
     */
    String desc();
 
    /**
     * Record request parameters
     */
    boolean param() default true;
 
    /**
     * Record returned results
     */
    boolean result() default false;
 
}*
 */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface OperLog {
 
    /**
     * modular
     */
    String value();
 
    /**
     * function
     */
    String desc();
 
    /**
     * Record request parameters
     */
    boolean param() default true;
 
    /**
     * Record returned results
     */
    boolean result() default false;
 
@Aspect
@Component
public class OperLogAspect {
    private ThreadLocal<Long> startTime = new ThreadLocal<>();
    @Autowired
    private OperRecordService operRecordService;
 
    @Pointcut("@annotation(com.egao.common.core.annotation.OperLog)")
    public void operLog() {
    }
 
    @Before("operLog()")
    public void doBefore(JoinPoint joinPoint) throws Throwable {
        startTime.set(System.currentTimeMillis());
    }
 
    @AfterReturning(pointcut = "operLog()", returning = "result")
    public void doAfterReturning(JoinPoint joinPoint, Object result) {
        saveLog(joinPoint, result, null);
    }
 
    @AfterThrowing(value = "operLog()", throwing = "e")
    public void doAfterThrowing(JoinPoint joinPoint, Exception e) {
        saveLog(joinPoint, null, e);
    }
 
    private void saveLog(JoinPoint joinPoint, Object result, Exception e) {
        // Get reques ts object
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = (attributes == null ? null : attributes.getRequest());
        // Build operation log
        OperRecord operRecord = new OperRecord();
        operRecord.setUserId(getLoginUserId());
        if (startTime.get() != null) operRecord.setSpendTime(System.currentTimeMillis() - startTime.get());
        if (request != null) {
            operRecord.setRequestMethod(request.getMethod());
            operRecord.setUrl(request.getRequestURI());
            operRecord.setIp(UserAgentGetter.getIp(request));
        }
        // Record exception information
        if (e != null) {
            operRecord.setState(1);
            operRecord.setComments(StrUtil.sub(e.toString(), 0, 2000));
        }
public class BaseController {
 
    /**
     * Get the currently logged in user
     */
    public User getLoginUser() {
        Subject subject = SecurityUtils.getSubject();
        if (subject == null) return null;
        Object object = subject.getPrincipal();
        if (object != null) return (User) object;
        return null;
    }
 
    /**
     * Get the currently logged in userId
     */
    public Integer getLoginUserId() {
        User loginUser = getLoginUser();
        return loginUser == null ? null : loginUser.getUserId();
    }
 
}
/**
 * user management 
 * Created by xiaomeng 2020-12-24 16:10
*Technical exchange V: kaifazixun
 */
@Controller
@RequestMapping("/sys/user")
public class UserController extends BaseController {
    @Autowired
    private UserService userService;
    @Autowired
    private DictionaryDataService dictionaryDataService;
    @Autowired
    private RoleService roleService;
    @Autowired
    private OrganizationService organizationService;
 
    @RequiresPermissions("sys:user:view")
    @RequestMapping()
    public String view(Model model) {
        model.addAttribute("sexList", dictionaryDataService.listByDictCode("sex"));
        model.addAttribute("organizationTypeList", dictionaryDataService.listByDictCode("organization_type"));
        model.addAttribute("rolesJson", JSON.toJSONString(roleService.list()));
        return "system/user.html";
    }
 
    /**
     * Personal Center
     */
    @RequestMapping("/info")
    public String userInfo(Model model) {
        model.addAttribute("user", userService.getFullById(getLoginUserId()));
        model.addAttribute("sexList", dictionaryDataService.listByDictCode("sex"));
        return "index/user-info.html";
    }
 
    /**
     * Paging query user
     */
    @OperLog(value = "user management ", desc = "Paging query")
    @RequiresPermissions("sys:user:list")
    @ResponseBody
    @RequestMapping("/page")
    public PageResult<User> page(HttpServletRequest request) {
        PageParam<User> pageParam = new PageParam<>(request);
        pageParam.setDefaultOrder(null, new String[]{"create_time"});
        return userService.listPage(pageParam);
    }
 
    /**
     * Query all users
     */
    @OperLog(value = "user management ", desc = "Query all")
    @RequiresPermissions("sys:user:list")
    @ResponseBody
    @RequestMapping("/list")
    public JsonResult list(HttpServletRequest request) {
        PageParam<User> pageParam = new PageParam<>(request);
        List<User> records = userService.listAll(pageParam.getNoPageParam());
        return JsonResult.ok().setData(pageParam.sortRecords(records));
    }
 
    /**
     * Query user by id
     */
    @OperLog(value = "user management ", desc = "according to id query")
    @RequiresPermissions("sys:user:list")
    @ResponseBody
    @RequestMapping("/get")
    public JsonResult get(Integer id) {
        PageParam<User> pageParam = new PageParam<>();
        pageParam.put("userId", id);
        List<User> records = userService.listAll(pageParam.getNoPageParam());
        return JsonResult.ok().setData(pageParam.getOne(records));
    }
/**
 * user management 
 * Created by xiaomeng 2020-12-24 16:10
*Technical exchange V: kaifazixun
 */
@Controller
@RequestMapping("/sys/user")
public class UserController extends BaseController {
    @Autowired
    private UserService userService;
    @Autowired
    private DictionaryDataService dictionaryDataService;
    @Autowired
    private RoleService roleService;
    @Autowired
    private OrganizationService organizationService;
 
    @RequiresPermissions("sys:user:view")
    @RequestMapping()
    public String view(Model model) {
        model.addAttribute("sexList", dictionaryDataService.listByDictCode("sex"));
        model.addAttribute("organizationTypeList", dictionaryDataService.listByDictCode("organization_type"));
        model.addAttribute("rolesJson", JSON.toJSONString(roleService.list()));
        return "system/user.html";
    }
 
    /**
     * Personal Center
     */
    @RequestMapping("/info")
    public String userInfo(Model model) {
        model.addAttribute("user", userService.getFullById(getLoginUserId()));
        model.addAttribute("sexList", dictionaryDataService.listByDictCode("sex"));
        return "index/user-info.html";
    }
 
    /**
     * Paging query user
     */
    @OperLog(value = "user management ", desc = "Paging query")
    @RequiresPermissions("sys:user:list")
    @ResponseBody
    @RequestMapping("/page")
    public PageResult<User> page(HttpServletRequest request) {
        PageParam<User> pageParam = new PageParam<>(request);
        pageParam.setDefaultOrder(null, new String[]{"create_time"});
        return userService.listPage(pageParam);
    }
 
    /**
     * Query all users
     */
    @OperLog(value = "user management ", desc = "Query all")
    @RequiresPermissions("sys:user:list")
    @ResponseBody
    @RequestMapping("/list")
    public JsonResult list(HttpServletRequest request) {
        PageParam<User> pageParam = new PageParam<>(request);
        List<User> records = userService.listAll(pageParam.getNoPageParam());
        return JsonResult.ok().setData(pageParam.sortRecords(records));
    }
 
    /**
     * Query user by id
     */
    @OperLog(value = "user management ", desc = "according to id query")
    @RequiresPermissions("sys:user:list")
    @ResponseBody
    @RequestMapping("/get")
    public JsonResult get(Integer id) {
        PageParam<User> pageParam = new PageParam<>();
        pageParam.put("userId", id);
        List<User> records = userService.listAll(pageParam.getNoPageParam());
        return JsonResult.ok().setData(pageParam.getOne(records));
    }
/**
 * Dictionary management
 * Created by xiaomeng on 2021-03-14 11:29:03
 * Technical exchange plus v:kafazixun
 */
@Controller
@RequestMapping("/sys/dict")
public class DictionaryController extends BaseController {
    @Autowired
    private DictionaryService dictionaryService;
 
    @RequiresPermissions("sys:dict:view")
    @RequestMapping()
    public String view() {
        return "system/dictionary.html";
    }
 
    /**
     * Paging query dictionary
     */
    @OperLog(value = "Dictionary management", desc = "Paging query")
    @RequiresPermissions("sys:dict:list")
    @ResponseBody
    @RequestMapping("/page")
    public PageResult<Dictionary> page(HttpServletRequest request) {
        PageParam<Dictionary> pageParam = new PageParam<>(request);
        return new PageResult<>(dictionaryService.page(pageParam, pageParam.getWrapper()).getRecords(), pageParam.getTotal());
    }
 
    /**
     * Query all dictionaries
     */
    @OperLog(value = "Dictionary management", desc = "Query all")
    @RequiresPermissions("sys:dict:list")
    @ResponseBody
    @RequestMapping("/list")
    public JsonResult list(HttpServletRequest request) {
        PageParam<Dictionary> pageParam = new PageParam<>(request);
        return JsonResult.ok().setData(dictionaryService.list(pageParam.getOrderWrapper()));
    }
 
    /**
     * Query dictionary by id
     */
    @OperLog(value = "Dictionary management", desc = "according to id query")
    @RequiresPermissions("sys:dict:list")
    @ResponseBody
    @RequestMapping("/get")
    public JsonResult get(Integer id) {
        return JsonResult.ok().setData(dictionaryService.getById(id));
    }

Topics: Java Spring Boot Programmer