赞
踩
仓库管理系统基于springboot 开发 主要功能包括:
部门管理,菜单管理,权限管理,角色管理,用户管理,
客户管理,供应商管理,商品管理,进货管理,销售管理。等功能
jdk8+mysql+IntelliJ IDEA+maven
springboot+mysql+html+layui
登录界面
后台首页
系统管理
商品管理
登录权限Controller
RestController
@RequestMapping("loginfo")
public class LoginfoController {
@Autowired
private ILoginfoService loginfoService;
/**
* 查询所有登陆日志的信息
* @param loginfoVo
* @return
*/
@RequestMapping("loadAllLoginfo")
public DataGridView loadAllLoginfo(LoginfoVo loginfoVo){
IPage<Loginfo> page = new Page<Loginfo>(loginfoVo.getPage(),loginfoVo.getLimit());
QueryWrapper<Loginfo> queryWrapper = new QueryWrapper<Loginfo>();
//进行模糊查询
queryWrapper.like(StringUtils.isNotBlank(loginfoVo.getLoginname()),"loginname",loginfoVo.getLoginname());
queryWrapper.like(StringUtils.isNotBlank(loginfoVo.getLoginip()),"loginip",loginfoVo.getLoginip());
//数据库中登陆时间要大于用户输入的开始时间且小于用户登陆的结束时间
queryWrapper.ge(loginfoVo.getStartTime()!=null,"logintime",loginfoVo.getStartTime());
queryWrapper.le(loginfoVo.getEndTime()!=null,"logintime",loginfoVo.getEndTime());
//根据登陆时间进行降序排序
queryWrapper.orderByDesc("logintime");
loginfoService.page(page,queryWrapper);
return new DataGridView(page.getTotal(),page.getRecords());
}
/**
* 删除单条日志
* @param id
* @return
*/
@RequestMapping("deleteLoginfo")
public ResultObj deleteLoginfo(Integer id){
try {
loginfoService.removeById(id);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
/**
* 批量删除
* @param loginfoVo
* @return
*/
@RequestMapping("batchDeleteLoginfo")
public ResultObj batchDeleteLoginfo(LoginfoVo loginfoVo){
try {
Collection<Serializable> idList = new ArrayList<Serializable>();
for (Integer id : loginfoVo.getIds()) {
idList.add(id);
}
this.loginfoService.removeByIds(idList);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
文件上传Controller
@RestController
@RequestMapping("file")
public class FileController {
/**
* 文件上传
* @param mf
* @return
*/
@RequestMapping("uploadFile")
public Map<String,Object> uploadFile(MultipartFile mf) {
//1.得到文件名
String oldName = mf.getOriginalFilename();
//2.根据旧的文件名生成新的文件名
String newName=AppFileUtils.createNewFileName(oldName);
//3.得到当前日期的字符串
String dirName= DateUtil.format(new Date(), "yyyy-MM-dd");
//4.构造文件夹
File dirFile=new File(AppFileUtils.UPLOAD_PATH,dirName);
//5.判断当前文件夹是否存在
if(!dirFile.exists()) {
//如果不存在则创建新文件夹
dirFile.mkdirs();
}
//6.构造文件对象
File file=new File(dirFile, newName+"_temp");
//7.把mf里面的图片信息写入file
try {
mf.transferTo(file);
} catch (IllegalStateException | IOException e) {
e.printStackTrace();
}
Map<String,Object> map=new HashMap<String, Object>();
map.put("path",dirName+"/"+newName+"_temp");
return map;
}
/**
* 图片下载
*/
@RequestMapping("showImageByPath")
public ResponseEntity<Object> showImageByPath(String path){
return AppFileUtils.createResponseEntity(path);
}
}
商品Controller
/**
* 查询商品
* @param goodsVo
* @return
*/
@RequestMapping("loadAllGoods")
public DataGridView loadAllGoods(GoodsVo goodsVo){
IPage<Goods> page = new Page<>(goodsVo.getPage(),goodsVo.getLimit());
QueryWrapper<Goods> queryWrapper = new QueryWrapper();
queryWrapper.eq(goodsVo.getProviderid()!=null&&goodsVo.getProviderid()!=0,"providerid",goodsVo.getProviderid());
queryWrapper.like(StringUtils.isNotBlank(goodsVo.getGoodsname()),"goodsname",goodsVo.getGoodsname());
queryWrapper.like(StringUtils.isNotBlank(goodsVo.getProductcode()),"productcode",goodsVo.getProductcode());
queryWrapper.like(StringUtils.isNotBlank(goodsVo.getPromitcode()),"promitcode",goodsVo.getPromitcode());
queryWrapper.like(StringUtils.isNotBlank(goodsVo.getDescription()),"description",goodsVo.getDescription());
queryWrapper.like(StringUtils.isNotBlank(goodsVo.getSize()),"size",goodsVo.getSize());
queryWrapper.orderByDesc("id");
goodsService.page(page,queryWrapper);
List<Goods> records = page.getRecords();
for (Goods goods : records) {
Provider provider = providerService.getById(goods.getProviderid());
if (null!=provider){
goods.setProvidername(provider.getProvidername());
}
}
return new DataGridView(page.getTotal(),page.getRecords());
}
/**
* 添加商品
* @param goodsVo
* @return
*/
@RequestMapping("addGoods")
public ResultObj addGoods(GoodsVo goodsVo){
try {
if (goodsVo.getGoodsimg()!=null&&goodsVo.getGoodsimg().endsWith("_temp")){
String newName = AppFileUtils.renameFile(goodsVo.getGoodsimg());
goodsVo.setGoodsimg(newName);
}
goodsService.save(goodsVo);
return ResultObj.ADD_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.ADD_ERROR;
}
}
/**
* 修改商品
* @param goodsVo
* @return
*/
@RequestMapping("updateGoods")
public ResultObj updateGoods(GoodsVo goodsVo){
try {
//商品图片不是默认图片
if (!(goodsVo.getGoodsimg()!=null&&goodsVo.getGoodsimg().equals(Constast.DEFAULT_IMG_GOODS))){
if (goodsVo.getGoodsimg().endsWith("_temp")){
String newName = AppFileUtils.renameFile(goodsVo.getGoodsimg());
goodsVo.setGoodsimg(newName);
//删除原先的图片
String oldPath = goodsService.getById(goodsVo.getId()).getGoodsimg();
AppFileUtils.removeFileByPath(oldPath);
}
}
goodsService.updateById(goodsVo);
return ResultObj.UPDATE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.UPDATE_ERROR;
}
}
/**
* 删除商品
* @param id
* @return
*/
@RequestMapping("deleteGoods")
public ResultObj deleteGoods(Integer id,String goodsimg){
try {
//删除商品的图片
AppFileUtils.removeFileByPath(goodsimg);
goodsService.removeById(id);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
/**
* 加载所有可用的商品
* @return
*/
@RequestMapping("loadAllGoodsForSelect")
public DataGridView loadAllGoodsForSelect(){
QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
queryWrapper.eq("available",Constast.AVAILABLE_TRUE);
List<Goods> list = goodsService.list(queryWrapper);
for (Goods goods : list) {
Provider provider = providerService.getById(goods.getProviderid());
if (null!=provider){
goods.setProvidername(provider.getProvidername());
}
}
return new DataGridView(list);
}
/**
* 根据供应商ID查询商品信息
* @param providerid 供应商ID
* @return
*/
@RequestMapping("loadGoodsByProviderId")
public DataGridView loadGoodsByProviderId(Integer providerid){
QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
queryWrapper.eq("available",Constast.AVAILABLE_TRUE);
queryWrapper.eq(providerid!=null,"providerid",providerid);
List<Goods> list = goodsService.list(queryWrapper);
for (Goods goods : list) {
Provider provider = providerService.getById(goods.getProviderid());
if (null!=provider){
goods.setProvidername(provider.getProvidername());
}
}
return new DataGridView(list);
}
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。