作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
园区招商管理系统。共分为三种角色,超级管理员、企业人员、高级用户。
超级管理员角色具有功能:
系统设置-用户管理、页面管理、角色管理;
招商管理-招商列表;
公司管理-公司列表、我的申请;
投诉管理-投诉列表、我的投诉;
合同管理-合同列表;
项目管理-项目列表、我的项目;
新闻管理-新闻列表;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 8.0版本;
技术栈
1. 后端:SpringBoot;
2. 前端:html+thymeleaf;
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中application.properties配置文件中的数据库配置改为自己的配置
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
4. 运行项目,输入localhost:8081 登录
5. 管理员账户:admin 密码:123456
6. 企业人员和高级用户菜单可通过管理员进行分配;
运行截图
代码相关
管理端控制器
@Controller("Admin")
@RequestMapping("/admin")
public class Adminontroller {
@Autowired
private PageService pageService;
@Autowired
private RoleService roleService;
@Autowired
private PageRoleService pageRoleService;
@Autowired
private UserRoleService userRoleService;
@Autowired
private UserService userService;
private final Logger logger = LoggerFactory.getLogger(Adminontroller.class);
/**
* Method name: page <BR>
* Description: 跳转到页面设置页面 <BR>
*
* @param model
* @return String<BR>
*/
@RequestMapping("/page")
public String page(Model model) {
List<Page> pageList = pageService.getAllPage();
model.addAttribute("pageList", pageList);
return "sa/page";
}
/**
* Method name: role <BR>
* Description: 跳转到角色设置页面 <BR>
*
* @param model
* @return String<BR>
*/
@RequestMapping("/role")
public String role(Model model) {
return "sa/role";
}
/**
* Method name: getAllRole <BR>
* Description: 获取所有权限 <BR>
*
* @return List<Role><BR>
*/
@RequestMapping("/getAllRole")
@ResponseBody
public List<Role> getAllRole() {
return roleService.getAllRole();
}
/**
* Method name: getAllPage <BR>
* Description: 获取所有页面 <BR>
*
* @return List<Page><BR>
*/
@RequestMapping("/getAllPage")
@ResponseBody
public List<Page> getAllPage() {
return pageService.getAllPage();
}
/**
* Method name: getPageByRole <BR>
* Description: 获取某个角色的权限页面 <BR>
*/
@RequestMapping("/getPageByRole")
@ResponseBody
public Object getPageByRole(Integer roleId) {
return pageService.getAllPageByRoleId(roleId);
}
/**
* Method name: updatePageById <BR>
* Description: 根据页面id更新页面 <BR>
*
* @param page
* @return ResultMap<BR>
*/
@RequestMapping("/updatePageById")
@ResponseBody
public ResultMap updatePageById(Page page) {
return pageService.updatePageById(page);
}
/**
* Method name: addPage <BR>
* Description: 添加页面 <BR>
*
* @param page
* @return Page<BR>
*/
@RequestMapping("/addPage")
@ResponseBody
public Page addPage(Page page) {
return pageService.addPage(page);
}
/**
* Method name: delPageById <BR>
* Description: 根据页面id删除页面 <BR>
*
* @param id
* @return ResultMap<BR>
*/
@RequestMapping("/delPageById")
@ResponseBody
public ResultMap delPageById(Integer id) {
if (null == id) {
return new ResultMap().fail().message("参数错误");
}
return pageService.delPageById(id);
}
/**
* Method name: addRole <BR>
* Description: 增加角色 <BR>
*
* @param name
* @return String<BR>
*/
@RequestMapping("/addRole")
@ResponseBody
public String addRole(String name) {
return roleService.addRole(name);
}
/**
* Method name: delManageRole <BR>
* Description: 根据角色id删除角色 <BR>
*
* @param id
* @return String<BR>
*/
@RequestMapping("/delRole")
@ResponseBody
public String delRole(int id) {
// 删除角色
boolean flag1 = roleService.delRoleById(id);
// 删除角色_权限表
boolean flag2 = pageRoleService.delPageRoleByRoleId(id);
// 删除某个角色的所有用户
boolean flag3 = userRoleService.delUserRoleByRoleId(id);
if (flag1 && flag2 && flag3) {
return "SUCCESS";
}
return "ERROR";
}
/**
* Method name: updateRole <BR>
* Description: 根据权限id修改权限信息 <BR>
*
* @param id
* @param name
* @return String<BR>
*/
@RequestMapping("/updateRole")
@ResponseBody
public String updateRole(Integer id, String name) {
int n = roleService.updateRoleById(id, name);
if (n != 0) {
return "SUCCESS";
}
return "ERROR";
}
/**
* Method name: addPageRoleByRoleId <BR>
* Description: 增加某个角色的权限页面 <BR>
*
* @param roleId
* @param pageIds
* @return String<BR>
*/
@RequestMapping("/addPageRoleByRoleId")
@ResponseBody
public String addPageRoleByRoleId(Integer roleId, Integer[] pageIds) {
if (null == roleId) {
return "ERROR";
}
// 先删除老的权限
boolean flag1 = pageRoleService.delPageRoleByRoleId(roleId);
boolean flag2 = pageRoleService.addPageRoles(roleId, pageIds);
if (flag1 && flag2) {
return "SUCCESS";
}
return "ERROR";
}
/**
* Method name: getAllUserByMap <BR>
* Description: 根据角色查询下面所有的人员/非角色下所有人员 <BR>
*/
@RequestMapping("/getAllUserByRoleId")
@ResponseBody
public Object getAllUserByRoleId(Integer roleId, String roleNot, Integer page, Integer limit) {
if (null == roleNot) {
return userService.getAllUserByRoleId(roleId, page, limit);
}
return userService.getAllUserByNotRoleId(roleId, page, limit);
}
/**
* Method name: delUserRoleByUserIdAndRoleId <BR>
* Description: 根据用户id权限id删除用户权限表 <BR>
*
* @param userId
* @param roleId
* @return ResultMap<BR>
*/
@RequestMapping("/delUserRoleByUserIdAndRoleId")
@ResponseBody
public ResultMap delUserRoleByUserIdAndRoleId(String userId, Integer roleId) {
return userRoleService.delUserRoleByUserIdAndRoleId(userId, roleId);
}
/**
* Method name: selectUserRole <BR>
* Description: 跳转到选择用户角色页面 <BR>
*
* @return String<BR>
*/
@RequestMapping("/selectUserRole")
public String selectUserRole() {
return "sa/selectUserRole";
}
/**
* Method name: addUserRole <BR>
* Description: 增加用户的角色 <BR>
*
* @param roleId
* @param userIds
* @return String<BR>
*/
@RequestMapping("/addUserRole")
@ResponseBody
public String addUserRole(Integer roleId, String[] userIds) {
return userRoleService.addUserRole(roleId, userIds);
}
/**
* Method name: userAddPage <BR>
* Description: 用户添加页面 <BR>
*
* @return String<BR>
*/
@RequestMapping(value = "/userAddPage")
public String userAddPage() {
return "sa/userAdd";
}
/**
* Method name: userPage <BR>
* Description: 用户管理页面 <BR>
*
* @return String<BR>
*/
@RequestMapping(value = "/userPage")
public String userPage() {
return "sa/userList";
}
/**
* Method name: getAllUserByLimit <BR>
* Description: 根据条件获取所有用户 <BR>
*
* @param userParameter
* @return Object<BR>
*/
@RequestMapping("/getAllUserByLimit")
@ResponseBody
public Object getAllUserByLimit(UserParameter userParameter) {
return userService.getAllUserByLimit(userParameter);
}
/**
* Method name: getAllDelUserByLimit <BR>
* Description: 获取所有删除用户 <BR>
*
* @param userParameter
* @return Object<BR>
*/
@RequestMapping("/getAllDelUserByLimit")
@ResponseBody
public Object getAllDelUserByLimit(UserParameter userParameter) {
return userService.getAllDelUserByLimit(userParameter);
}
/**
* Method name: delUser <BR>
* Description: 批量删除用户 <BR>
*
* @param ids
* @return String<BR>
*/
@RequestMapping(value = "delUser")
@ResponseBody
@Transactional
public String delUser(String[] ids) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
try {
for (String id : ids) {
if (id.equals(user.getId())) {
return "DontOP";
}
userService.delUserById(id);
}
return "SUCCESS";
} catch (Exception e) {
logger.error("根据用户id更新用户异常", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "ERROR";
}
}
/**
* Method name: addUserPage <BR>
* Description: 增加用户界面 <BR>
*
* @return String<BR>
*/
@RequestMapping(value = "/addUserPage")
public String addUserPage(String userId, Model model) {
model.addAttribute("manageUser", userId);
if (null != userId) {
User user = userService.selectByPrimaryKey(userId);
model.addAttribute("manageUser", user);
}
return "sa/userAdd";
}
/**
* Method name: checkUserId <BR>
* Description: 检测用户账号是否存在 <BR>
*
* @param userId
* @return User<BR>
*/
@ResponseBody
@RequestMapping("/checkUserId")
public User checkUserId(String userId) {
return userService.selectByPrimaryKey(userId);
}
/**
* Method name: addUser <BR>
* Description: 用户添加 <BR>
*
* @param user
* @return String<BR>
*/
@ResponseBody
@RequestMapping("/addUser")
public String addUser(User user) {
try {
user.setPassword(MD5.md5(user.getPassword()));
user.setCreateTime(new Date());
userService.addUser(user);
User u = userService.getUserByPhoneAndName(user.getPhone(), user.getName());
String[] ids = new String[1];
ids[0] = u.getId()+"";
userRoleService.addUserRole(user.getRole(), ids);
return "SUCCESS";
} catch (Exception e) {
return "ERR";
}
}
/**
* Method name: updateUser <BR>
* Description: 更新用户 <BR>
*
* @param user
* @return String<BR>
*/
@ResponseBody
@RequestMapping("/updateUser")
public String updateUser(User user, String oldId) {
return userService.updateUser(oldId, user);
}
/**
* Method name: delUserPage <BR>
* Description: 已删除用户列表 <BR>
*
* @return String<BR>
*/
@RequestMapping("/delUserPage")
public String delUserPage() {
return "sa/userDelPage";
}
}
公司管理控制器
@Controller("CompanyProject")
@RequestMapping("/admin/project")
public class ProjectController {
@Autowired
private ProjectService projectService;
@RequestMapping("/addProject")
public String addProject() {
return "/user/addProject";
}
@ResponseBody
@RequestMapping("/add")
public String add(Project project) {
project.setStatus(0+"");
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
project.setCompanyId(user.getId());
project.setCreateTime(new Date());
project.setViewCount(0);
project.setApplyCount(0);
try {
projectService.save(project);
return "SUCCESS";
} catch (Exception e) {
e.printStackTrace();
return "ERR";
}
}
@RequestMapping("/xq")
public String xq(Long id, Model model) {
Project project = projectService.getById(id);
projectService.view(id);
model.addAttribute("item", project);
return "/sa/xqProject";
}
@RequestMapping("/list")
public String list() {
return "/sa/projectList";
}
@RequestMapping("/doProject")
public String doComplaint(Long id, Model model) {
model.addAttribute("cId", id);
return "/sa/doProject";
}
@RequestMapping("/getAllByLimit")
@ResponseBody
public Object getAllByLimit(Project project) {
return projectService.getAllByLimit(project);
}
@ResponseBody
@RequestMapping("/del")
public String delWord(String[] ids) {
try {
for (String id : ids){
projectService.delById(id);
}
return "SUCCESS";
} catch (Exception e) {
e.printStackTrace();
return "ERR";
}
}
@ResponseBody
@RequestMapping("/update")
public String update(Project project) {
try {
projectService.updateById(project);
return "SUCCESS";
} catch (Exception e) {
e.printStackTrace();
return "ERR";
}
}
}
如果也想学习本系统,下面领取。回复:023springboot