diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java index b684d96..04af6d1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java @@ -38,7 +38,7 @@ public class CommonController @Operation(summary = "上传商城相关图片", description = "上传图片,上传后返回原图和缩略图的url") @PostMapping("/productImage/upload") public RestResponse uploadProductImage(@RequestParam("file") MultipartFile file) { - return new RestResponse().setData(fileService.uploadProductImage(file)); + return new RestResponse().setData(fileService.uploadProductImage(file)).setSuccess(true); } @Operation(summary = "上传文件", description = "上传文件,上传后返回文件url") diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/BrandController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/BrandController.java new file mode 100644 index 0000000..4f28ded --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/BrandController.java @@ -0,0 +1,86 @@ +package com.ruoyi.web.controller.mall; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.mall.domain.Brand; +import com.ruoyi.mall.domain.query.BrandQuery; +import com.ruoyi.mall.service.BrandService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 品牌管理Controller + */ +@Api(description ="品牌管理接口列表") +@RestController +@RequestMapping("/pms/brand") +public class BrandController extends BaseController { + @Autowired + private BrandService service; + + @ApiOperation("查询品牌管理列表") + @PreAuthorize("@ss.hasPermi('pms:brand:list')") + @PostMapping("/list") + public ResponseEntity> list(@RequestBody BrandQuery query, Pageable page) { + List list = service.selectList(query, page); + return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal())); + } + @ApiOperation("所有品牌管理列表") + @PreAuthorize("@ss.hasPermi('pms:brand:list')") + @PostMapping("/all") + public ResponseEntity> all(@RequestBody BrandQuery query) { + return ResponseEntity.ok(service.selectList(query, null)); + } + + @ApiOperation("导出品牌管理列表") + @PreAuthorize("@ss.hasPermi('pms:brand:export')") + @Log(title = "品牌管理", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public ResponseEntity export(BrandQuery query) { +// List list = service.selectList(query, null); +// ExcelUtil util = new ExcelUtil<>(BrandVO.class); +// return ResponseEntity.ok(util.writeExcel(convert.dos2vos(list), "品牌管理数据")); + return null; + } + + @ApiOperation("获取品牌管理详细信息") + @PreAuthorize("@ss.hasPermi('pms:brand:query')") + @GetMapping(value = "/{id}") + public ResponseEntity getInfo(@PathVariable("id") Long id) { + return ResponseEntity.ok(service.selectById(id)); + } + + @ApiOperation("新增品牌管理") + @PreAuthorize("@ss.hasPermi('pms:brand:add')") + @Log(title = "品牌管理", businessType = BusinessType.INSERT) + @PostMapping + public ResponseEntity add(@RequestBody Brand brand) { + return ResponseEntity.ok(service.insert(brand)); + } + + @ApiOperation("修改品牌管理") + @PreAuthorize("@ss.hasPermi('pms:brand:edit')") + @Log(title = "品牌管理", businessType = BusinessType.UPDATE) + @PutMapping + public ResponseEntity edit(@RequestBody Brand brand) { + return ResponseEntity.ok(service.update(brand)); + } + + @ApiOperation("删除品牌管理") + @PreAuthorize("@ss.hasPermi('pms:brand:remove')") + @Log(title = "品牌管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{id}") + public ResponseEntity remove(@PathVariable Long id) { + return ResponseEntity.ok(service.deleteById(id)); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/ProductCategoryController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/ProductCategoryController.java new file mode 100644 index 0000000..787c456 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/ProductCategoryController.java @@ -0,0 +1,71 @@ +package com.ruoyi.web.controller.mall; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.mall.domain.ProductCategory; +import com.ruoyi.mall.domain.query.ProductCategoryQuery; +import com.ruoyi.mall.domain.vo.ProductCategoryVO; +import com.ruoyi.mall.service.ProductCategoryService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 商品分类Controller + * + * @author + * @date 2022-11-28 + */ +@Api(description ="商品分类接口列表") +@RestController +@RequestMapping("/pms/productCategory") +public class ProductCategoryController extends BaseController { + @Autowired + private ProductCategoryService service; + + + @ApiOperation("查询商品分类列表") + @PreAuthorize("@ss.hasPermi('pms:productCategory:list')") + @PostMapping("/list") + public ResponseEntity> list(@RequestBody ProductCategoryQuery query) { + List list = service.selectList(query, null); + return ResponseEntity.ok(list); + } + + @ApiOperation("获取商品分类详细信息") + @PreAuthorize("@ss.hasPermi('pms:productCategory:query')") + @GetMapping(value = "/{id}") + public ResponseEntity getInfo(@PathVariable("id") Long id) { + return ResponseEntity.ok(service.selectById(id)); + } + + @ApiOperation("新增商品分类") + @PreAuthorize("@ss.hasPermi('pms:productCategory:add')") + @Log(title = "商品分类", businessType = BusinessType.INSERT) + @PostMapping + public ResponseEntity add(@RequestBody ProductCategory productCategory) { + return ResponseEntity.ok(service.insert(productCategory)); + } + + @ApiOperation("修改商品分类") + @PreAuthorize("@ss.hasPermi('pms:productCategory:edit')") + @Log(title = "商品分类", businessType = BusinessType.UPDATE) + @PutMapping + public ResponseEntity edit(@RequestBody ProductCategory productCategory) { + return ResponseEntity.ok(service.update(productCategory)); + } + + @ApiOperation("删除商品分类") + @PreAuthorize("@ss.hasPermi('pms:productCategory:remove')") + @Log(title = "商品分类", businessType = BusinessType.DELETE) + @DeleteMapping("/{id}") + public ResponseEntity remove(@PathVariable Long id) { + return ResponseEntity.ok(service.deleteById(id)); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/ProductController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/ProductController.java new file mode 100644 index 0000000..62acf5f --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/ProductController.java @@ -0,0 +1,96 @@ +package com.ruoyi.web.controller.mall; + +import cn.xluobo.business.sc.course.domain.req.ReqSearchScCourse; +import cn.xluobo.business.sc.course.domain.resp.course.RespSearchCourse; +import cn.xluobo.business.sc.course.service.IScCourseService; +import cn.xluobo.core.page.RespPage; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.mall.domain.Product; +import com.ruoyi.mall.domain.query.ProductQuery; +import com.ruoyi.mall.domain.vo.ProductVO; +import com.ruoyi.mall.service.ProductService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 商品信息Controller + * + * @author zcc + * @date 2022-11-28 + */ +@Api(description ="商品信息接口列表") +@RestController +@RequestMapping("/pms/product") +public class ProductController extends BaseController { + @Autowired + private ProductService service; + @Autowired + private IScCourseService courseService; + + @ApiOperation("查询商品信息列表") + @PreAuthorize("@ss.hasPermi('pms:product:list')") + @PostMapping("/list") + public ResponseEntity> list(@RequestBody ProductQuery query, Pageable page) { +// service.getIds(query); + List list = service.selectList(query, page); + return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal())); + } + + @ApiOperation("导出商品信息列表") + @PreAuthorize("@ss.hasPermi('pms:product:export')") + @Log(title = "商品信息", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public ResponseEntity export(ProductQuery query) { +// List list = service.selectList(query, null); +// ExcelUtil util = new ExcelUtil<>(ProductVO.class); +// return ResponseEntity.ok(util.writeExcel(convert.dos2vos(list), "商品信息数据")); + return null; + } + + @ApiOperation("获取商品信息详细信息") + @PreAuthorize("@ss.hasPermi('pms:product:query')") + @GetMapping(value = "/{id}") + public ResponseEntity getInfo(@PathVariable("id") Long id) { + return ResponseEntity.ok(service.selectById(id)); + } + + @ApiOperation("新增商品信息") + @PreAuthorize("@ss.hasPermi('pms:product:add')") + @Log(title = "商品信息", businessType = BusinessType.INSERT) + @PostMapping + public ResponseEntity add(@RequestBody ProductVO product) { + return ResponseEntity.ok(service.insert(product)); + } + + @ApiOperation("修改商品信息") + @PreAuthorize("@ss.hasPermi('pms:product:edit')") + @Log(title = "商品信息", businessType = BusinessType.UPDATE) + @PutMapping + public ResponseEntity edit(@RequestBody ProductVO product) { + return ResponseEntity.ok(service.update(product)); + } + + @ApiOperation("删除商品信息") + @PreAuthorize("@ss.hasPermi('pms:product:remove')") + @Log(title = "商品信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{id}") + public ResponseEntity remove(@PathVariable Long id) { + return ResponseEntity.ok(service.deleteById(id)); + } + + @PostMapping("/courseList") + public ResponseEntity> listCourseForProduct(@RequestBody ReqSearchScCourse query){ + return ResponseEntity.ok(courseService.searchCourse(query)); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java index 56d947e..78ffcf0 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java @@ -1,17 +1,5 @@ package com.ruoyi.web.controller.system; -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -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.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.controller.BaseController; @@ -28,10 +16,16 @@ import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.domain.SysUserRole; import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; /** * 角色信息 - * + * * @author ruoyi */ @RestController @@ -43,10 +37,10 @@ public class SysRoleController extends BaseController @Autowired private TokenService tokenService; - + @Autowired private SysPermissionService permissionService; - + @Autowired private ISysUserService userService; @@ -97,6 +91,7 @@ public class SysRoleController extends BaseController return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); } role.setCreateBy(getUserId()); + role.setTenantId(getLoginUser().getNowTenantId()); return toAjax(roleService.insertRole(role)); } @@ -119,7 +114,7 @@ public class SysRoleController extends BaseController return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); } role.setUpdateBy(getUserId()); - + if (roleService.updateRole(role) > 0) { // 更新缓存用户权限 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index e434779..973a939 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -1,20 +1,5 @@ package com.ruoyi.web.controller.system; -import java.util.List; -import java.util.stream.Collectors; -import org.apache.commons.lang3.ArrayUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -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.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.controller.BaseController; @@ -29,10 +14,19 @@ import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.service.ISysPostService; import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysUserService; +import org.apache.commons.lang3.ArrayUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.stream.Collectors; /** * 用户信息 - * + * * @author ruoyi */ @RestController @@ -144,6 +138,7 @@ public class SysUserController extends BaseController } user.setCreateBy(getUserId()); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); + user.setTenantId(getLoginUser().getNowTenantId()); return toAjax(userService.insertUser(user)); } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java index 3460dbe..9f5b2bf 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java @@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.BaseEntity; import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import org.springframework.data.annotation.Id; import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; @@ -22,6 +23,7 @@ public class SysDept extends BaseEntity private static final long serialVersionUID = 1L; /** 部门ID */ + @Id private Long deptId; /** 父部门ID */ @@ -58,6 +60,8 @@ public class SysDept extends BaseEntity // private String tenantId; + private String deptType; + /** 子部门 */ private List children = new ArrayList(); diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java index 5e79fc9..9bee8aa 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java @@ -1,16 +1,17 @@ package com.ruoyi.common.core.domain.entity; -import java.util.ArrayList; -import java.util.List; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; +import com.ruoyi.common.core.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.core.domain.BaseEntity; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.util.ArrayList; +import java.util.List; /** * 菜单权限表 sys_menu - * + * * @author ruoyi */ public class SysMenu extends BaseEntity @@ -52,7 +53,7 @@ public class SysMenu extends BaseEntity /** 显示状态(0显示 1隐藏) */ private String visible; - + /** 菜单状态(0显示 1隐藏) */ private String status; @@ -62,6 +63,8 @@ public class SysMenu extends BaseEntity /** 菜单图标 */ private String icon; + + /** 子菜单 */ private List children = new ArrayList(); @@ -231,7 +234,7 @@ public class SysMenu extends BaseEntity { this.children = children; } - + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java index fecd8a9..8c3074c 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java @@ -67,7 +67,7 @@ public class SysUser extends BaseEntity private String status; /** 删除标志(0代表存在 2代表删除) */ - private String delFlag; + private String deleteFlag; /** 最后登录IP */ @Excel(name = "最后登录IP", type = Type.EXPORT) @@ -84,6 +84,8 @@ public class SysUser extends BaseEntity }) private SysDept dept; + private int teacher;//是否为任课教师 1是 0否 + /** 角色对象 */ private List roles; @@ -108,6 +110,14 @@ public class SysUser extends BaseEntity this.userId = userId; } + public int getTeacher() { + return teacher; + } + + public void setTeacher(int teacher) { + this.teacher = teacher; + } + public String getTenantId() { return tenantId; } @@ -244,14 +254,14 @@ public class SysUser extends BaseEntity this.status = status; } - public String getDelFlag() + public String getDeleteFlag() { - return delFlag; + return deleteFlag; } - public void setDelFlag(String delFlag) + public void setDeleteFlag(String deleteFlag) { - this.delFlag = delFlag; + this.deleteFlag = deleteFlag; } public String getLoginIp() @@ -338,7 +348,7 @@ public class SysUser extends BaseEntity .append("password", getPassword()) .append("salt", getSalt()) .append("status", getStatus()) - .append("delFlag", getDelFlag()) + .append("delFlag", getDeleteFlag()) .append("loginIp", getLoginIp()) .append("loginDate", getLoginDate()) .append("createBy", getCreateBy()) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java index c8b1c7b..3223761 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java @@ -39,7 +39,7 @@ public class UserDetailsServiceImpl implements UserDetailsService log.info("登录用户:{} 不存在.", username); throw new ServiceException("登录用户:" + username + " 不存在"); } - else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) + else if (UserStatus.DELETED.getCode().equals(user.getDeleteFlag())) { log.info("登录用户:{} 已被删除.", username); throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/Brand.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/Brand.java new file mode 100644 index 0000000..329e95d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/Brand.java @@ -0,0 +1,39 @@ +package com.ruoyi.mall.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseAudit; +import lombok.Data; +/** + * 品牌管理对象 mall_brand + * + * @author + */ + +@Data +@TableName("mall_brand") +public class Brand extends BaseAudit { + private static final long serialVersionUID = 1L; + + + private Long id; + + + @Excel(name = "NAME") + private String name; + + + @Excel(name = "SORT") + private Integer sort; + + + @Excel(name = "SHOW_STATUS") + private Integer showStatus; + + + @Excel(name = "品牌logo") + private String logo; + + private Long storeId; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/Product.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/Product.java new file mode 100644 index 0000000..f2b48ae --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/Product.java @@ -0,0 +1,101 @@ +package com.ruoyi.mall.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseAudit; +import lombok.Data; + +import java.math.BigDecimal; +/** + * 商品信息对象 mall_product + * + * @author zcc + */ + +@Data +@TableName("mall_product") +public class Product extends BaseAudit { + private static final long serialVersionUID = 1L; + + + private Long id; + + + @Excel(name = "BRAND_ID") + private Long brandId; + + + @Excel(name = "CATEGORY_ID") + private Long categoryId; + + + @Excel(name = "商品编码") + private String outProductId; + + + @Excel(name = "NAME") + private String name; + + + @Excel(name = "主图") + private String pic; + + + @Excel(name = "画册图片,连产品图片限制为5张,以逗号分割") + private String albumPics; + + + @Excel(name = "上架状态:0->下架;1->上架") + private Integer publishStatus; + + + @Excel(name = "排序") + private Integer sort; + + + @Excel(name = "PRICE") + private BigDecimal price; + + + @Excel(name = "单位") + private String unit; + + + @Excel(name = "商品重量,默认为克") + private BigDecimal weight; + + + @Excel(name = "商品销售属性,json格式") + //"[{\"name\":\"颜色\",\"options\":[{\"name\":\"粉\"},{\"name\":\"绿色\"},{\"name\":null}]},{\"name\":\"尺寸\",\"options\":[{\"name\":\"大\"},{\"name\":\"小\"},{\"name\":null}]}]" + private String productAttr; + + + @Excel(name = "产品详情网页内容") + private String detailHtml; + + + @Excel(name = "移动端网页详情") + private String detailMobileHtml; + + + @Excel(name = "品牌名称") + private String brandName; + + + @Excel(name = "商品分类名称") + private String productCategoryName; + + // 0->商品;1->课程 + private Integer isCourse; + + private Long courseId; + /** + * 客服id + */ + private Long customerService; + /** + * 教练id + */ + private Long instructor; + private Long storeId; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/ProductCategory.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/ProductCategory.java new file mode 100644 index 0000000..eed65bf --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/ProductCategory.java @@ -0,0 +1,47 @@ +package com.ruoyi.mall.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseAudit; +import lombok.Data; +/** + * 商品分类对象 mall_product_category + * + * @author zcc + */ + +@Data +@TableName("mall_product_category") +public class ProductCategory extends BaseAudit { + private static final long serialVersionUID = 1L; + + + private Long id; + + + @Excel(name = "上级分类的编号:0表示一级分类") + private Long parentId; + + + @Excel(name = "NAME") + private String typeName; + + + @Excel(name = "分类级别:0->1级;1->2级") + private Integer level; + + + @Excel(name = "显示状态:0->不显示;1->显示") + private Integer showStatus; + + + @Excel(name = "SORT") + private Integer sort; + + + @Excel(name = "图标") + private String icon; + + private Long storeId; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/Sku.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/Sku.java new file mode 100644 index 0000000..ef16e63 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/Sku.java @@ -0,0 +1,47 @@ +package com.ruoyi.mall.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseAudit; +import lombok.Data; + +import java.math.BigDecimal; +/** + * sku信息对象 mall_sku + * + * @author zcc + */ + +@Data +@TableName("mall_sku") +public class Sku extends BaseAudit { + private static final long serialVersionUID = 1L; + + + private Long id; + + + @Excel(name = "PRODUCT_ID") + private Long productId; + + + @Excel(name = "sku编码") + private String outSkuId; + + @Excel(name = "PRICE") + private BigDecimal price; + + + @Excel(name = "展示图片") + private String pic; + + + @Excel(name = "商品销售属性,json格式") + //"{\"颜色\":\"粉\",\"尺寸\":\"大\"}" + private String spData; + + + @Excel(name = "库存数") + private Integer stock; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/query/BrandQuery.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/query/BrandQuery.java new file mode 100644 index 0000000..a8624d0 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/query/BrandQuery.java @@ -0,0 +1,25 @@ +package com.ruoyi.mall.domain.query; + +import lombok.Data; + +/** + * 品牌管理 查询 对象 + * + * @author + */ + +@Data +public class BrandQuery { + + private String nameLike; + + + private Integer sort; + + + private Integer showStatus; + + + private String logo; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/query/ProductCategoryQuery.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/query/ProductCategoryQuery.java new file mode 100644 index 0000000..ac3173d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/query/ProductCategoryQuery.java @@ -0,0 +1,31 @@ +package com.ruoyi.mall.domain.query; + +import lombok.Data; + +/** + * 商品分类 查询 对象 + * + * @author + */ + +@Data +public class ProductCategoryQuery { + //"上级分类的编号:0表示一级分类 精确匹配") + private Long parentId; + + //"NAME 精确匹配") + private String nameLike; + + //"分类级别:0->1级;1->2级 精确匹配") + private Integer level; + + //"显示状态:0->不显示;1->显示 精确匹配") + private Integer showStatus; + + //"SORT 精确匹配") + private Integer sort; + + //"图标 精确匹配") + private String icon; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/query/ProductQuery.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/query/ProductQuery.java new file mode 100644 index 0000000..4ba66db --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/query/ProductQuery.java @@ -0,0 +1,83 @@ +package com.ruoyi.mall.domain.query; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 商品信息 查询 对象 + * + * @author + */ +//商品信息 查询 对象") +@Data +public class ProductQuery { + //"BRAND_ID 精确匹配") + private Long brandId; + + //"CATEGORY_ID 精确匹配") + private Long categoryId; + + //"商品编码 精确匹配") + private String outProductId; + + //"NAME 精确匹配") + private String nameLike; + + //"主图 精确匹配") + private String pic; + + //"画册图片,连产品图片限制为5张,以逗号分割 精确匹配") + private String albumPics; + + //"上架状态:0->下架;1->上架 精确匹配") + private Integer publishStatus; + + //"排序 精确匹配") + private Integer sort; + + //"PRICE 精确匹配") + private BigDecimal price; + + //"单位 精确匹配") + private String unit; + + //name = "商品销售属性,json格式") + private String productAttr; + + //"商品重量,默认为克 精确匹配") + private BigDecimal weight; + + //"产品详情网页内容 精确匹配") + private String detailHtml; + + //"移动端网页详情 精确匹配") + private String detailMobileHtml; + + //"品牌名称 精确匹配") + private String brandNameLike; + + //"商品分类名称 精确匹配") + private String productCategoryNameLike; + + //"排序字段") + private String orderField = "sort"; + + //"排序规则") + private String orderSort = "desc"; + + //"搜索关键字") + private String search; + // 0->商品;1->课程 + private Integer isCourse; + + //排查的id + private List excludeProductIds; + + private List ids; + + private List brandIds; + private List CategoryIds; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/query/SkuQuery.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/query/SkuQuery.java new file mode 100644 index 0000000..6ef59ff --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/query/SkuQuery.java @@ -0,0 +1,30 @@ +package com.ruoyi.mall.domain.query; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * sku信息 查询 对象 + * + * @author + */ +//sku信息 查询 对象") +@Data +public class SkuQuery { + //"PRODUCT_ID 精确匹配") + private Long productId; + + //"sku编码 精确匹配") + private String outSkuId; + + //"PRICE 精确匹配") + private BigDecimal price; + + //"展示图片 精确匹配") + private String pic; + + //"商品销售属性,json格式 精确匹配") + private String spData; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/BrandVO.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/BrandVO.java new file mode 100644 index 0000000..15bc2ea --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/BrandVO.java @@ -0,0 +1,27 @@ +package com.ruoyi.mall.domain.vo; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseAudit; +import lombok.Data; +/** + * 品牌管理 数据视图对象 + * + * @author zcc + */ +@Data +public class BrandVO extends BaseAudit { + /** ID */ + private Long id; + /** NAME */ + @Excel(name = "NAME") + private String name; + /** SORT */ + @Excel(name = "SORT") + private Integer sort; + /** SHOW_STATUS */ + @Excel(name = "SHOW_STATUS") + private Integer showStatus; + /** 品牌logo */ + @Excel(name = "品牌logo") + private String logo; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/ProductCategoryVO.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/ProductCategoryVO.java new file mode 100644 index 0000000..1479186 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/ProductCategoryVO.java @@ -0,0 +1,30 @@ +package com.ruoyi.mall.domain.vo; + +import com.ruoyi.common.core.domain.BaseAudit; +import lombok.Data; + +import java.util.List; + +/** + * 商品分类 数据视图对象 + * + * @author zcc + */ +@Data +public class ProductCategoryVO extends BaseAudit { + /** ID */ + private Long id; + /** 上级分类的编号:0表示一级分类 */ + private Long parentId; + /** NAME */ + private String typeName; + /** 分类级别:0->1级;1->2级 */ + private Integer level; + /** 显示状态:0->不显示;1->显示 */ + private Integer showStatus; + /** SORT */ + private Integer sort; + /** 图标 */ + private String icon; + private List children; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/ProductDetailVO.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/ProductDetailVO.java new file mode 100644 index 0000000..e73d515 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/ProductDetailVO.java @@ -0,0 +1,15 @@ +package com.ruoyi.mall.domain.vo; + +import com.ruoyi.mall.domain.Brand; +import com.ruoyi.mall.domain.Product; +import com.ruoyi.mall.domain.Sku; +import lombok.Data; + +import java.util.List; + +@Data +public class ProductDetailVO { + private Product product; + private List skus; + private Brand brand; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/ProductVO.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/ProductVO.java new file mode 100644 index 0000000..bef2db5 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/ProductVO.java @@ -0,0 +1,67 @@ +package com.ruoyi.mall.domain.vo; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseAudit; +import com.ruoyi.mall.domain.Sku; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; +/** + * 商品信息 数据视图对象 + * + * @author zcc + */ +@Data +public class ProductVO extends BaseAudit { + /** ID */ + private Long id; + /** BRAND_ID */ + @Excel(name = "BRAND_ID") + private Long brandId; + /** CATEGORY_ID */ + @Excel(name = "CATEGORY_ID") + private Long categoryId; + /** 商品编码 */ + @Excel(name = "商品编码") + private String outProductId; + /** NAME */ + @Excel(name = "NAME") + private String name; + /** 主图 */ + @Excel(name = "主图") + private String pic; + /** 画册图片,连产品图片限制为5张,以逗号分割 */ + @Excel(name = "画册图片,连产品图片限制为5张,以逗号分割") + private String albumPics; + /** 上架状态:0->下架;1->上架 */ + @Excel(name = "上架状态:0->下架;1->上架") + private Integer publishStatus; + /** 排序 */ + @Excel(name = "排序") + private Integer sort; + /** PRICE */ + @Excel(name = "PRICE") + private BigDecimal price; + /** 单位 */ + @Excel(name = "单位") + private String unit; + /** 商品重量,默认为克 */ + @Excel(name = "商品重量,默认为克") + private BigDecimal weight; + /** 产品详情网页内容 */ + @Excel(name = "产品详情网页内容") + private String detailHtml; + /** 移动端网页详情 */ + @Excel(name = "移动端网页详情") + private String detailMobileHtml; + /** 品牌名称 */ + @Excel(name = "品牌名称") + private String brandName; + /** 商品分类名称 */ + @Excel(name = "商品分类名称") + private String productCategoryName; + @Excel(name = "商品销售属性,json格式") + private String productAttr; + private List skuList; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/SkuVO.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/SkuVO.java new file mode 100644 index 0000000..cca4728 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/vo/SkuVO.java @@ -0,0 +1,34 @@ +package com.ruoyi.mall.domain.vo; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseAudit; +import lombok.Data; + +import java.math.BigDecimal; +/** + * sku信息 数据视图对象 + * + * @author zcc + */ +@Data +public class SkuVO extends BaseAudit { + /** ID */ + private Long id; + /** PRODUCT_ID */ + @Excel(name = "PRODUCT_ID") + private Long productId; + /** sku编码 */ + @Excel(name = "sku编码") + private String outSkuId; + /** PRICE */ + @Excel(name = "PRICE") + private BigDecimal price; + /** 展示图片 */ + @Excel(name = "展示图片") + private String pic; + /** 商品销售属性,json格式 */ + @Excel(name = "商品销售属性,json格式") + private String spData; + @Excel(name = "库存数") + private Integer stock; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/BrandMapper.java b/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/BrandMapper.java new file mode 100644 index 0000000..4233411 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/BrandMapper.java @@ -0,0 +1,21 @@ +package com.ruoyi.mall.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.mall.domain.Brand; + +import java.util.List; + +/** + * 品牌管理Mapper接口 + * + * @author zcc + */ +public interface BrandMapper extends BaseMapper { + /** + * 查询品牌管理列表 + * + * @param brand 品牌管理 + * @return 品牌管理集合 + */ + List selectByEntity(Brand brand); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/ProductCategoryMapper.java b/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/ProductCategoryMapper.java new file mode 100644 index 0000000..7d7411e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/ProductCategoryMapper.java @@ -0,0 +1,21 @@ +package com.ruoyi.mall.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.mall.domain.ProductCategory; + +import java.util.List; + +/** + * 商品分类Mapper接口 + * + * @author zcc + */ +public interface ProductCategoryMapper extends BaseMapper { + /** + * 查询商品分类列表 + * + * @param productCategory 商品分类 + * @return 商品分类集合 + */ + List selectByEntity(ProductCategory productCategory); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/ProductMapper.java b/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/ProductMapper.java new file mode 100644 index 0000000..bd03d9d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/ProductMapper.java @@ -0,0 +1,21 @@ +package com.ruoyi.mall.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.mall.domain.Product; + +import java.util.List; + +/** + * 商品信息Mapper接口 + * + * @author zcc + */ +public interface ProductMapper extends BaseMapper { + /** + * 查询商品信息列表 + * + * @param product 商品信息 + * @return 商品信息集合 + */ + List selectByEntity(Product product); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/SkuMapper.java b/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/SkuMapper.java new file mode 100644 index 0000000..2056db5 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/SkuMapper.java @@ -0,0 +1,25 @@ +package com.ruoyi.mall.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.mall.domain.Sku; +import org.apache.ibatis.annotations.Param; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * sku信息Mapper接口 + * + * @author zcc + */ +public interface SkuMapper extends BaseMapper { + /** + * 查询sku信息列表 + * + * @param sku sku信息 + * @return sku信息集合 + */ + List selectByEntity(Sku sku); + + int updateStockById(@Param("skuId")Long skuId, @Param("optDate")LocalDateTime optDate, @Param("quantity")Integer quantity); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/service/BrandService.java b/ruoyi-system/src/main/java/com/ruoyi/mall/service/BrandService.java new file mode 100644 index 0000000..145920d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/service/BrandService.java @@ -0,0 +1,103 @@ +package com.ruoyi.mall.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.mall.domain.Brand; +import com.ruoyi.mall.domain.query.BrandQuery; +import com.ruoyi.mall.mapper.BrandMapper; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * 品牌管理Service业务层处理 + * + * + * @author zcc + */ +@Service +public class BrandService { + @Autowired + private BrandMapper brandMapper; + + /** + * 查询品牌管理 + * + * @param id 品牌管理主键 + * @return 品牌管理 + */ + public Brand selectById(Long id) { + return brandMapper.selectById(id); + } + + /** + * 查询品牌管理列表 + * + * @param query 查询条件 + * @param page 分页条件 + * @return 品牌管理 + */ + public List selectList(BrandQuery query, Pageable page) { + if (page != null) { + PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize()); + } + QueryWrapper qw = new QueryWrapper<>(); + String nameLike = query.getNameLike(); + if (!StringUtils.isEmpty(nameLike)) { + qw.like("name", nameLike); + } + Integer sort = query.getSort(); + if (sort != null) { + qw.eq("sort", sort); + } + Integer showStatus = query.getShowStatus(); + if (showStatus != null) { + qw.eq("show_status", showStatus); + } + String logo = query.getLogo(); + if (!StringUtils.isEmpty(logo)) { + qw.eq("logo", logo); + } + qw.eq("store_id", SecurityUtils.getDeptId()); + qw.orderByAsc("sort"); + + return brandMapper.selectList(qw); + } + + /** + * 新增品牌管理 + * + * @param brand 品牌管理 + * @return 结果 + */ + public int insert(Brand brand) { + brand.setCreateTime(LocalDateTime.now()); + brand.setStoreId(SecurityUtils.getDeptId()); + return brandMapper.insert(brand); + } + + /** + * 修改品牌管理 + * + * @param brand 品牌管理 + * @return 结果 + */ + public int update(Brand brand) { + return brandMapper.updateById(brand); + } + + /** + * 删除品牌管理信息 + * + * @param id 品牌管理主键 + * @return 结果 + */ + public int deleteById(Long id) { + return brandMapper.deleteById(id); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/service/ProductCategoryService.java b/ruoyi-system/src/main/java/com/ruoyi/mall/service/ProductCategoryService.java new file mode 100644 index 0000000..3498625 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/service/ProductCategoryService.java @@ -0,0 +1,154 @@ +package com.ruoyi.mall.service; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.mall.domain.ProductCategory; +import com.ruoyi.mall.domain.query.ProductCategoryQuery; +import com.ruoyi.mall.domain.vo.ProductCategoryVO; +import com.ruoyi.mall.mapper.ProductCategoryMapper; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +/** + * 商品分类Service业务层处理 + * + * @author zcc + */ +@Service +public class ProductCategoryService { + @Autowired + private ProductCategoryMapper productCategoryMapper; + + + /** + * 查询商品分类 + * + * @param id 商品分类主键 + * @return 商品分类 + */ + public ProductCategory selectById(Long id) { + return productCategoryMapper.selectById(id); + } + + /** + * 查询商品分类列表 + * + * @param query 查询条件 + * @param page 分页条件 + * @return 商品分类 + */ + public List selectList(ProductCategoryQuery query, Pageable page) { + if (page != null) { + PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize()); + } + QueryWrapper qw = new QueryWrapper<>(); + Long parentId = query.getParentId(); + if (parentId != null) { + qw.eq("parent_id", parentId); + } + String nameLike = query.getNameLike(); + if (!StringUtils.isEmpty(nameLike)) { + qw.like("type_name", nameLike); + } + Integer level = query.getLevel(); + if (level != null) { + qw.eq("level", level); + } + Integer showStatus = query.getShowStatus(); + if (showStatus != null) { + qw.eq("show_status", showStatus); + } + Integer sort = query.getSort(); + if (sort != null) { + qw.eq("sort", sort); + } + String icon = query.getIcon(); + if (!StringUtils.isEmpty(icon)) { + qw.eq("icon", icon); + } + qw.eq("store_id", SecurityUtils.getDeptId()); + qw.orderByAsc("sort"); + + List productCategories = productCategoryMapper.selectList(qw); + List productCategoryVOS = BeanUtil.copyToList(productCategories,ProductCategoryVO.class); + return formatTree(productCategoryVOS); + + } + + private List formatTree(List nodes) { + List tree = new ArrayList<>(); + List children = new ArrayList<>(); + // 1)先获取到所有根节点 + for (ProductCategoryVO node : nodes) { + if (node.getParentId() == null || node.getParentId() == 0) { + tree.add(node); + } else { + children.add(node); + } + } + // 2)把所有除根结点外的节点作为子节点,然后遍历每一个根节点 + for (ProductCategoryVO node : tree) { + // 3)递归构建此根的子节点 + recur(node, children); + } + return tree; + } + + private void recur(ProductCategoryVO rootNode, List children) { + // 1)遍历剩余子节点,找出当前根的子节点 + for (ProductCategoryVO node : children) { + // 2)如果子节点的父id等于根节点的id,那么就将这个节点加到根节点的children列表中 + if (rootNode.getId() == node.getParentId()) { + if (rootNode.getChildren() == null) { + rootNode.setChildren(new ArrayList<>()); + } + rootNode.getChildren().add(node); + // 3)以当前节点作为根节点进行递归,检查是否还有子节点。 + recur(node, children); + } + } + } + + + /** + * 新增商品分类 + * + * @param productCategory 商品分类 + * @return 结果 + */ + public int insert(ProductCategory productCategory) { + productCategory.setCreateTime(LocalDateTime.now()); + productCategory.setStoreId(SecurityUtils.getDeptId()); + return productCategoryMapper.insert(productCategory); + } + + /** + * 修改商品分类 + * + * @param productCategory 商品分类 + * @return 结果 + */ + public int update(ProductCategory productCategory) { + return productCategoryMapper.updateById(productCategory); + } + + /** + * 删除商品分类信息 + * + * @param id 商品分类主键 + * @return 结果 + */ + public int deleteById(Long id) { + return productCategoryMapper.deleteById(id); + } + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/service/ProductService.java b/ruoyi-system/src/main/java/com/ruoyi/mall/service/ProductService.java new file mode 100644 index 0000000..cc27231 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/service/ProductService.java @@ -0,0 +1,268 @@ +package com.ruoyi.mall.service; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.mall.domain.Brand; +import com.ruoyi.mall.domain.Product; +import com.ruoyi.mall.domain.ProductCategory; +import com.ruoyi.mall.domain.Sku; +import com.ruoyi.mall.domain.query.ProductQuery; +import com.ruoyi.mall.domain.vo.ProductDetailVO; +import com.ruoyi.mall.domain.vo.ProductVO; +import com.ruoyi.mall.mapper.BrandMapper; +import com.ruoyi.mall.mapper.ProductCategoryMapper; +import com.ruoyi.mall.mapper.ProductMapper; +import com.ruoyi.mall.mapper.SkuMapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 商品信息Service业务层处理 + * + * + * @author zcc + */ +@Service +@Slf4j +public class ProductService { + @Autowired + private ProductMapper productMapper; + @Autowired + private ProductCategoryMapper productCategoryMapper; + @Autowired + private SkuMapper skuMapper; + @Autowired + private BrandMapper brandMapper; + + /** + * 查询商品信息 + * + * @param id 商品信息主键 + * @return 商品信息 + */ + public ProductVO selectById(Long id) { + Product product = productMapper.selectById(id); + ProductVO productVO = BeanUtil.toBean(product,ProductVO.class); + QueryWrapper qw = new QueryWrapper<>(); + qw.eq("product_id", product.getId()); + List skus = skuMapper.selectList(qw); + productVO.setSkuList(skus); + return productVO; + } + + /** + * 查询商品信息列表 + * + * @param query 查询条件 + * @param page 分页条件 + * @return 商品信息 + */ + public List selectList(ProductQuery query, Pageable page) { + if (page != null) { + PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize()); + } + QueryWrapper qw = new QueryWrapper<>(); + if (StringUtils.isNoneEmpty(query.getOrderField())){ + if (StringUtils.isNotEmpty(query.getOrderSort()) && "desc".equalsIgnoreCase(query.getOrderSort())) { + qw.orderByDesc(query.getOrderField()); + } else { + qw.orderByAsc(query.getOrderField()); + } + }else { + qw.orderByDesc("publish_status"); + qw.orderByAsc("sort"); + } + Long categoryId = query.getCategoryId(); + if (categoryId != null) { + qw.eq("category_id", categoryId); + } + Integer publishStatus = query.getPublishStatus(); + if (publishStatus != null) { + qw.eq("publish_status", publishStatus); + } + String search = query.getSearch(); + if (StringUtils.isNoneEmpty(search)){ + qw.like("name", "%".concat(query.getSearch().trim()).concat("%")); + } + + if (CollectionUtil.isNotEmpty(query.getExcludeProductIds())) { + qw.notIn("id",query.getExcludeProductIds()); + } + if (CollectionUtil.isNotEmpty(query.getIds())) { + qw.in("id",query.getIds()); + } + String nameLike = query.getNameLike(); + if (StringUtils.isNoneEmpty(nameLike)){ + qw.like("name", "%".concat(nameLike).concat("%")); + } + if (ObjectUtil.isNotEmpty(query.getIsCourse())){ + qw.eq("is_Course", query.getIsCourse()); + } + + + if (ObjectUtil.isNotEmpty(query.getOutProductId())){ + qw.eq("out_product_id", query.getOutProductId()); + } + + if (StringUtils.isNotEmpty(query.getBrandNameLike())){ + qw.like("brand_name", "%".concat(query.getBrandNameLike()).concat("%")); + } + + if (StringUtils.isNotEmpty(query.getProductCategoryNameLike())){ + qw.like("product_category_name", "%".concat(query.getProductCategoryNameLike()).concat("%")); + } + + qw.eq("store_id",SecurityUtils.getDeptId()); + + return productMapper.selectList(qw); + } + + public void getIds(ProductQuery query){ + + if (ObjectUtil.isNotEmpty(query.getBrandNameLike())){ + + List brands= brandMapper.selectList(new QueryWrapper() + .eq("store_id",SecurityUtils.getDeptId()) + .like("name","%".concat(query.getBrandNameLike()).concat("%"))); + if (brands.size()>0){ + List brandsIds = brands.stream() + .map(it -> it.getId()).collect(Collectors.toList()); + query.setBrandIds(brandsIds); + } + + } + if (ObjectUtil.isNotEmpty(query.getProductCategoryNameLike())){ + + List categories= productCategoryMapper.selectList(new QueryWrapper() + .eq("store_id",SecurityUtils.getDeptId()) + .like("type_name","%".concat(query.getProductCategoryNameLike()).concat("%"))); + if (categories.size()>0){ + List ids = categories.stream() + .map(it -> it.getId()).collect(Collectors.toList()); + query.setCategoryIds(ids); + } + + } + + + } + /** + * 新增商品信息 + * + * @param productVO 商品信息 + * @return 结果 + */ + @Transactional + public int insert(ProductVO productVO) { + + Product product = BeanUtil.toBean(productVO,Product.class); + product.setCreateTime(LocalDateTime.now()); + List skuList = productVO.getSkuList(); + productMapper.insert(product); + if(skuList!=null){ + skuList.forEach(sku -> { + sku.setProductId(product.getId()); + sku.setCreateTime(LocalDateTime.now()); + skuMapper.insert(sku); + }); + } + return 1; + } + + /** + * 修改商品信息 + * + * @param productVO 商品信息 + * @return 结果 + */ + @Transactional + public int update(ProductVO productVO) { + Product dbProduct = productMapper.selectById(productVO.getId()); + List idList = productVO.getSkuList().stream().filter(it -> it.getId() != null).map(it -> it.getId()).collect(Collectors.toList()); + if (dbProduct == null) { + return 0; + } + Long userId = SecurityUtils.getUserId(); + Product product = BeanUtil.toBean(productVO,Product.class); + List skuList = productVO.getSkuList(); + product.setUpdateBy(userId); + product.setUpdateTime(LocalDateTime.now()); + productMapper.updateById(product); + //查找库中所有的sku + Map map = new HashMap<>(); + map.put("product_id", product.getId()); + Map skuMap = skuMapper.selectByMap(map).stream().collect(Collectors.toMap(it -> it.getId(), it -> it)); + //针对已有的进行编辑 + List updateList = productVO.getSkuList().stream().filter(it -> it.getId() != null).collect(Collectors.toList()); + if (!CollectionUtil.isEmpty(updateList)) { + log.info("共有{}个sku需要修改,{},productId:{}",updateList.size(), JSONUtil.toJsonStr(updateList),productVO.getId()); + updateList.forEach(it->{ + Sku sku = skuMap.get(it.getId()); + sku.setUpdateBy(SecurityUtils.getUserId()); + sku.setUpdateTime(LocalDateTime.now()); + sku.setPrice(it.getPrice()); + sku.setSpData(it.getSpData()); + sku.setPic(it.getPic()); + sku.setOutSkuId(it.getOutSkuId()); + sku.setStock(it.getStock()); + skuMapper.updateById(sku); + }); + } + //针对没有的进行新增 + List addList = productVO.getSkuList().stream().filter(it -> it.getId() == null).collect(Collectors.toList()); + if (!CollectionUtil.isEmpty(addList)) { + log.info("共有{}个sku需要新增,{},productId:{}",addList.size(), JSONUtil.toJsonStr(addList),productVO.getId()); + addList.forEach(sku -> { + sku.setProductId(product.getId()); + sku.setCreateTime(LocalDateTime.now()); + skuMapper.insert(sku); + }); + } + //删除 + List deleteIds = skuMap.keySet().stream().filter(it -> !idList.contains(it)).collect(Collectors.toList()); + if (!CollectionUtil.isEmpty(deleteIds)) { + log.info("共有{}个sku需要删除,{},productId:{}",deleteIds.size(), JSONUtil.toJsonStr(deleteIds),productVO.getId()); + skuMapper.deleteBatchIds(deleteIds); + } + return 1; + } + + /** + * 删除商品信息信息 + * + * @param id 商品信息主键 + * @return 结果 + */ + public int deleteById(Long id) { + return productMapper.deleteById(id); + } + + public ProductDetailVO queryDetail(Long id) { + ProductDetailVO res = new ProductDetailVO(); + Product d = productMapper.selectById(id); + res.setProduct(d); + LambdaQueryWrapper qw = new LambdaQueryWrapper<>(); + qw.eq(Sku::getProductId, id); + res.setSkus(skuMapper.selectList(qw)); + if (d.getBrandId() != null) { + res.setBrand(brandMapper.selectById(d.getBrandId())); + } + return res; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java index 1f1fcf4..a3fe7fe 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java @@ -1,16 +1,17 @@ package com.ruoyi.system.domain; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel.ColumnType; import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; /** * 岗位表 sys_post - * + * * @author ruoyi */ public class SysPost extends BaseEntity @@ -36,6 +37,15 @@ public class SysPost extends BaseEntity /** 状态(0正常 1停用) */ @Excel(name = "状态", readConverterExp = "0=正常,1=停用") private String status; + private String tenantId; + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } /** 用户是否存在此岗位标识 默认不存在 */ private boolean flag = false; @@ -104,7 +114,7 @@ public class SysPost extends BaseEntity { this.flag = flag; } - + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java index 415599c..6f1761f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java @@ -1,19 +1,20 @@ package com.ruoyi.system.mapper; -import java.util.List; -import org.apache.ibatis.annotations.Param; import com.ruoyi.common.core.domain.entity.SysDept; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 部门管理 数据层 - * + * * @author ruoyi */ public interface SysDeptMapper { /** * 查询部门管理数据 - * + * * @param dept 部门信息 * @return 部门信息集合 */ @@ -21,16 +22,18 @@ public interface SysDeptMapper /** * 根据角色ID查询部门树信息 - * + * * @param roleId 角色ID * @param deptCheckStrictly 部门树选择项是否关联显示 * @return 选中部门列表 */ - public List selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly); + public List selectDeptListByRoleId(@Param("roleId") Long roleId + , @Param("deptCheckStrictly") boolean deptCheckStrictly + , @Param("tenantId") String tenantId); /** * 根据部门ID查询信息 - * + * * @param deptId 部门ID * @return 部门信息 */ @@ -38,7 +41,7 @@ public interface SysDeptMapper /** * 根据ID查询所有子部门 - * + * * @param deptId 部门ID * @return 部门列表 */ @@ -46,7 +49,7 @@ public interface SysDeptMapper /** * 根据ID查询所有子部门(正常状态) - * + * * @param deptId 部门ID * @return 子部门数 */ @@ -54,7 +57,7 @@ public interface SysDeptMapper /** * 是否存在子节点 - * + * * @param deptId 部门ID * @return 结果 */ @@ -62,7 +65,7 @@ public interface SysDeptMapper /** * 查询部门是否存在用户 - * + * * @param deptId 部门ID * @return 结果 */ @@ -70,7 +73,7 @@ public interface SysDeptMapper /** * 校验部门名称是否唯一 - * + * * @param deptName 部门名称 * @param parentId 父部门ID * @return 结果 @@ -79,7 +82,7 @@ public interface SysDeptMapper /** * 新增部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @@ -87,7 +90,7 @@ public interface SysDeptMapper /** * 修改部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @@ -95,14 +98,14 @@ public interface SysDeptMapper /** * 修改所在部门正常状态 - * + * * @param deptIds 部门ID组 */ public void updateDeptStatusNormal(Long[] deptIds); /** * 修改子元素关系 - * + * * @param depts 子元素 * @return 结果 */ @@ -110,7 +113,7 @@ public interface SysDeptMapper /** * 删除部门管理信息 - * + * * @param deptId 部门ID * @return 结果 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java index b428747..a428919 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java @@ -1,18 +1,20 @@ package com.ruoyi.system.mapper; -import java.util.List; import com.ruoyi.system.domain.SysPost; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 岗位信息 数据层 - * + * * @author ruoyi */ public interface SysPostMapper { /** * 查询岗位数据集合 - * + * * @param post 岗位信息 * @return 岗位数据集合 */ @@ -20,14 +22,14 @@ public interface SysPostMapper /** * 查询所有岗位 - * + * * @return 岗位列表 */ - public List selectPostAll(); + public List selectPostAll(String tenantId); /** * 通过岗位ID查询岗位信息 - * + * * @param postId 岗位ID * @return 角色对象信息 */ @@ -35,15 +37,15 @@ public interface SysPostMapper /** * 根据用户ID获取岗位选择框列表 - * + * * @param userId 用户ID * @return 选中岗位ID列表 */ - public List selectPostListByUserId(Long userId); + public List selectPostListByUserId(@Param("userId") Long userId,@Param("tenantId") String tenantId); /** * 查询用户所属岗位组 - * + * * @param userName 用户名 * @return 结果 */ @@ -51,7 +53,7 @@ public interface SysPostMapper /** * 删除岗位信息 - * + * * @param postId 岗位ID * @return 结果 */ @@ -59,7 +61,7 @@ public interface SysPostMapper /** * 批量删除岗位信息 - * + * * @param postIds 需要删除的岗位ID * @return 结果 */ @@ -67,7 +69,7 @@ public interface SysPostMapper /** * 修改岗位信息 - * + * * @param post 岗位信息 * @return 结果 */ @@ -75,7 +77,7 @@ public interface SysPostMapper /** * 新增岗位信息 - * + * * @param post 岗位信息 * @return 结果 */ @@ -83,7 +85,7 @@ public interface SysPostMapper /** * 校验岗位名称 - * + * * @param postName 岗位名称 * @return 结果 */ @@ -91,7 +93,7 @@ public interface SysPostMapper /** * 校验岗位编码 - * + * * @param postCode 岗位编码 * @return 结果 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java index 11647ab..e039753 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java @@ -1,19 +1,21 @@ package com.ruoyi.system.mapper; -import java.util.List; import com.ruoyi.common.core.domain.entity.SysRole; +import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; +import java.util.List; + /** * 角色表 数据层 - * + * * @author ruoyi */ public interface SysRoleMapper { /** * 根据条件分页查询角色数据 - * + * * @param role 角色信息 * @return 角色数据集合信息 */ @@ -21,7 +23,7 @@ public interface SysRoleMapper /** * 根据用户ID查询角色 - * + * * @param userId 用户ID * @return 角色列表 */ @@ -29,22 +31,22 @@ public interface SysRoleMapper /** * 查询所有角色 - * + * * @return 角色列表 */ public List selectRoleAll(); /** * 根据用户ID获取角色选择框列表 - * + * * @param userId 用户ID * @return 选中角色ID列表 */ - public List selectRoleListByUserId(Long userId); + public List selectRoleListByUserId(@Param("userId") Long userId,@Param("tenantId")String tenantId); /** * 通过角色ID查询角色 - * + * * @param roleId 角色ID * @return 角色对象信息 */ @@ -52,7 +54,7 @@ public interface SysRoleMapper /** * 根据用户ID查询角色 - * + * * @param userName 用户名 * @return 角色列表 */ @@ -60,7 +62,7 @@ public interface SysRoleMapper /** * 校验角色名称是否唯一 - * + * * @param roleName 角色名称 * @return 角色信息 */ @@ -68,7 +70,7 @@ public interface SysRoleMapper /** * 校验角色权限是否唯一 - * + * * @param roleKey 角色权限 * @return 角色信息 */ @@ -76,7 +78,7 @@ public interface SysRoleMapper /** * 修改角色信息 - * + * * @param role 角色信息 * @return 结果 */ @@ -84,7 +86,7 @@ public interface SysRoleMapper /** * 新增角色信息 - * + * * @param role 角色信息 * @return 结果 */ @@ -92,7 +94,7 @@ public interface SysRoleMapper /** * 通过角色ID删除角色 - * + * * @param roleId 角色ID * @return 结果 */ @@ -100,7 +102,7 @@ public interface SysRoleMapper /** * 批量删除角色信息 - * + * * @param roleIds 需要删除的角色ID * @return 结果 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 46f75a3..11018f7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -1,11 +1,5 @@ package com.ruoyi.system.service.impl; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.stream.Collectors; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.TreeSelect; @@ -20,10 +14,17 @@ import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.system.mapper.SysDeptMapper; import com.ruoyi.system.mapper.SysRoleMapper; import com.ruoyi.system.service.ISysDeptService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; /** * 部门管理 服务实现 - * + * * @author ruoyi */ @Service @@ -37,7 +38,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 查询部门管理数据 - * + * * @param dept 部门信息 * @return 部门信息集合 */ @@ -45,12 +46,13 @@ public class SysDeptServiceImpl implements ISysDeptService @DataScope(deptAlias = "d") public List selectDeptList(SysDept dept) { + dept.setTenantId(SecurityUtils.getLoginUser().getNowTenantId()); return deptMapper.selectDeptList(dept); } /** * 构建前端所需要树结构 - * + * * @param depts 部门列表 * @return 树结构列表 */ @@ -82,7 +84,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 构建前端所需要下拉树结构 - * + * * @param depts 部门列表 * @return 下拉树结构列表 */ @@ -95,7 +97,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 根据角色ID查询部门树信息 - * + * * @param roleId 角色ID * @return 选中部门列表 */ @@ -103,12 +105,12 @@ public class SysDeptServiceImpl implements ISysDeptService public List selectDeptListByRoleId(Long roleId) { SysRole role = roleMapper.selectRoleById(roleId); - return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); + return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly(),SecurityUtils.getLoginUser().getNowTenantId()); } /** * 根据部门ID查询信息 - * + * * @param deptId 部门ID * @return 部门信息 */ @@ -120,7 +122,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 根据ID查询所有子部门(正常状态) - * + * * @param deptId 部门ID * @return 子部门数 */ @@ -132,7 +134,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 是否存在子节点 - * + * * @param deptId 部门ID * @return 结果 */ @@ -145,7 +147,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 查询部门是否存在用户 - * + * * @param deptId 部门ID * @return 结果 true 存在 false 不存在 */ @@ -158,7 +160,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 校验部门名称是否唯一 - * + * * @param dept 部门信息 * @return 结果 */ @@ -176,7 +178,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 校验部门是否有数据权限 - * + * * @param deptId 部门id */ @Override @@ -196,7 +198,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 新增保存部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @@ -210,12 +212,13 @@ public class SysDeptServiceImpl implements ISysDeptService throw new ServiceException("部门停用,不允许新增"); } dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); + dept.setTenantId(SecurityUtils.getLoginUser().getNowTenantId()); return deptMapper.insertDept(dept); } /** * 修改保存部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @@ -243,7 +246,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 修改该部门的父级部门状态 - * + * * @param dept 当前部门 */ private void updateParentDeptStatusNormal(SysDept dept) @@ -255,7 +258,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 修改子元素关系 - * + * * @param deptId 被修改的部门ID * @param newAncestors 新的父ID集合 * @param oldAncestors 旧的父ID集合 @@ -275,7 +278,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 删除部门管理信息 - * + * * @param deptId 部门ID * @return 结果 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java index 46805ef..ef63fbe 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java @@ -1,19 +1,21 @@ package com.ruoyi.system.service.impl; -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.mapper.SysPostMapper; import com.ruoyi.system.mapper.SysUserPostMapper; import com.ruoyi.system.service.ISysPostService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; /** * 岗位信息 服务层处理 - * + * * @author ruoyi */ @Service @@ -27,30 +29,31 @@ public class SysPostServiceImpl implements ISysPostService /** * 查询岗位信息集合 - * + * * @param post 岗位信息 * @return 岗位信息集合 */ @Override public List selectPostList(SysPost post) { + post.setTenantId(SecurityUtils.getLoginUser().getNowTenantId()); return postMapper.selectPostList(post); } /** * 查询所有岗位 - * + * * @return 岗位列表 */ @Override public List selectPostAll() { - return postMapper.selectPostAll(); + return postMapper.selectPostAll(SecurityUtils.getLoginUser().getNowTenantId()); } /** * 通过岗位ID查询岗位信息 - * + * * @param postId 岗位ID * @return 角色对象信息 */ @@ -62,19 +65,20 @@ public class SysPostServiceImpl implements ISysPostService /** * 根据用户ID获取岗位选择框列表 - * + * * @param userId 用户ID * @return 选中岗位ID列表 */ @Override public List selectPostListByUserId(Long userId) { - return postMapper.selectPostListByUserId(userId); + + return postMapper.selectPostListByUserId(userId,SecurityUtils.getLoginUser().getNowTenantId()); } /** * 校验岗位名称是否唯一 - * + * * @param post 岗位信息 * @return 结果 */ @@ -92,7 +96,7 @@ public class SysPostServiceImpl implements ISysPostService /** * 校验岗位编码是否唯一 - * + * * @param post 岗位信息 * @return 结果 */ @@ -110,7 +114,7 @@ public class SysPostServiceImpl implements ISysPostService /** * 通过岗位ID查询岗位使用数量 - * + * * @param postId 岗位ID * @return 结果 */ @@ -122,7 +126,7 @@ public class SysPostServiceImpl implements ISysPostService /** * 删除岗位信息 - * + * * @param postId 岗位ID * @return 结果 */ @@ -134,7 +138,7 @@ public class SysPostServiceImpl implements ISysPostService /** * 批量删除岗位信息 - * + * * @param postIds 需要删除的岗位ID * @return 结果 * @throws Exception 异常 @@ -155,19 +159,20 @@ public class SysPostServiceImpl implements ISysPostService /** * 新增保存岗位信息 - * + * * @param post 岗位信息 * @return 结果 */ @Override public int insertPost(SysPost post) { + post.setTenantId(SecurityUtils.getLoginUser().getNowTenantId()); return postMapper.insertPost(post); } /** * 修改保存岗位信息 - * + * * @param post 岗位信息 * @return 结果 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 7293b65..21a5e3a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -122,7 +122,7 @@ public class SysRoleServiceImpl implements ISysRoleService @Override public List selectRoleListByUserId(Long userId) { - return roleMapper.selectRoleListByUserId(userId); + return roleMapper.selectRoleListByUserId(userId,SecurityUtils.getLoginUser().getNowTenantId()); } /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTenantServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTenantServiceImpl.java index 67ee761..50b0779 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTenantServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTenantServiceImpl.java @@ -6,13 +6,16 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.RestResponse; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.page.RespPage; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.system.domain.SysTenant; +import com.ruoyi.system.domain.SysUserRole; import com.ruoyi.system.domain.vo.ReqBusinessAddTenant; import com.ruoyi.system.domain.vo.ReqSearchSysTenant; +import com.ruoyi.system.mapper.SysDeptMapper; import com.ruoyi.system.mapper.SysTenantMapper; import com.ruoyi.system.mapper.SysUserRoleMapper; import com.ruoyi.system.service.ISysUserService; @@ -23,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; @@ -35,6 +39,8 @@ public class SysTenantServiceImpl extends ServiceImpl selectUserTenantList(String userId, String limitTenantUserId) { return baseMapper.selectUserTenantList(userId, limitTenantUserId); @@ -129,7 +135,7 @@ public class SysTenantServiceImpl extends ServiceImpl list=new ArrayList<>(); + list.add(userRole); + userRoleMapper.batchUserRole(list); + + // + +// } catch (Exception e) { +// e.printStackTrace(); +// } return RestResponse.success(); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 2100115..68ec149 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -61,6 +61,10 @@ public class SysUserServiceImpl implements ISysUserService @DataScope(deptAlias = "d", userAlias = "u") public List selectUserList(SysUser user) { + if (! SecurityUtils.isAdmin(SecurityUtils.getUserId())){ + user.setTenantId(SecurityUtils.getLoginUser().getNowTenantId()); + } + return userMapper.selectUserList(user); } @@ -440,6 +444,7 @@ public class SysUserServiceImpl implements ISysUserService List list = new ArrayList(); for (Long roleId : roleIds) { + SysUserRole ur = new SysUserRole(); ur.setUserId(userId); ur.setRoleId(roleId); @@ -563,4 +568,5 @@ public class SysUserServiceImpl implements ISysUserService } + } diff --git a/ruoyi-system/src/main/resources/mapper/mall/BrandMapper.xml b/ruoyi-system/src/main/resources/mapper/mall/BrandMapper.xml new file mode 100644 index 0000000..c20724b --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/mall/BrandMapper.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + select id, name, sort, show_status, logo, create_by, create_time, update_by, update_time from pms_brand + + + + diff --git a/ruoyi-system/src/main/resources/mapper/mall/ProductCategoryMapper.xml b/ruoyi-system/src/main/resources/mapper/mall/ProductCategoryMapper.xml new file mode 100644 index 0000000..0669b51 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/mall/ProductCategoryMapper.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + select id, parent_id, name, level, show_status, sort, icon, create_by, create_time, update_by, update_time from pms_product_category + + + + diff --git a/ruoyi-system/src/main/resources/mapper/mall/ProductMapper.xml b/ruoyi-system/src/main/resources/mapper/mall/ProductMapper.xml new file mode 100644 index 0000000..b870f93 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/mall/ProductMapper.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, brand_id, category_id, out_product_id, name, pic, album_pics, publish_status, sort, price, unit, weight, detail_html, detail_mobile_html, brand_name, product_category_name, create_by, create_time, update_by, update_time from pms_product + + + + diff --git a/ruoyi-system/src/main/resources/mapper/mall/SkuMapper.xml b/ruoyi-system/src/main/resources/mapper/mall/SkuMapper.xml new file mode 100644 index 0000000..d9a956d --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/mall/SkuMapper.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + select id, product_id, out_sku_id, price, pic, sp_data, create_by, create_time, update_by, update_time from pms_sku + + + update + pms_sku + set + stock = stock - #{quantity}, + update_time = #{optDate} + where id = #{skuId} + + + + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index c2304b2..96d1b20 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -20,10 +20,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + - select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.delete_flag, d.create_by, d.create_time + select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.delete_flag, d.create_by + , d.create_time,d.leader_id,d.dept_type,d.tenant_id + from sys_dept d @@ -42,6 +47,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND status = #{status} + + AND tenant_id = #{tenantId} + ${params.dataScope} order by d.parent_id, d.order_num @@ -52,9 +60,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from sys_dept d left join sys_role_dept rd on d.dept_id = rd.dept_id where rd.role_id = #{roleId} + AND tenant_id = #{tenantId} and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId}) + order by d.parent_id, d.order_num @@ -85,7 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where dept_name=#{deptName} and parent_id = #{parentId} limit 1 - + insert into sys_dept( dept_id, parent_id, @@ -95,6 +105,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" leader, phone, email, + tenant_id, + dept_type, status, create_by, create_time @@ -107,6 +119,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{leader}, #{phone}, #{email}, + #{tenantId}, + #{deptType}, #{status}, #{createBy}, sysdate() @@ -121,8 +135,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ancestors = #{ancestors}, order_num = #{orderNum}, leader = #{leader}, + leader_id = #{leaderId}, phone = #{phone}, email = #{email}, + tenant_id =#{tenantId}, + dept_type =#{deptType}, status = #{status}, update_by = #{updateBy}, update_time = sysdate() diff --git a/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml index dd89e8d..f1f7326 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml @@ -16,15 +16,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + - select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark + select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark from sys_post - + - + - + - - select p.post_id from sys_post p left join sys_user_post up on up.post_id = p.post_id left join sys_user u on u.user_id = up.user_id - where u.user_id = #{userId} + where u.user_id = #{userId} and p.tenant_id=#{tenantId} - + - + - + - + update sys_post @@ -85,7 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where post_id = #{postId} - + insert into sys_post( post_id, @@ -95,6 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" status, remark, create_by, + tenant_id, create_time )values( #{postId}, @@ -104,19 +111,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{status}, #{remark}, #{createBy}, + #{tenantId}, sysdate() ) - + delete from sys_post where post_id = #{postId} - + delete from sys_post where post_id in #{postId} - + - + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml index e3f36f9..bb82759 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -66,12 +66,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select r.role_id from sys_role r left join sys_user_role ur on ur.role_id = r.role_id left join sys_user u on u.user_id = ur.user_id - where u.user_id = #{userId} + where u.user_id = #{userId} and r.tenant_id in (#{tenantId},"1") - select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u + select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.delete_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader + from sys_user u left join sys_dept d on u.dept_id = d.dept_id - where u.del_flag = '0' + where u.delete_flag = '0' AND u.user_id = #{userId} @@ -69,6 +70,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND u.status = #{status} + + AND u.tenant_id = #{tenantId} + AND u.phonenumber like concat('%', #{phonenumber}, '%') @@ -91,7 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join sys_dept d on u.dept_id = d.dept_id left join sys_user_role ur on u.user_id = ur.user_id left join sys_role r on r.role_id = ur.role_id - where u.del_flag = '0' and r.role_id = #{roleId} + where u.delete_flag = '0' and r.role_id = #{roleId} AND u.user_name like concat('%', #{userName}, '%') @@ -108,7 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join sys_dept d on u.dept_id = d.dept_id left join sys_user_role ur on u.user_id = ur.user_id left join sys_role r on r.role_id = ur.role_id - where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL) + where u.delete_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL) and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId}) AND u.user_name like concat('%', #{userName}, '%') @@ -146,6 +150,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into sys_user( user_id, dept_id, + tenant_id, user_name, nick_name, email, @@ -156,10 +161,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" status, create_by, remark, + teacher, create_time )values( #{userId}, #{deptId}, + #{tenantId}, #{userName}, #{nickName}, #{email}, @@ -170,6 +177,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{status}, #{createBy}, #{remark}, + #{teacher}, sysdate() ) @@ -190,6 +198,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" login_date = #{loginDate}, update_by = #{updateBy}, remark = #{remark}, + teacher = #{teacher}, update_time = sysdate() where user_id = #{userId} @@ -208,11 +217,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update sys_user set del_flag = '2' where user_id = #{userId} + update sys_user set delelete_flag = '2' where user_id = #{userId} - update sys_user set del_flag = '2' where user_id in + update sys_user set delete_flag = '2' where user_id in #{userId}