SpringBoot+Vue project personalized music recommendation system

Get the source code at the end of the article

Development language: Java

Framework: springboot+vue

Node: node.js

JDK version: JDK1.8

Server: tomcat7

Database: mysql 5.7/8.0

Database tool: Navicat11

Development software: eclipse/idea,Visual

Maven package: Maven3.3.9

Browser: Google Chrome

Table of contents

1. Introduction

2. System function

3. Detailed system design

3.1 Front page homepage module

3.2 Campus super phone module

3.3 Music Information Module

3.4 Music library module

3.5 Membership Package Module

Fourth, the administrator function module

4.1 Backstage Homepage Module

4.2 Administrator module

4.3 Music Information Module

4.4 Music library module

4.5 Membership Package Module

Five, part of the core code

5.1 User login key code

5.2 User registration key code

4.3 User management key code

4.4 Site Management Key Codes

1. Introduction

In the development process of the personalized music recommendation system, the B/S architecture is adopted, and Java technology is mainly used for development, combined with the latest popular SpringBoot framework. The middleware server is a Tomcat server, using Mysql database and IDEA development environment. The music player management system includes administrators, registered users and members. Its main functions include administrators: home page, site management (carousel, bulletin board) user management (administrators, registered users, members), content management (campus super chat, topic classification, music information, information classification), more Management (music classification, singer management, music library, membership package, membership management, membership music library) and other functions.

This system introduces the development background of the personalized music recommendation system in detail, and introduces the system development technology, then analyzes the requirements of the system, and describes the business process, system structure and data of the personalized music recommendation system in detail. Users can search for the music they want to listen to according to the keywords.

2. System function

This personalized music recommendation system mainly includes three functional modules, namely user functional module, member and administrator functional module.

(1) Administrator module: home page, site management (carousel, bulletin board) user management (administrators, registered users, members), content management (campus super chat, topic classification, music information, information classification), more Management (music classification, singer management, music library, membership package, membership management, membership music library) and other functions. 

(2) Front-end users: home page, campus chat, announcement news, music information, music library, membership package, my (my account, my collection, personal center, exit).

3. Detailed system design

3.1 Front page homepage module

3.2 Campus super phone module

3.3 Music Information Module

3.4 Music library module

 

3.5 Membership Package Module

Fourth, the administrator function module

4.1 Backstage Homepage Module


 

4.2 Administrator module

4.3 Music Information Module

 

4.4 Music library module

4.5 Membership Package Module

Five, part of the core code

5.1 User login key code

 /**
     * Log in
     * @param data
     * @param httpServletRequest
     * @return
     */
    @PostMapping("login")
    public Map<String, Object> login(@RequestBody Map<String, String> data, HttpServletRequest httpServletRequest) {
        log.info("[Execute the login interface]");

        String username = data.get("username");
        String email = data.get("email");
        String phone = data.get("phone");
        String password = data.get("password");

        List resultList = null;
        Map<String, String> map = new HashMap<>();
        if(username != null && "".equals(username) == false){
            map.put("username", username);
            resultList = service.select(map, new HashMap<>()).getResultList();
        }
        else if(email != null && "".equals(email) == false){
            map.put("email", email);
            resultList = service.select(map, new HashMap<>()).getResultList();
        }
        else if(phone != null && "".equals(phone) == false){
            map.put("phone", phone);
            resultList = service.select(map, new HashMap<>()).getResultList();
        }else{
            return error(30000, "Account or password cannot be empty");
        }
        if (resultList == null || password == null) {
            return error(30000, "Account or password cannot be empty");
        }
        //Determine if this user exists
        if (resultList.size()<=0){
            return error(30000,"User does not exist");
        }

        User byUsername = (User) resultList.get(0);


        Map<String, String> groupMap = new HashMap<>();
        groupMap.put("name",byUsername.getUserGroup());
        List groupList = userGroupService.select(groupMap, new HashMap<>()).getResultList();
        if (groupList.size()<1){
            return error(30000,"User group does not exist");
        }

        UserGroup userGroup = (UserGroup) groupList.get(0);

        //Query user audit status
        if (!StringUtils.isEmpty(userGroup.getSourceTable())){
            String sql = "select examine_state from "+ userGroup.getSourceTable() +" WHERE user_id = " + byUsername.getUserId();
            String res = String.valueOf(service.runCountSql(sql).getSingleResult());
            if (res==null){
                return error(30000,"User does not exist");
            }
            if (!res.equals("passed")){
                return error(30000,"The user has not passed the audit");
            }
        }

        //Query user status
        if (byUsername.getState()!=1){
            return error(30000,"User is unavailable and cannot log in");
        }

        String md5password = service.encryption(password);
        if (byUsername.getPassword().equals(md5password)) {
            // Store Token in database
            AccessToken accessToken = new AccessToken();
            accessToken.setToken(UUID.randomUUID().toString().replaceAll("-", ""));
            accessToken.setUser_id(byUsername.getUserId());
            tokenService.save(accessToken);

            // Return user information
            JSONObject user = JSONObject.parseObject(JSONObject.toJSONString(byUsername));
            user.put("token", accessToken.getToken());
            JSONObject ret = new JSONObject();
            ret.put("obj",user);
            return success(ret);
        } else {
            return error(30000, "Incorrect account or password");
        }
    }

5.2 User registration key code

/**
     * register
     * @param user
     * @return
     */
    @PostMapping("register")
    public Map<String, Object> signUp(@RequestBody User user) {
        // query user
        Map<String, String> query = new HashMap<>();
        query.put("username",user.getUsername());
        List list = service.select(query, new HashMap<>()).getResultList();
        if (list.size()>0){
            return error(30000, "user already exists");
        }
        user.setUserId(null);
        user.setPassword(service.encryption(user.getPassword()));
        service.save(user);
        return success(1);
}

/**
     * User ID: [0,8388607] User gets other user related data
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "user_id")
    private Integer userId;

    /**
     * Account Status: [0,10] (1 Available | 2 Abnormal | 3 Frozen | 4 Logged Out)
     */

    @Basic
    @Column(name = "state")
    private Integer state;

    /**
     * User group: [0,32767] Determine user identity and permissions
     */

    @Basic
    @Column(name = "user_group")
    private String userGroup;

    /**
     * Last Login Time:
     */

    @Basic
    @Column(name = "login_time")
    private Timestamp loginTime;

    /**
     * Mobile number: [0,11] The user's mobile number, used to retrieve the password or log in
     */

    @Basic
    @Column(name = "phone")
    private String phone;

    /**
     * Mobile phone certification: [0,1] (0 not certified | 1 under review | 2 certified)
     */

    @Basic
    @Column(name = "phone_state")
    private Integer phoneState;

    /**
     * Username: [0,16] The account name the user uses to log in
     */

    @Basic
    @Column(name = "username")
    private String username;

    /**
     * Nickname: [0,16]
     */

    @Basic
    @Column(name = "nickname")
    private String nickname;

    /**
     * Password: [0,32] Password required for user login, consisting of 6-16 digits or English
     */

    @Basic
    @Column(name = "password")
    private String password;

    /**
     * Email: [0,64] The user's email, used to retrieve the password or log in
     */

    @Basic
    @Column(name = "email")
    private String email;

    /**
     * Email certification: [0,1] (0 not certified | 1 under review | 2 certified)
     */

    @Basic
    @Column(name = "email_state")
    private Integer emailState;

    /**
     * Avatar address: [0,255]
     */

    @Basic
    @Column(name = "avatar")
    private String avatar;

    /**
     * Creation time:
     */

    @Basic
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp createTime;

    @Basic
    @Transient
    private String code;
}

4.3 User management key code

public String encryption(String plainText) {
        String re_md5 = new String();
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(plainText.getBytes());
            byte b[] = md.digest();

            int i;

            StringBuffer buf = new StringBuffer("");
            for (int offset = 0; offset < b.length; offset++) {
                i = b[offset];
                if (i < 0)
                    i += 256;
                if (i < 16)
                    buf.append("0");
                buf.append(Integer.toHexString(i));
            }

            re_md5 = buf.toString();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return re_md5;
    }

4.4 Site Management Key Codes

 @PostMapping("/add")
    @Transactional
    public Map<String, Object> add(HttpServletRequest request) throws IOException {
        service.insert(service.readBody(request.getReader()));
        return success(1);
    }

    @Transactional
    public Map<String, Object> addMap(Map<String,Object> map){
        service.insert(map);
        return success(1);
}

    public Map<String,Object> readBody(BufferedReader reader){
        BufferedReader br = null;
        StringBuilder sb = new StringBuilder("");
        try{
            br = reader;
            String str;
            while ((str = br.readLine()) != null){
                sb.append(str);
            }
            br.close();
            String json = sb.toString();
            return JSONObject.parseObject(json, Map.class);
        }catch (IOException e){
            e.printStackTrace();
        }finally{
            if (null != br){
                try{
                    br.close();
                }catch (IOException e){
                    e.printStackTrace();
                }
            }
        }
        return null;
}

    public void insert(Map<String,Object> body){
        StringBuffer sql = new StringBuffer("INSERT INTO ");
        sql.append("`").append(table).append("`").append(" (");
        for (Map.Entry<String,Object> entry:body.entrySet()){
            sql.append("`"+humpToLine(entry.getKey())+"`").append(",");
        }
        sql.deleteCharAt(sql.length()-1);
        sql.append(") VALUES (");
        for (Map.Entry<String,Object> entry:body.entrySet()){
            Object value = entry.getValue();
            if (value instanceof String){
                sql.append("'").append(entry.getValue()).append("'").append(",");
            }else {
                sql.append(entry.getValue()).append(",");
            }
        }
        sql.deleteCharAt(sql.length() - 1);
        sql.append(")");
        log.info("[{}] - Insert operation:{}",table,sql);
        Query query = runCountSql(sql.toString());
        query.executeUpdate();
    }

Tags: Java Back-end Vue.js Spring Boot GraduationDesign

Posted by eddierosenthal on Tue, 04 Oct 2022 13:48:23 +1030