Java project: food forum system (java+SSM+JSP+jQuery+LayUI+mysql)

Source code acquisition: Download from the blog home page “Resources”!

Project Introduction

The project is mainly divided into foreground and background;
The main functions of the front desk include:
Login, registration; home page, my posts, opinions and suggestions; forum list, post viewing, posting and replying, etc.;
After ordinary users log in, the main functions are:
My homepage, user center, basic settings, moderator application, my attention, blocked users, my private messages, etc.;
The main functions of the background include:
Member management: banning, banning, deleting, etc.;
Site information: add, edit, delete, etc.;
Friendship link: add, edit, delete, etc.;
Forum management: add, modify, delete categories, revoke moderators, etc.;
Post management: migration, essence, top, delete, etc.;
Moderator review: pass, reject, etc.;
Suggestions: reply, delete;
Sensitive characters: add, edit, delete sensitive characters;
Report information: view the person being reported, the person making the report, the reason for the report, etc.;

Environmental needs

1. Operating environment: preferably java jdk 1.8, we run on this platform. Other versions are also theoretically possible.
2. IDE environment: IDEA, Eclipse, Myeclipse are all available. Recommend IDEA;
3. Tomcat environment: Tomcat 7.x, 8.x, 9.x versions are available
4. Hardware environment: Windows 7/8/10 with 1G memory or more; or Mac OS;
5. Maven project: No; check whether pom.xml is included in the source code directory; if it is included, it is a maven project, otherwise it is a non-maven project
6. Database: MySql version 5.7;

technology stack

1. Backend: Spring Spring MVC MyBatis
2. Front end: JSP + jQuery + LayUI

Instructions for use

1. Use Navicat or other tools to create a database with the corresponding name in mysql, and import the sql file of the project;
2. Use IDEA/Eclipse/MyEclipse to import the project. When importing Eclipse/MyEclipse, if it is a maven project, please select maven;
If it is a maven project, after the import is successful, please execute the maven clean;maven install command, configure tomcat, and then run;
3. Change the database configuration in the db.properties configuration file in the project to your own configuration;
4. Run the project, enter http://localhost:8080/cateforumssm to log in

User Management Controller:

/**
 * User Controller
 *
 */
@RestController
@RequestMapping("/admin/user")
public class UserAdminController {

  @Resource
  private UserService userService;

  @Value("${MD5Salt}")
  private String salt; // md5 encryption salt

  /**
   * Find user by ID
   * @param userId
   * @return
   */
  @RequestMapping("/findById")
  public Map<String, Object> findById(Integer userId) {
    Map<String, Object> resultMap = new HashMap<String, Object>();
    User user = userService.findById(userId);
    resultMap. put("errorNo", 0);
    resultMap. put("data", user);
    return resultMap;
  }

  /**
   * Query users in pages
   * @param user
   * @param registrationDates
   * @param page
   * @param limit
   * @return
   */
  @RequestMapping("/list")
  public Map<String, Object> list(User user,
      @RequestParam(value = "latelyLoginTimes", required = false) String latelyLoginTimes,
      @RequestParam(value = "page", required = false) Integer page,
      @RequestParam(value = "pageSize", required = false) Integer pageSize) {
    String s_bregistrationDate = null; // start time
    String s_eregistrationDate = null; // end time
    if (StringUtil. isNotEmpty(latelyLoginTimes)) {
      String[] strs = latelyLoginTimes.split(" - "); // split time period
      s_bregistrationDate = strs[0];
      s_eregistrationDate = strs[1];
    }
    List<User> userList = userService.list(user, s_bregistrationDate, s_eregistrationDate, page - 1, pageSize);
    Long total = userService.getCount(user, s_bregistrationDate, s_eregistrationDate);
    Map<String, Object> resultMap = new HashMap<String, Object>();
    resultMap. put("errorNo", 0);
    resultMap. put("data", userList);
    resultMap. put("total", total);
    return resultMap;
  }

  @RequestMapping("/delete")
  public Map<String, Object> delete(Integer userId) {
    Map<String, Object> resultMap = new HashMap<String, Object>();
    userService.delete(userId);
    resultMap. put("errorNo", 0);
    return resultMap;
  }

  /**
   * unsubscribe
   * @param request
   * @param userId
   * @return
   */
  @RequestMapping("/removeFocusUser")
  public ModelAndView removeFocusUser(HttpServletRequest request, String userId) {
    ModelAndView mav = new ModelAndView();
    User user = (User) request.getSession().getAttribute("user");// currently logged in user

    String userIds = user. getUserIds();
    List<String> tempList = Arrays.asList(userIds.split(","));
    List<String> lineIdList = new ArrayList<>(tempList);
    lineIdList. remove(userId);
    String ret = StringUtils. join(lineIdList, ",");

    user.setUserIds(ret);

    userService. save(user);
    mav.setViewName("redirect:/viewFocusUser");
    return mav;
  }

  /**
   * Follow users
   * @param request
   * @param userId
   * @return
   */
  @RequestMapping("/addFocusUser")
  public ModelAndView addFocusUser(HttpServletRequest request, String userId) {
    ModelAndView mav = new ModelAndView();
    User user = (User) request.getSession().getAttribute("user");// currently logged in user

    String userIds = user. getUserIds();
    List<String> tempList = Arrays.asList(userIds.split(","));
    List<String> lineIdList = new ArrayList<>(tempList);
    lineIdList.add(userId);
    String ret = StringUtils. join(lineIdList, ",");

    user.setUserIds(ret);

    userService. save(user);
    mav.setViewName("redirect:/viewFocusUser");
    return mav;
  }

  @RequestMapping("/addFocusUser/{userId}")
  public ModelAndView addFocusUser(@PathVariable(value = "userId", required = false) Integer userId,
      HttpSession session) {
    ModelAndView mav = new ModelAndView();
    User user = (User) session.getAttribute("user");// currently logged in user

    String userIds = user. getUserIds();
    List<String> tempList = new ArrayList<>();
    if (userIds != null) {
      tempList = Arrays.asList(userIds.split(","));
    }
    List<String> lineIdList = new ArrayList<>(tempList);
    lineIdList.add(userId.toString());
    String ret = StringUtils. join(lineIdList, ",");

    user.setUserIds(ret);

    userService. save(user);
    mav.setViewName("redirect:/viewFocusUser");
    return mav;
  }

  /**
   * Cancel favorite
   * @param request
   * @param userId
   * @return
   */
  @RequestMapping("/removeCollection")
  public ModelAndView removeCollection(HttpServletRequest request, String artId) {
    ModelAndView mav = new ModelAndView();
    User user = (User) request.getSession().getAttribute("user");// currently logged in user

    String artIds = user. getArticleIds();
    List<String> tempList = Arrays.asList(artIds.split(","));
    List<String> lineIdList = new ArrayList<>(tempList);
    lineIdList. remove(artId);
    String ret = StringUtils. join(lineIdList, ",");

    user.setArticleIds(ret);

    userService. save(user);
    mav.setViewName("redirect:/viewCollection");
    return mav;
  }

  /**
   * collect
   * @param request
   * @param userId
   * @return
   */
  @RequestMapping("/addCollection")
  public ModelAndView addCollection(HttpServletRequest request, String artId) {
    ModelAndView mav = new ModelAndView();
    User user = (User) request.getSession().getAttribute("user");// currently logged in user

    String artIds = user. getArticleIds();
    List<String> tempList = Arrays.asList(artIds.split(","));
    List<String> lineIdList = new ArrayList<>(tempList);
    lineIdList.add(artId);
    String ret = StringUtils. join(lineIdList, ",");

    user.setArticleIds(ret);

    userService. save(user);
    mav.setViewName("redirect:/viewCollection");
    return mav;
  }
}

Reply to Admin Control:

/**
 * Reply to the Controller layer
 *
 */
@RestController
@RequestMapping("/admin/reply")
public class ReplyAdminController {
\t
\t
@Resource
private ReplyService replyService;

/**
* paging query reply
* @param reply
* @param page
* @param limit
* @return
*/
@RequestMapping("/list")
public Map<String, Object> list(Reply reply,@RequestParam(value="page",required=false)Integer page,@RequestParam(value="pageSize",required=false)Integer pageSize){
Map<String, Object> resultMap=new HashMap<String, Object>();
List<Reply> replyList=replyService.list(reply,page-1, pageSize);
Long total = replyService. getCount();
resultMap. put("errorNo", 0);
resultMap. put("data", replyList);
resultMap. put("total", total);
return resultMap;
}
\t
/**
* delete reply
* @param ids
* @return
*/
@RequestMapping("/delete")
public Map<String, Object> delete(@RequestParam(value="replyId")String ids){
String []idsStr=ids.split(",");
Map<String, Object> resultMap=new HashMap<String, Object>();
for(int i=0;i<idsStr.length;i++) {
replyService.delete(Integer.parseInt(idsStr[i]));
}
resultMap. put("errorNo", 0);
resultMap. put("data", 1);
return resultMap;
}
\t
}

Blogger management control layer:

/**
 * Blogger Controller
 *
 */
@RestController
@RequestMapping("/admin/blogger")
public class BloggerAdminController {
\t
@Resource
private BloggerService bloggerService;
\t
@Resource
private StartupRunner startupRunner;
\t
/**
* Find bloggers
* @param bloggerId
* @return
*/
@RequestMapping("/find")
public Map<String, Object> find() {
Map<String, Object> resultMap=new HashMap<String, Object>();
resultMap. put("errorNo", 0);
resultMap.put("data", bloggerService.find());
return resultMap;
}
\t
/**
* Add or modify bloggers
* @param blogger
* @return
*/
@RequestMapping("/save")
public Map<String, Object> save(Blogger blogger){
Map<String, Object> resultMap=new HashMap<String, Object>();
bloggerService. save(blogger);
resultMap. put("errorNo", 0);
resultMap. put("data", 1);
startupRunner. loadData();
return resultMap;
}

}

Source code acquisition: Download from the blog home page “Resources”!

The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge. Java skill treeHomepageOverview 108586 people are studying systematically