diff --git a/pom.xml b/pom.xml index 5ea2133ec..3e63bf5d9 100644 --- a/pom.xml +++ b/pom.xml @@ -202,6 +202,13 @@ ${ruoyi.version} + + + com.ruoyi + ruoyi-business + ${ruoyi.version} + + @@ -212,6 +219,7 @@ ruoyi-quartz ruoyi-generator ruoyi-common + ruoyi-business pom diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 06a6028ce..9f7785b48 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -79,6 +79,12 @@ ruoyi-generator + + + com.ruoyi + ruoyi-business + + diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index d69c66d27..e359cd27b 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -6,9 +6,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://www.ks1.top:20336/Bizz?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: password + password: 123456 # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/ruoyi-business/pom.xml b/ruoyi-business/pom.xml new file mode 100644 index 000000000..b6f0b58f8 --- /dev/null +++ b/ruoyi-business/pom.xml @@ -0,0 +1,114 @@ + + + + ruoyi + com.ruoyi + 4.4.0 + + 4.0.0 + jar + ruoyi-business + + + 商业代码 + + + + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + + org.springframework.boot + spring-boot-devtools + true + + + + + io.springfox + springfox-swagger2 + + + + + io.swagger + swagger-annotations + 1.5.21 + + + + io.swagger + swagger-models + 1.5.21 + + + + + io.springfox + springfox-swagger-ui + + + + + mysql + mysql-connector-java + + + + + com.ruoyi + ruoyi-framework + + + + + com.ruoyi + ruoyi-quartz + + + + + com.ruoyi + ruoyi-generator + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.1.1.RELEASE + + true + + + + + repackage + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.0.0 + + false + ${project.artifactId} + + + + ${project.artifactId} + + + \ No newline at end of file diff --git a/ruoyi-business/productMenu.sql b/ruoyi-business/productMenu.sql new file mode 100644 index 000000000..d8e8adb5e --- /dev/null +++ b/ruoyi-business/productMenu.sql @@ -0,0 +1,22 @@ +-- 菜单 SQL +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品', '2000', '1', '/business/product', 'C', '0', 'business:product:view', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '产品菜单'); + +-- 按钮父菜单ID +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品查询', @parentId, '1', '#', 'F', '0', 'business:product:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); + +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品新增', @parentId, '2', '#', 'F', '0', 'business:product:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); + +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品修改', @parentId, '3', '#', 'F', '0', 'business:product:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); + +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品删除', @parentId, '4', '#', 'F', '0', 'business:product:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); + +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品导出', @parentId, '5', '#', 'F', '0', 'business:product:export', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); diff --git a/ruoyi-business/productTypeMenu.sql b/ruoyi-business/productTypeMenu.sql new file mode 100644 index 000000000..2dbf87d70 --- /dev/null +++ b/ruoyi-business/productTypeMenu.sql @@ -0,0 +1,22 @@ +-- 菜单 SQL +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品分类', '2000', '1', '/business/productType', 'C', '0', 'business:productType:view', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '产品分类菜单'); + +-- 按钮父菜单ID +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品分类查询', @parentId, '1', '#', 'F', '0', 'business:productType:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); + +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品分类新增', @parentId, '2', '#', 'F', '0', 'business:productType:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); + +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品分类修改', @parentId, '3', '#', 'F', '0', 'business:productType:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); + +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品分类删除', @parentId, '4', '#', 'F', '0', 'business:productType:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); + +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品分类导出', @parentId, '5', '#', 'F', '0', 'business:productType:export', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/controller/BizProductController.java b/ruoyi-business/src/main/java/com/ruoyi/business/controller/BizProductController.java new file mode 100644 index 000000000..45e15ad23 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/controller/BizProductController.java @@ -0,0 +1,160 @@ +package com.ruoyi.business.controller; + +import java.util.Date; +import java.util.List; + +import com.ruoyi.business.domain.BizProductType; +import com.ruoyi.business.service.IBizProductTypeService; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.framework.util.ShiroUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.business.domain.BizProduct; +import com.ruoyi.business.service.IBizProductService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 产品Controller + * + * @author ruoyi + * @date 2020-09-06 + */ +@Controller +@RequestMapping("/business/product") +public class BizProductController extends BaseController +{ + private String prefix = "business/product"; + + @Autowired + private IBizProductService bizProductService; + + @Autowired + private IBizProductTypeService bizProductTypeService; + + @RequiresPermissions("business:product:view") + @GetMapping() + public String product(ModelMap mmap) + { + mmap.put("productTypeList", bizProductTypeService.selectBizProductTypeList(new BizProductType())); + return prefix + "/product"; + } + + /** + * 查询产品列表 + */ + @RequiresPermissions("business:product:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(BizProduct bizProduct) + { + startPage(); + List list = bizProductService.selectBizProductList(bizProduct); + return getDataTable(list); + } + + /** + * 导出产品列表 + */ + @RequiresPermissions("business:product:export") + @Log(title = "产品", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(BizProduct bizProduct) + { + List list = bizProductService.selectBizProductList(bizProduct); + ExcelUtil util = new ExcelUtil(BizProduct.class); + return util.exportExcel(list, "product"); + } + + /** + * 新增产品 + */ + @GetMapping("/add") + public String add(ModelMap mmap) + { + mmap.put("productTypeList", bizProductTypeService.selectBizProductTypeList(new BizProductType())); + return prefix + "/add"; + } + + /** + * 新增保存产品 + */ + @RequiresPermissions("business:product:add") + @Log(title = "产品", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(BizProduct bizProduct) + { + Date now = new Date(); + bizProduct.setCreateBy(ShiroUtils.getLoginName()); + bizProduct.setCreateTime(now); + bizProduct.setProductCode("BPD" + DateUtils.dateTimeNow("YYYYMMDDHHMMSSSSS")); + //如果上架设置上架时间 + if (bizProduct.getOnlineStatus() == 1) { + bizProduct.setOnlineTime(now); + } + return toAjax(bizProductService.insertBizProduct(bizProduct)); + } + + /** + * 修改产品 + */ + @GetMapping("/edit/{productId}") + public String edit(@PathVariable(value = "productId", required = true) Long productId, ModelMap mmap) + { + BizProduct bizProduct = bizProductService.selectBizProductById(productId); + mmap.put("bizProduct", bizProduct); + mmap.put("productTypeList", bizProductTypeService.selectBizProductTypeList(new BizProductType())); + return prefix + "/edit"; + } + + /** + * 修改保存产品 + */ + @RequiresPermissions("business:product:edit") + @Log(title = "产品", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(BizProduct bizProduct) + { + bizProduct.setUpdateBy(ShiroUtils.getLoginName()); + bizProduct.setUpdateTime(new Date()); + return toAjax(bizProductService.updateBizProduct(bizProduct)); + } + + /** + * 上架下架产品 + */ + @RequiresPermissions("business:product:edit") + @Log(title = "产品", businessType = BusinessType.UPDATE) + @PostMapping("/status") + @ResponseBody + public AjaxResult editStatus(@PathVariable(value = "productId", required = true) Long productID) + { + return toAjax(bizProductService.updateBizProductStatus(productID)); + } + + /** + * 删除产品 + */ + @RequiresPermissions("business:product:remove") + @Log(title = "产品", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(bizProductService.deleteBizProductByIds(ids)); + } +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/controller/BizProductTypeController.java b/ruoyi-business/src/main/java/com/ruoyi/business/controller/BizProductTypeController.java new file mode 100644 index 000000000..37b0f75fc --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/controller/BizProductTypeController.java @@ -0,0 +1,135 @@ +package com.ruoyi.business.controller; + +import java.util.Date; +import java.util.List; + +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.framework.util.ShiroUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.business.domain.BizProductType; +import com.ruoyi.business.service.IBizProductTypeService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 产品分类Controller + * + * @author ruoyi + * @date 2020-09-05 + */ +@Controller +@RequestMapping("/business/productType") +public class BizProductTypeController extends BaseController +{ + private String prefix = "business/productType"; + + @Autowired + private IBizProductTypeService bizProductTypeService; + + @RequiresPermissions("business:productType:view") + @GetMapping() + public String productType() + { + return prefix + "/productType"; + } + + /** + * 查询产品分类列表 + */ + @RequiresPermissions("business:productType:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(BizProductType bizProductType) + { + startPage(); + List list = bizProductTypeService.selectBizProductTypeList(bizProductType); + return getDataTable(list); + } + + /** + * 导出产品分类列表 + */ + @RequiresPermissions("business:productType:export") + @Log(title = "产品分类", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(BizProductType bizProductType) + { + List list = bizProductTypeService.selectBizProductTypeList(bizProductType); + ExcelUtil util = new ExcelUtil(BizProductType.class); + return util.exportExcel(list, "productType"); + } + + /** + * 新增产品分类 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存产品分类 + */ + @RequiresPermissions("business:productType:add") + @Log(title = "产品分类", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(BizProductType bizProductType) + { + bizProductType.setCreateBy(ShiroUtils.getLoginName()); + bizProductType.setCreateTime(new Date()); + bizProductType.setProductTypeCode("BPT" + DateUtils.dateTimeNow("YYYYMMDDHHMMSSSSS")); + return toAjax(bizProductTypeService.insertBizProductType(bizProductType)); + } + + /** + * 修改产品分类 + */ + @GetMapping("/edit/{productTypeId}") + public String edit(@PathVariable(value = "productTypeId", required = true) Long productTypeId, ModelMap mmap) + { + BizProductType bizProductType = bizProductTypeService.selectBizProductTypeById(productTypeId); + mmap.put("bizProductType", bizProductType); + return prefix + "/edit"; + } + + /** + * 修改保存产品分类 + */ + @RequiresPermissions("business:productType:edit") + @Log(title = "产品分类", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(BizProductType bizProductType) + { + bizProductType.setUpdateBy(ShiroUtils.getLoginName()); + bizProductType.setUpdateTime(new Date()); + return toAjax(bizProductTypeService.updateBizProductType(bizProductType)); + } + + /** + * 删除产品分类 + */ + @RequiresPermissions("business:productType:remove") + @Log(title = "产品分类", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(bizProductTypeService.deleteBizProductTypeByIds(ids)); + } +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/domain/BizProduct.java b/ruoyi-business/src/main/java/com/ruoyi/business/domain/BizProduct.java new file mode 100644 index 000000000..30deacfa8 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/domain/BizProduct.java @@ -0,0 +1,198 @@ +package com.ruoyi.business.domain; + +import java.util.List; +import java.util.Date; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 产品对象 biz_product + * + * @author ruoyi + * @date 2020-09-06 + */ +public class BizProduct extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 产品ID */ + private Long productId; + + /** 产品编码 */ + @Excel(name = "产品编码") + private String productCode; + + /** 产品名称 */ + @Excel(name = "产品名称") + private String productName; + + /** 产品分类ID */ + @Excel(name = "产品分类ID") + private Long productTypeId; + + /** 产品类型 */ + @Excel(name = "产品类型") + private Integer productClass; + + /** 产品单价 */ + @Excel(name = "产品单价") + private Long amount; + + /** 排序 */ + @Excel(name = "排序") + private Long sort; + + /** 是否上架 */ + @Excel(name = "是否上架") + private Integer onlineStatus; + + /** 上架时间 */ + @Excel(name = "上架时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date onlineTime; + + /** 下架时间 */ + private Date offlineTime; + + /** 产品图片信息 */ + private String mainImage; + private List detailImages; + private List loopImages; + + public void setProductId(Long productId) + { + this.productId = productId; + } + + public Long getProductId() + { + return productId; + } + public void setProductCode(String productCode) + { + this.productCode = productCode; + } + + public String getProductCode() + { + return productCode; + } + public void setProductName(String productName) + { + this.productName = productName; + } + + public String getProductName() + { + return productName; + } + public void setProductTypeId(Long productTypeId) + { + this.productTypeId = productTypeId; + } + + public Long getProductTypeId() + { + return productTypeId; + } + public void setProductClass(Integer productClass) + { + this.productClass = productClass; + } + + public Integer getProductClass() + { + return productClass; + } + public void setAmount(Long amount) + { + this.amount = amount; + } + + public Long getAmount() + { + return amount; + } + public void setSort(Long sort) + { + this.sort = sort; + } + + public Long getSort() + { + return sort; + } + public void setOnlineStatus(Integer onlineStatus) + { + this.onlineStatus = onlineStatus; + } + + public Integer getOnlineStatus() + { + return onlineStatus; + } + public void setOnlineTime(Date onlineTime) + { + this.onlineTime = onlineTime; + } + + public Date getOnlineTime() + { + return onlineTime; + } + public void setOfflineTime(Date offlineTime) + { + this.offlineTime = offlineTime; + } + + public Date getOfflineTime() + { + return offlineTime; + } + + public String getMainImage() { + return mainImage; + } + + public void setMainImage(String mainImage) { + this.mainImage = mainImage; + } + + public List getDetailImages() { + return detailImages; + } + + public void setDetailImages(List detailImages) { + this.detailImages = detailImages; + } + + public List getLoopImages() { + return loopImages; + } + + public void setLoopImages(List loopImages) { + this.loopImages = loopImages; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("productId", getProductId()) + .append("productCode", getProductCode()) + .append("productName", getProductName()) + .append("productTypeId", getProductTypeId()) + .append("productClass", getProductClass()) + .append("amount", getAmount()) + .append("sort", getSort()) + .append("onlineStatus", getOnlineStatus()) + .append("onlineTime", getOnlineTime()) + .append("offlineTime", getOfflineTime()) + .append("remark", getRemark()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/domain/BizProductImage.java b/ruoyi-business/src/main/java/com/ruoyi/business/domain/BizProductImage.java new file mode 100644 index 000000000..db90dabc2 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/domain/BizProductImage.java @@ -0,0 +1,75 @@ +package com.ruoyi.business.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 产品图片对象 biz_product_image + * + * @author ruoyi + * @date 2020-09-06 + */ +public class BizProductImage extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 产品图片ID */ + private Long productImageId; + + /** 产品ID */ + private Long productId; + + /** 附件类型:0-主图,1-详情图,2-轮播图 */ + private Integer imageType; + + /** 附件地址 */ + private String imageUrl; + + + public void setProductImageId(Long productImageId) + { + this.productImageId = productImageId; + } + + public Long getProductImageId() + { + return productImageId; + } + public void setProductId(Long productId) + { + this.productId = productId; + } + + public Long getProductId() + { + return productId; + } + public void setImageType(Integer imageType) + { + this.imageType = imageType; + } + + public Integer getImageType() { + return imageType; + } + + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } + + public String getImageUrl() + { + return imageUrl; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("productImageId", getProductImageId()) + .append("productId", getProductId()) + .append("imageUrl", getImageUrl()) + .toString(); + } +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/domain/BizProductType.java b/ruoyi-business/src/main/java/com/ruoyi/business/domain/BizProductType.java new file mode 100644 index 000000000..1a6c07ec6 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/domain/BizProductType.java @@ -0,0 +1,110 @@ +package com.ruoyi.business.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 产品分类对象 biz_product_type + * + * @author ruoyi + * @date 2020-09-05 + */ +public class BizProductType extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 产品分类ID */ + private Long productTypeId; + + /** 产品分类编码 */ + @Excel(name = "产品分类编码") + private String productTypeCode; + + /** 产品分类名称 */ + @Excel(name = "产品分类名称") + private String productTypeName; + + /** 附件地址 */ + private String imageUrl; + + /** 排序 */ + @Excel(name = "排序") + private Long sort; + + /** 是否禁用:0-否,1-是 */ + @Excel(name = "是否禁用:0-否,1-是") + private Integer isEnable; + + public void setProductTypeId(Long productTypeId) + { + this.productTypeId = productTypeId; + } + + public Long getProductTypeId() + { + return productTypeId; + } + public void setProductTypeCode(String productTypeCode) + { + this.productTypeCode = productTypeCode; + } + + public String getProductTypeCode() + { + return productTypeCode; + } + public void setProductTypeName(String productTypeName) + { + this.productTypeName = productTypeName; + } + + public String getProductTypeName() + { + return productTypeName; + } + public void setImageUrl(String imageUrl) + { + this.imageUrl = imageUrl; + } + + public String getImageUrl() + { + return imageUrl; + } + public void setSort(Long sort) + { + this.sort = sort; + } + + public Long getSort() + { + return sort; + } + public void setIsEnable(Integer isEnable) + { + this.isEnable = isEnable; + } + + public Integer getIsEnable() + { + return isEnable; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("productTypeId", getProductTypeId()) + .append("productTypeCode", getProductTypeCode()) + .append("productTypeName", getProductTypeName()) + .append("imageUrl", getImageUrl()) + .append("sort", getSort()) + .append("isEnable", getIsEnable()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/mapper/BizProductMapper.java b/ruoyi-business/src/main/java/com/ruoyi/business/mapper/BizProductMapper.java new file mode 100644 index 000000000..0b2b5cfd1 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/mapper/BizProductMapper.java @@ -0,0 +1,95 @@ +package com.ruoyi.business.mapper; + +import java.util.List; +import com.ruoyi.business.domain.BizProduct; +import com.ruoyi.business.domain.BizProductImage; + +/** + * 产品Mapper接口 + * + * @author ruoyi + * @date 2020-09-06 + */ +public interface BizProductMapper +{ + /** + * 查询产品 + * + * @param productId 产品ID + * @return 产品 + */ + public BizProduct selectBizProductById(Long productId); + + /** + * 查询产品图片列表 + * + * @param productId 产品ID + * @return 产品图片列表 + */ + public List selectBizProductImageList(Long productId); + + /** + * 查询产品列表 + * + * @param bizProduct 产品 + * @return 产品集合 + */ + public List selectBizProductList(BizProduct bizProduct); + + /** + * 新增产品 + * + * @param bizProduct 产品 + * @return 结果 + */ + public int insertBizProduct(BizProduct bizProduct); + + /** + * 修改产品 + * + * @param bizProduct 产品 + * @return 结果 + */ + public int updateBizProduct(BizProduct bizProduct); + + /** + * 删除产品 + * + * @param productId 产品ID + * @return 结果 + */ + public int deleteBizProductById(Long productId); + + /** + * 批量删除产品 + * + * @param productIds 需要删除的数据ID + * @return 结果 + */ + public int deleteBizProductByIds(String[] productIds); + + /** + * 批量删除产品图片 + * + * @param productIds 需要删除的数据ID + * @return 结果 + */ + public int deleteBizProductImageByProductIds(String[] productIds); + + /** + * 批量新增产品图片 + * + * @param bizProductImageList 产品图片列表 + * @return 结果 + */ + public int batchBizProductImage(List bizProductImageList); + + + /** + * 通过产品ID删除产品图片信息 + * + * @param productId 角色ID + * @return 结果 + */ + public int deleteBizProductImageByProductId(Long productId); +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/mapper/BizProductTypeMapper.java b/ruoyi-business/src/main/java/com/ruoyi/business/mapper/BizProductTypeMapper.java new file mode 100644 index 000000000..2416797dc --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/mapper/BizProductTypeMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.business.mapper; + +import java.util.List; +import com.ruoyi.business.domain.BizProductType; + +/** + * 产品分类Mapper接口 + * + * @author ruoyi + * @date 2020-09-05 + */ +public interface BizProductTypeMapper +{ + /** + * 查询产品分类 + * + * @param productTypeId 产品分类ID + * @return 产品分类 + */ + public BizProductType selectBizProductTypeById(Long productTypeId); + + /** + * 查询产品分类列表 + * + * @param bizProductType 产品分类 + * @return 产品分类集合 + */ + public List selectBizProductTypeList(BizProductType bizProductType); + + /** + * 新增产品分类 + * + * @param bizProductType 产品分类 + * @return 结果 + */ + public int insertBizProductType(BizProductType bizProductType); + + /** + * 修改产品分类 + * + * @param bizProductType 产品分类 + * @return 结果 + */ + public int updateBizProductType(BizProductType bizProductType); + + /** + * 删除产品分类 + * + * @param productTypeId 产品分类ID + * @return 结果 + */ + public int deleteBizProductTypeById(Long productTypeId); + + /** + * 批量删除产品分类 + * + * @param productTypeIds 需要删除的数据ID + * @return 结果 + */ + public int deleteBizProductTypeByIds(String[] productTypeIds); +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/service/IBizProductService.java b/ruoyi-business/src/main/java/com/ruoyi/business/service/IBizProductService.java new file mode 100644 index 000000000..a6318e62d --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/service/IBizProductService.java @@ -0,0 +1,70 @@ +package com.ruoyi.business.service; + +import java.util.List; +import com.ruoyi.business.domain.BizProduct; +import com.ruoyi.business.domain.BizProductImage; + +/** + * 产品Service接口 + * + * @author ruoyi + * @date 2020-09-06 + */ +public interface IBizProductService +{ + /** + * 查询产品 + * + * @param productId 产品ID + * @return 产品 + */ + public BizProduct selectBizProductById(Long productId); + + /** + * 查询产品列表 + * + * @param bizProduct 产品 + * @return 产品集合 + */ + public List selectBizProductList(BizProduct bizProduct); + + /** + * 新增产品 + * + * @param bizProduct 产品 + * @return 结果 + */ + public int insertBizProduct(BizProduct bizProduct); + + /** + * 修改产品 + * + * @param bizProduct 产品 + * @return 结果 + */ + public int updateBizProduct(BizProduct bizProduct); + + /** + * 上架下架产品 + * + * @param productID 产品 + * @return 结果 + */ + public int updateBizProductStatus(Long productID); + + /** + * 批量删除产品 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteBizProductByIds(String ids); + + /** + * 删除产品信息 + * + * @param productId 产品ID + * @return 结果 + */ + public int deleteBizProductById(Long productId); +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/service/IBizProductTypeService.java b/ruoyi-business/src/main/java/com/ruoyi/business/service/IBizProductTypeService.java new file mode 100644 index 000000000..a89431f38 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/service/IBizProductTypeService.java @@ -0,0 +1,61 @@ +package com.ruoyi.business.service; + +import java.util.List; +import com.ruoyi.business.domain.BizProductType; + +/** + * 产品分类Service接口 + * + * @author ruoyi + * @date 2020-09-05 + */ +public interface IBizProductTypeService +{ + /** + * 查询产品分类 + * + * @param productTypeId 产品分类ID + * @return 产品分类 + */ + public BizProductType selectBizProductTypeById(Long productTypeId); + + /** + * 查询产品分类列表 + * + * @param bizProductType 产品分类 + * @return 产品分类集合 + */ + public List selectBizProductTypeList(BizProductType bizProductType); + + /** + * 新增产品分类 + * + * @param bizProductType 产品分类 + * @return 结果 + */ + public int insertBizProductType(BizProductType bizProductType); + + /** + * 修改产品分类 + * + * @param bizProductType 产品分类 + * @return 结果 + */ + public int updateBizProductType(BizProductType bizProductType); + + /** + * 批量删除产品分类 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteBizProductTypeByIds(String ids); + + /** + * 删除产品分类信息 + * + * @param productTypeId 产品分类ID + * @return 结果 + */ + public int deleteBizProductTypeById(Long productTypeId); +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/BizProductServiceImpl.java b/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/BizProductServiceImpl.java new file mode 100644 index 000000000..3c58bb286 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/BizProductServiceImpl.java @@ -0,0 +1,199 @@ +package com.ruoyi.business.service.impl; + +import java.util.Date; +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.system.utils.DictUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.ArrayList; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.transaction.annotation.Transactional; +import com.ruoyi.business.domain.BizProductImage; +import com.ruoyi.business.mapper.BizProductMapper; +import com.ruoyi.business.domain.BizProduct; +import com.ruoyi.business.service.IBizProductService; +import com.ruoyi.common.core.text.Convert; + +/** + * 产品Service业务层处理 + * + * @author ruoyi + * @date 2020-09-06 + */ +@Service +public class BizProductServiceImpl implements IBizProductService +{ + @Autowired + private BizProductMapper bizProductMapper; + + /** + * 查询产品 + * + * @param productId 产品ID + * @return 产品 + */ + @Override + public BizProduct selectBizProductById(Long productId) + { + BizProduct bizProduct = bizProductMapper.selectBizProductById(productId); + List imageList = bizProductMapper.selectBizProductImageList(productId); + List detailImages = new ArrayList(); + List loopImages = new ArrayList(); + //取出商品三种图片数据 + for (BizProductImage image : imageList) { + String url = image.getImageUrl(); + switch (image.getImageType()) { + case 0: + bizProduct.setMainImage(url); + break; + case 1: + detailImages.add(url); + break; + case 2: + loopImages.add(url); + break; + } + } + bizProduct.setDetailImages(detailImages); + bizProduct.setLoopImages(loopImages); + return bizProduct; + } + + /** + * 查询产品列表 + * + * @param bizProduct 产品 + * @return 产品 + */ + @Override + public List selectBizProductList(BizProduct bizProduct) + { + return bizProductMapper.selectBizProductList(bizProduct); + } + + /** + * 新增产品 + * + * @param bizProduct 产品 + * @return 结果 + */ + @Transactional + @Override + public int insertBizProduct(BizProduct bizProduct) + { + bizProduct.setCreateTime(DateUtils.getNowDate()); + int rows = bizProductMapper.insertBizProduct(bizProduct); + insertBizProductImage(bizProduct); + return rows; + } + + /** + * 修改产品 + * + * @param bizProduct 产品 + * @return 结果 + */ + @Transactional + @Override + public int updateBizProduct(BizProduct bizProduct) + { + bizProduct.setUpdateTime(DateUtils.getNowDate()); + bizProductMapper.deleteBizProductImageByProductId(bizProduct.getProductId()); + insertBizProductImage(bizProduct); + return bizProductMapper.updateBizProduct(bizProduct); + } + + /** + * 上架下架产品 + * + * @param productID 产品 + * @return 结果 + */ + @Transactional + @Override + public int updateBizProductStatus(Long productID) + { + BizProduct bizProduct = bizProductMapper.selectBizProductById(productID); + Date now = new Date(); + switch (bizProduct.getOnlineStatus()) + { + case 0: + bizProduct.setOnlineTime(now); + bizProduct.setOnlineStatus(1); + break; + case 1: + bizProduct.setOfflineTime(now); + bizProduct.setOnlineStatus(0); + break; + } + return bizProductMapper.updateBizProduct(bizProduct); + } + + /** + * 删除产品对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Transactional + @Override + public int deleteBizProductByIds(String ids) + { + bizProductMapper.deleteBizProductImageByProductIds(Convert.toStrArray(ids)); + return bizProductMapper.deleteBizProductByIds(Convert.toStrArray(ids)); + } + + /** + * 删除产品信息 + * + * @param productId 产品ID + * @return 结果 + */ + @Override + public int deleteBizProductById(Long productId) + { + bizProductMapper.deleteBizProductImageByProductId(productId); + return bizProductMapper.deleteBizProductById(productId); + } + + /** + * 新增产品图片信息 + * + * @param bizProduct 产品对象 + */ + public void insertBizProductImage(BizProduct bizProduct) + { + List detailImages = bizProduct.getDetailImages(); + List loopImages = bizProduct.getLoopImages(); + String mainImage = bizProduct.getMainImage(); + Long productId = bizProduct.getProductId(); + List list = new ArrayList(); + //插入三类产品图片 + if (StringUtils.isNotEmpty(mainImage)) { + list.add(getInsertProductImage(productId, 0, mainImage)); + } + if (StringUtils.isNotNull(detailImages)) { + for (String url : detailImages) { + list.add(getInsertProductImage(productId, 1, url)); + } + } + if (StringUtils.isNotNull(loopImages)) { + for (String url : loopImages) { + list.add(getInsertProductImage(productId, 2, url)); + } + } + if (list.size() > 0) { + bizProductMapper.batchBizProductImage(list); + } + } + + //新增企业图片 + public BizProductImage getInsertProductImage(Long productId, Integer type, String url) { + BizProductImage productImage = new BizProductImage(); + productImage.setProductId(productId); + productImage.setImageType(type); + productImage.setImageUrl(url); + return productImage; + } +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/BizProductTypeServiceImpl.java b/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/BizProductTypeServiceImpl.java new file mode 100644 index 000000000..c71525f2c --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/BizProductTypeServiceImpl.java @@ -0,0 +1,97 @@ +package com.ruoyi.business.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.business.mapper.BizProductTypeMapper; +import com.ruoyi.business.domain.BizProductType; +import com.ruoyi.business.service.IBizProductTypeService; +import com.ruoyi.common.core.text.Convert; + +/** + * 产品分类Service业务层处理 + * + * @author ruoyi + * @date 2020-09-05 + */ +@Service +public class BizProductTypeServiceImpl implements IBizProductTypeService +{ + @Autowired + private BizProductTypeMapper bizProductTypeMapper; + + /** + * 查询产品分类 + * + * @param productTypeId 产品分类ID + * @return 产品分类 + */ + @Override + public BizProductType selectBizProductTypeById(Long productTypeId) + { + return bizProductTypeMapper.selectBizProductTypeById(productTypeId); + } + + /** + * 查询产品分类列表 + * + * @param bizProductType 产品分类 + * @return 产品分类 + */ + @Override + public List selectBizProductTypeList(BizProductType bizProductType) + { + return bizProductTypeMapper.selectBizProductTypeList(bizProductType); + } + + /** + * 新增产品分类 + * + * @param bizProductType 产品分类 + * @return 结果 + */ + @Override + public int insertBizProductType(BizProductType bizProductType) + { + bizProductType.setCreateTime(DateUtils.getNowDate()); + return bizProductTypeMapper.insertBizProductType(bizProductType); + } + + /** + * 修改产品分类 + * + * @param bizProductType 产品分类 + * @return 结果 + */ + @Override + public int updateBizProductType(BizProductType bizProductType) + { + bizProductType.setUpdateTime(DateUtils.getNowDate()); + return bizProductTypeMapper.updateBizProductType(bizProductType); + } + + /** + * 删除产品分类对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteBizProductTypeByIds(String ids) + { + return bizProductTypeMapper.deleteBizProductTypeByIds(Convert.toStrArray(ids)); + } + + /** + * 删除产品分类信息 + * + * @param productTypeId 产品分类ID + * @return 结果 + */ + @Override + public int deleteBizProductTypeById(Long productTypeId) + { + return bizProductTypeMapper.deleteBizProductTypeById(productTypeId); + } +} diff --git a/ruoyi-business/src/main/resources/mapper/business/BizProductMapper.xml b/ruoyi-business/src/main/resources/mapper/business/BizProductMapper.xml new file mode 100644 index 000000000..9b9f13c8b --- /dev/null +++ b/ruoyi-business/src/main/resources/mapper/business/BizProductMapper.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select product_id, product_code, product_name, product_type_id, product_class, amount, sort, online_status, online_time, offline_time, remark, create_by, create_time, update_by, update_time from biz_product + + + + + + + + + + insert into biz_product + + product_code, + product_name, + product_type_id, + product_class, + amount, + sort, + online_status, + online_time, + offline_time, + remark, + create_by, + create_time, + update_by, + update_time, + + + #{productCode}, + #{productName}, + #{productTypeId}, + #{productClass}, + #{amount}, + #{sort}, + #{onlineStatus}, + #{onlineTime}, + #{offlineTime}, + #{remark}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update biz_product + + product_code = #{productCode}, + product_name = #{productName}, + product_type_id = #{productTypeId}, + product_class = #{productClass}, + amount = #{amount}, + sort = #{sort}, + online_status = #{onlineStatus}, + online_time = #{onlineTime}, + offline_time = #{offlineTime}, + remark = #{remark}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where product_id = #{productId} + + + + delete from biz_product where product_id = #{productId} + + + + delete from biz_product where product_id in + + #{productId} + + + + + delete from biz_product_image where product_id in + + #{productId} + + + + + delete from biz_product_image where product_id = #{productId} + + + + insert into biz_product_image( product_id, image_type, image_url ) values + + ( #{item.productId}, #{item.imageType}, #{item.imageUrl} ) + + + + \ No newline at end of file diff --git a/ruoyi-business/src/main/resources/mapper/business/BizProductTypeMapper.xml b/ruoyi-business/src/main/resources/mapper/business/BizProductTypeMapper.xml new file mode 100644 index 000000000..628c3c1e5 --- /dev/null +++ b/ruoyi-business/src/main/resources/mapper/business/BizProductTypeMapper.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + select product_type_id, product_type_code, product_type_name, image_url, sort, is_enable, create_by, create_time, update_by, update_time from biz_product_type + + + + + + + + insert into biz_product_type + + product_type_code, + product_type_name, + image_url, + sort, + is_enable, + create_by, + create_time, + update_by, + update_time, + + + #{productTypeCode}, + #{productTypeName}, + #{imageUrl}, + #{sort}, + #{isEnable}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update biz_product_type + + product_type_code = #{productTypeCode}, + product_type_name = #{productTypeName}, + image_url = #{imageUrl}, + sort = #{sort}, + is_enable = #{isEnable}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where product_type_id = #{productTypeId} + + + + delete from biz_product_type where product_type_id = #{productTypeId} + + + + delete from biz_product_type where product_type_id in + + #{productTypeId} + + + + \ No newline at end of file diff --git a/ruoyi-business/src/main/resources/templates/business/product/add.html b/ruoyi-business/src/main/resources/templates/business/product/add.html new file mode 100644 index 000000000..2e238e27f --- /dev/null +++ b/ruoyi-business/src/main/resources/templates/business/product/add.html @@ -0,0 +1,179 @@ + + + + + + + +
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + 排序数字越大排列越靠前 +
+
+
+ +
+
+ + +
+
+ + +
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+ +
+ 只能上传png jpg gif图片且大小不能超过200KB +
+
+
+ +
+
+ +
+ 只能上传png jpg gif图片且大小不能超过200KB +
+
+
+ +
+
+ +
+ 只能上传png jpg gif图片且大小不能超过200KB +
+
+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/ruoyi-business/src/main/resources/templates/business/product/edit.html b/ruoyi-business/src/main/resources/templates/business/product/edit.html new file mode 100644 index 000000000..43f565523 --- /dev/null +++ b/ruoyi-business/src/main/resources/templates/business/product/edit.html @@ -0,0 +1,196 @@ + + + + + + +
+
+

产品信息

+ +
+ +
+ +
+
+
+ +
+ + 代码生成请选择字典属性 +
+
+
+ +
+ + 代码生成请选择字典属性 +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + 代码生成请选择字典属性 +
+
+
+ +
+ +
+
+

产品图片信息

+
+
+ + +
+
+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/ruoyi-business/src/main/resources/templates/business/product/product.html b/ruoyi-business/src/main/resources/templates/business/product/product.html new file mode 100644 index 000000000..8054fb324 --- /dev/null +++ b/ruoyi-business/src/main/resources/templates/business/product/product.html @@ -0,0 +1,161 @@ + + + + + + +
+
+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • +  搜索 +  重置 +
  • +
+
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/ruoyi-business/src/main/resources/templates/business/productType/add.html b/ruoyi-business/src/main/resources/templates/business/productType/add.html new file mode 100644 index 000000000..a105888ce --- /dev/null +++ b/ruoyi-business/src/main/resources/templates/business/productType/add.html @@ -0,0 +1,76 @@ + + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+ 只能上传png jpg gif图片且大小不能超过200KB +
+
+
+ +
+ + 排序数字越大排列越靠前 +
+
+
+ +
+
+ + +
+
+ + +
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/ruoyi-business/src/main/resources/templates/business/productType/edit.html b/ruoyi-business/src/main/resources/templates/business/productType/edit.html new file mode 100644 index 000000000..4994e3f8f --- /dev/null +++ b/ruoyi-business/src/main/resources/templates/business/productType/edit.html @@ -0,0 +1,83 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+ +
+ 只能上传png jpg gif图片且大小不能超过200KB +
+
+
+ +
+ + 排序数字越大排列越靠前 +
+
+
+ +
+
+ + +
+
+ + +
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/ruoyi-business/src/main/resources/templates/business/productType/productType.html b/ruoyi-business/src/main/resources/templates/business/productType/productType.html new file mode 100644 index 000000000..82e8da88f --- /dev/null +++ b/ruoyi-business/src/main/resources/templates/business/productType/productType.html @@ -0,0 +1,109 @@ + + + + + + +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file