From 8dde877a9fd39aae1bcb7b910e2ec2a0aaf0ea0b Mon Sep 17 00:00:00 2001 From: zhh Date: Wed, 18 Apr 2018 15:41:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=A7=E5=93=81=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=88=86=E7=B1=BB=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 43 +++++++--- .../com/macro/mall/config/SecurityConfig.java | 2 +- ...PmsProductAttributeCategoryController.java | 82 +++++++++++++++++++ .../PmsProductCategoryController.java | 4 +- .../PmsProductAttributeCategoryService.java | 20 +++++ .../service/PmsProductCategoryService.java | 2 +- ...msProductAttributeCategoryServiceImpl.java | 51 ++++++++++++ .../impl/PmsProductCategoryServiceImpl.java | 2 +- 8 files changed, 191 insertions(+), 15 deletions(-) create mode 100644 mall-admin/src/main/java/com/macro/mall/controller/PmsProductAttributeCategoryController.java create mode 100644 mall-admin/src/main/java/com/macro/mall/service/PmsProductAttributeCategoryService.java create mode 100644 mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductAttributeCategoryServiceImpl.java diff --git a/README.md b/README.md index e5a5368..a4b41ab 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # mall -### 技术选型 +## 技术选型 -#### 后端技术 +### 后端技术 技术 | 名称 ----|---- Spring Boot | 容器+MVC框架 @@ -16,7 +16,7 @@ Hibernator-Validator | 验证框架 Vue | 前端框架 AdminLte | 前端模版 -#### 框架搭建 +### 框架搭建 功能 | 完成 ----|---- 集成MyBatis | ✔ @@ -32,10 +32,33 @@ crud操作demo | ✔ 包结构调整 | ✔ SpringSecurity登录改为Restful形式 | -#### 功能完善 -后台登录功能 -商品管理 -促销管理 -内容管理 -用户管理 -订单管理 \ No newline at end of file +### 功能完善 + +#### 后台登录功能 + +#### 商品管理 + +##### 商品属性分类管理 + +- 添加商品属性分类(名称) +- 分页查询全部商品属性分类 +- 删除单个商品属性分类 +- 修改单个属性分类名称 +- 查询单个属性分类信息 + +##### 商品属性管理 + +- 根据分类查询属性列表或参数列表(分页,支持类型) +- 添加商品属性 +- 查询单个商品属性 +- 编辑商品属性 +- 批量删除商品属性 +- 分页查询全部商品属性 + +#### 促销管理 + +#### 内容管理 + +#### 用户管理 + +#### 订单管理 diff --git a/mall-admin/src/main/java/com/macro/mall/config/SecurityConfig.java b/mall-admin/src/main/java/com/macro/mall/config/SecurityConfig.java index f343998..faa50bb 100644 --- a/mall-admin/src/main/java/com/macro/mall/config/SecurityConfig.java +++ b/mall-admin/src/main/java/com/macro/mall/config/SecurityConfig.java @@ -30,7 +30,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { http.authorizeRequests()//配置权限 // .antMatchers("/").access("hasRole('TEST')")//该路径需要TEST角色 .antMatchers("/").authenticated()//该路径需要登录认证 -// .antMatchers("/brand/list").hasAuthority("TEST")//该路径需要TEST权限 +// .antMatchers("/brand/getList").hasAuthority("TEST")//该路径需要TEST权限 .antMatchers("/**").permitAll() .and()//启用基于http的认证 .httpBasic() diff --git a/mall-admin/src/main/java/com/macro/mall/controller/PmsProductAttributeCategoryController.java b/mall-admin/src/main/java/com/macro/mall/controller/PmsProductAttributeCategoryController.java new file mode 100644 index 0000000..a594445 --- /dev/null +++ b/mall-admin/src/main/java/com/macro/mall/controller/PmsProductAttributeCategoryController.java @@ -0,0 +1,82 @@ +package com.macro.mall.controller; + +import com.macro.mall.dto.CommonResult; +import com.macro.mall.model.PmsProductAttributeCategory; +import com.macro.mall.service.PmsProductAttributeCategoryService; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 商品属性分类Controller + */ +@Controller +@RequestMapping("/productAttribute/category") +public class PmsProductAttributeCategoryController { + private static final Logger LOGGER = LoggerFactory.getLogger(PmsProductAttributeCategoryController.class); + @Autowired + private PmsProductAttributeCategoryService productAttributeCategoryService; + + @ApiOperation("添加商品属性分类") + @RequestMapping(value = "/create", method = RequestMethod.POST) + @ResponseBody + public Object create(@RequestParam String name) { + int count = productAttributeCategoryService.create(name); + if (count > 0) { + LOGGER.debug("create success name:{}", name); + return new CommonResult().success(count); + } else { + LOGGER.debug("create failed name:{}", name); + return new CommonResult().failed(); + } + } + + @ApiOperation("修改商品属性分类") + @RequestMapping(value = "/update/{id}", method = RequestMethod.POST) + @ResponseBody + public Object update(@PathVariable Long id, @RequestParam String name) { + int count = productAttributeCategoryService.update(id, name); + if (count > 0) { + LOGGER.debug("update success id:{}", id); + return new CommonResult().success(count); + } else { + LOGGER.debug("update failed id:{}", id); + return new CommonResult().failed(); + } + } + + @ApiOperation("删除单个商品属性分类") + @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) + @ResponseBody + public Object delete(@PathVariable Long id) { + int count = productAttributeCategoryService.delete(id); + if (count > 0) { + LOGGER.debug("delete success name:{}", id); + return new CommonResult().success(count); + } else { + LOGGER.debug("delete failed name:{}", id); + return new CommonResult().failed(); + } + } + + @ApiOperation("获取单个商品属性分类信息") + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public Object getItem(@PathVariable Long id) { + PmsProductAttributeCategory productAttributeCategory = productAttributeCategoryService.getItem(id); + return new CommonResult().success(productAttributeCategory); + } + + @ApiOperation("分页获取所有商品属性分类") + @RequestMapping(value = "/list", method = RequestMethod.GET) + @ResponseBody + public Object getList(@RequestParam(defaultValue = "5") Integer pageSize,@RequestParam(defaultValue = "1") Integer pageNum) { + List productAttributeCategoryList = productAttributeCategoryService.getList(pageSize,pageNum); + return new CommonResult().pageSuccess(productAttributeCategoryList); + } +} diff --git a/mall-admin/src/main/java/com/macro/mall/controller/PmsProductCategoryController.java b/mall-admin/src/main/java/com/macro/mall/controller/PmsProductCategoryController.java index 67638b1..ed8bc6d 100644 --- a/mall-admin/src/main/java/com/macro/mall/controller/PmsProductCategoryController.java +++ b/mall-admin/src/main/java/com/macro/mall/controller/PmsProductCategoryController.java @@ -65,10 +65,10 @@ public class PmsProductCategoryController { @ApiOperation("分页查询商品分类") @RequestMapping(value = "/list/{parentId}", method = RequestMethod.GET) @ResponseBody - public Object list(@PathVariable Long parentId, + public Object getList(@PathVariable Long parentId, @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) { - List productCategoryList = productCategoryService.list(parentId, pageSize, pageNum); + List productCategoryList = productCategoryService.getList(parentId, pageSize, pageNum); return new CommonResult().pageSuccess(productCategoryList); } diff --git a/mall-admin/src/main/java/com/macro/mall/service/PmsProductAttributeCategoryService.java b/mall-admin/src/main/java/com/macro/mall/service/PmsProductAttributeCategoryService.java new file mode 100644 index 0000000..e9ca0d3 --- /dev/null +++ b/mall-admin/src/main/java/com/macro/mall/service/PmsProductAttributeCategoryService.java @@ -0,0 +1,20 @@ +package com.macro.mall.service; + +import com.macro.mall.model.PmsProductAttributeCategory; + +import java.util.List; + +/** + * 商品属性分类Service + */ +public interface PmsProductAttributeCategoryService { + int create(String name); + + int update(Long id, String name); + + int delete(Long id); + + PmsProductAttributeCategory getItem(Long id); + + List getList(Integer pageSize, Integer pageNum); +} diff --git a/mall-admin/src/main/java/com/macro/mall/service/PmsProductCategoryService.java b/mall-admin/src/main/java/com/macro/mall/service/PmsProductCategoryService.java index 6056e8a..f953594 100644 --- a/mall-admin/src/main/java/com/macro/mall/service/PmsProductCategoryService.java +++ b/mall-admin/src/main/java/com/macro/mall/service/PmsProductCategoryService.java @@ -13,7 +13,7 @@ public interface PmsProductCategoryService { int update(Long id, PmsProductCategoryParam pmsProductCategoryParam); - List list(Long parentId, Integer pageSize, Integer pageNum); + List getList(Long parentId, Integer pageSize, Integer pageNum); int delete(Long id); } diff --git a/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductAttributeCategoryServiceImpl.java b/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductAttributeCategoryServiceImpl.java new file mode 100644 index 0000000..b30a704 --- /dev/null +++ b/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductAttributeCategoryServiceImpl.java @@ -0,0 +1,51 @@ +package com.macro.mall.service.impl; + +import com.github.pagehelper.PageHelper; +import com.macro.mall.mapper.PmsProductAttributeCategoryMapper; +import com.macro.mall.model.PmsProductAttributeCategory; +import com.macro.mall.model.PmsProductAttributeCategoryExample; +import com.macro.mall.service.PmsProductAttributeCategoryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * PmsProductAttributeCategoryService实现类 + */ +@Service +public class PmsProductAttributeCategoryServiceImpl implements PmsProductAttributeCategoryService { + @Autowired + private PmsProductAttributeCategoryMapper productAttributeCategoryMapper; + + @Override + public int create(String name) { + PmsProductAttributeCategory productAttributeCategory = new PmsProductAttributeCategory(); + productAttributeCategory.setName(name); + return productAttributeCategoryMapper.insertSelective(productAttributeCategory); + } + + @Override + public int update(Long id, String name) { + PmsProductAttributeCategory productAttributeCategory = new PmsProductAttributeCategory(); + productAttributeCategory.setName(name); + productAttributeCategory.setId(id); + return productAttributeCategoryMapper.updateByPrimaryKeySelective(productAttributeCategory); + } + + @Override + public int delete(Long id) { + return productAttributeCategoryMapper.deleteByPrimaryKey(id); + } + + @Override + public PmsProductAttributeCategory getItem(Long id) { + return productAttributeCategoryMapper.selectByPrimaryKey(id); + } + + @Override + public List getList(Integer pageSize, Integer pageNum) { + PageHelper.startPage(pageNum,pageSize); + return productAttributeCategoryMapper.selectByExample(new PmsProductAttributeCategoryExample()); + } +} diff --git a/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductCategoryServiceImpl.java b/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductCategoryServiceImpl.java index 9fbf207..606bd0b 100644 --- a/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductCategoryServiceImpl.java +++ b/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductCategoryServiceImpl.java @@ -39,7 +39,7 @@ public class PmsProductCategoryServiceImpl implements PmsProductCategoryService } @Override - public List list(Long parentId, Integer pageSize, Integer pageNum) { + public List getList(Long parentId, Integer pageSize, Integer pageNum) { PageHelper.startPage(pageNum, pageSize); PmsProductCategoryExample example = new PmsProductCategoryExample(); example.setOrderByClause("sort desc");