作者主页:夜未央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.数据库:MySql 5.7版本;
6.是否Maven项目:是;
技术栈
1. 后端:SpringBoot
2. 前端:HTML+CSS+JavaScript+layui
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:18081/ 登录
管理员:admin/123456
运行截图
代码相关
配件管理配置器
/**
* 配件控制器
*/
@Api("配件接口API")
@RestController
public class GoodsController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private GoodsService goodsService;
private String image = "";
@ApiOperation(value = "配件列表接口", notes = "配件结果集列表")
@GetMapping("/admin/goodsList")
public ServerLayResult<Goods> list(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit) {
//查询结果总数
int count = goodsService.count();
List<Goods> goods = goodsService.selectAll(page, limit);
//组装Json数据
ServerLayResult result = new ServerLayResult(0, "", count, goods);
return result;
}
@ApiOperation(value = "配件删除接口", notes = "根据配件ID删除配件")
@GetMapping("/admin/goods/del")
public String delete(Integer id) {
System.out.println("id = " + id);
int row = goodsService.deleteByPrimaryKey(id);
if (row > 0) {
return "success";
}
return "error";
}
@ApiOperation(value = "配件更新接口", notes = "根据json数据对象来更新接口")
@PostMapping("/admin/goods/update")
public String update(@RequestBody JSONObject ob) {
com.alibaba.fastjson.JSONObject json = JSON.parseObject(ob.toJSONString());
logger.info(ob.toJSONString());
String gname = json.getString("gname");
Integer id = json.getInteger("id");
Double goprice = json.getDouble("goprice");
Double grprice = json.getDouble("grprice");
Integer gstore = json.getInteger("gstore");
String goodstypeId = json.getString("goodstypeId");
if (goodstypeId == null) {
return "error";
}
Goods goods = new Goods();
goods.setId(id);
goods.setGname(gname);
goods.setGoprice(goprice);
goods.setGrprice(grprice);
goods.setGstore(gstore);
GoodsType goodsType = new GoodsType();
goodsType.setId(Integer.parseInt(goodstypeId));
goods.setGoodstypeId(goodsType);
goods.setIputTime(new Date());
// goods.setGpicture("http://www.csbishe.cn:18081/views/upload/" + image);
goods.setGpicture("http://localhost:18081/views/upload/" + image);
logger.info(String.valueOf(goods));
int insert = goodsService.updateByPrimaryKey(goods);
if (insert > 0) {
return "success";
}
return "error";
}
@ApiOperation(value = "配件保存接口", notes = "根据json数据来保存配件")
@PostMapping("/admin/goods/add")
public String addGoods(@RequestBody JSONObject ob) {
com.alibaba.fastjson.JSONObject json = JSON.parseObject(ob.toJSONString());
String gname = json.getString("gname");
Double goprice = json.getDouble("goprice");
Double grprice = json.getDouble("grprice");
Integer gstore = json.getInteger("gstore");
String goodstypeId = json.getString("goodstypeId");
Goods goods = new Goods();
goods.setGname(gname);
goods.setGoprice(goprice);
goods.setGrprice(grprice);
goods.setGstore(gstore);
GoodsType goodsType = new GoodsType();
goodsType.setId(Integer.parseInt(goodstypeId));
goods.setGoodstypeId(goodsType);
goods.setIputTime(new Date());
goods.setGpicture("http://localhost:18081/views/upload/" + image);
int insert = goodsService.insert(goods);
if (insert > 0) {
return "success";
}
return "error";
}
/**
* 实现文件上传
*/
@ApiOperation(value = "图片上传接口", notes = "根据MultipartFile类上传文件")
@PostMapping(value = "/admin/uploadImg")
public Map<String, Object> ramanage(@RequestParam("file") MultipartFile file,
HttpServletRequest request) {
Map<String, Object> result = new HashMap<>();
try {
//获取跟目录
File path = new File(ResourceUtils.getURL("classpath:").getPath());
if (!path.exists()) path = new File("");
System.out.println("path:" + path.getAbsolutePath());
File upload = new File(path.getAbsolutePath(), "static/images/upload/");
if (!upload.exists())
upload.mkdirs();
String realPath = path.getAbsolutePath() + "/static/views/upload";
request.setAttribute("path", realPath);
image = FileUploadUtils.uploadFile(file, realPath);
result.put("code", 0);
result.put("image", image);
} catch (Exception e) {
result.put("code", 1);
e.printStackTrace();
}
return result;
}
}
公共控制器
/**
* 公告控制器
*/
@Api(value = "公告模块AIP接口")
@RestController
public class NoticeController {
@Autowired
private NoticeService noticeService;
/**
* 查询结果列表
*
* @param page
* @param limit
* @return
*/
@SuppressWarnings("rawtypes")
@ApiOperation(value = "公告模块接口",notes = "公告结果列表")
@GetMapping("/admin/notice/list")
public ServerLayResult<Notice> list(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit) {
@SuppressWarnings("unchecked")
ServerLayResult<Notice> result = new ServerLayResult(0, "", noticeService.count(), noticeService.selectAll(page, limit));
return result;
}
/**
* 根据id删除
*
* @param id
* @return
*/
@ApiOperation(value = "公告删除接口",notes = "根据公告id删除公告")
@GetMapping("/admin/notice/del")
public String delete(Integer id) {
System.out.println("id = " + id);
int row = noticeService.deleteByPrimaryKey(id);
if (row > 0) {
return "success";
}
return "error";
}
/**
* 更新
*
* @param notice
* @return
*/
@ApiOperation(value = "更新公告接口",notes = "根据公告前台json数据对象进行删除公告!")
@PostMapping("/admin/notice/update")
public String update(@RequestBody Notice notice) {
Notice upNotice = notice;
upNotice.setNtime(new Date());
if (upNotice != null) {
int index = noticeService.updateByPrimaryKey(upNotice);
if (index > 0) {
return "success";
}
}
return "error";
}
/**
* 保存操作
*
* @param notice
* @return
*/
@ApiOperation(value = "保存公告接口",notes = "根据前台传入json数据对象进行保存公告")
@PostMapping("/admin/notice/save")
public String save(@RequestBody Notice notice) {
Notice saveNotice = notice;
saveNotice.setNtime(new Date());
if (saveNotice != null) {
int index = noticeService.insert(saveNotice);
if (index > 0) {
return "success";
}
}
return "error";
}
}
如果也想学习本系统,下面领取。回复:069springboot