商品管理

master
xiaoning 20 hours ago
parent d17f9a619d
commit 398a5396b7

@ -38,7 +38,7 @@ public class CommonController
@Operation(summary = "上传商城相关图片", description = "上传图片,上传后返回原图和缩略图的url") @Operation(summary = "上传商城相关图片", description = "上传图片,上传后返回原图和缩略图的url")
@PostMapping("/productImage/upload") @PostMapping("/productImage/upload")
public RestResponse uploadProductImage(@RequestParam("file") MultipartFile file) { 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") @Operation(summary = "上传文件", description = "上传文件上传后返回文件url")

@ -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<Page<Brand>> list(@RequestBody BrandQuery query, Pageable page) {
List<Brand> 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<List<Brand>> 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<String> export(BrandQuery query) {
// List<Brand> list = service.selectList(query, null);
// ExcelUtil<BrandVO> 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<Brand> 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<Integer> 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<Integer> 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<Integer> remove(@PathVariable Long id) {
return ResponseEntity.ok(service.deleteById(id));
}
}

@ -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<ProductCategoryVO>> list(@RequestBody ProductCategoryQuery query) {
List<ProductCategoryVO> list = service.selectList(query, null);
return ResponseEntity.ok(list);
}
@ApiOperation("获取商品分类详细信息")
@PreAuthorize("@ss.hasPermi('pms:productCategory:query')")
@GetMapping(value = "/{id}")
public ResponseEntity<ProductCategory> 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<Integer> 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<Integer> 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<Integer> remove(@PathVariable Long id) {
return ResponseEntity.ok(service.deleteById(id));
}
}

@ -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<Page<Product>> list(@RequestBody ProductQuery query, Pageable page) {
// service.getIds(query);
List<Product> 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<String> export(ProductQuery query) {
// List<Product> list = service.selectList(query, null);
// ExcelUtil<ProductVO> 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<ProductVO> 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<Integer> 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<Integer> 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<Integer> remove(@PathVariable Long id) {
return ResponseEntity.ok(service.deleteById(id));
}
@PostMapping("/courseList")
public ResponseEntity<RespPage<RespSearchCourse>> listCourseForProduct(@RequestBody ReqSearchScCourse query){
return ResponseEntity.ok(courseService.searchCourse(query));
}
}

@ -1,17 +1,5 @@
package com.ruoyi.web.controller.system; 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.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -28,6 +16,12 @@ import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.SysUserRole; import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService; 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;
/** /**
* *
@ -97,6 +91,7 @@ public class SysRoleController extends BaseController
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
} }
role.setCreateBy(getUserId()); role.setCreateBy(getUserId());
role.setTenantId(getLoginUser().getNowTenantId());
return toAjax(roleService.insertRole(role)); return toAjax(roleService.insertRole(role));
} }

@ -1,20 +1,5 @@
package com.ruoyi.web.controller.system; 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.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -29,6 +14,15 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysPostService; import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService; 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;
/** /**
* *
@ -144,6 +138,7 @@ public class SysUserController extends BaseController
} }
user.setCreateBy(getUserId()); user.setCreateBy(getUserId());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
user.setTenantId(getLoginUser().getNowTenantId());
return toAjax(userService.insertUser(user)); return toAjax(userService.insertUser(user));
} }

@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.data.annotation.Id;
import javax.validation.constraints.Email; import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
@ -22,6 +23,7 @@ public class SysDept extends BaseEntity
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 部门ID */ /** 部门ID */
@Id
private Long deptId; private Long deptId;
/** 父部门ID */ /** 父部门ID */
@ -58,6 +60,8 @@ public class SysDept extends BaseEntity
// //
private String tenantId; private String tenantId;
private String deptType;
/** 子部门 */ /** 子部门 */
private List<SysDept> children = new ArrayList<SysDept>(); private List<SysDept> children = new ArrayList<SysDept>();

@ -1,12 +1,13 @@
package com.ruoyi.common.core.domain.entity; package com.ruoyi.common.core.domain.entity;
import java.util.ArrayList; import com.ruoyi.common.core.domain.BaseEntity;
import java.util.List;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; 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 * sys_menu
@ -62,6 +63,8 @@ public class SysMenu extends BaseEntity
/** 菜单图标 */ /** 菜单图标 */
private String icon; private String icon;
/** 子菜单 */ /** 子菜单 */
private List<SysMenu> children = new ArrayList<SysMenu>(); private List<SysMenu> children = new ArrayList<SysMenu>();

@ -67,7 +67,7 @@ public class SysUser extends BaseEntity
private String status; private String status;
/** 删除标志0代表存在 2代表删除 */ /** 删除标志0代表存在 2代表删除 */
private String delFlag; private String deleteFlag;
/** 最后登录IP */ /** 最后登录IP */
@Excel(name = "最后登录IP", type = Type.EXPORT) @Excel(name = "最后登录IP", type = Type.EXPORT)
@ -84,6 +84,8 @@ public class SysUser extends BaseEntity
}) })
private SysDept dept; private SysDept dept;
private int teacher;//是否为任课教师 1是 0否
/** 角色对象 */ /** 角色对象 */
private List<SysRole> roles; private List<SysRole> roles;
@ -108,6 +110,14 @@ public class SysUser extends BaseEntity
this.userId = userId; this.userId = userId;
} }
public int getTeacher() {
return teacher;
}
public void setTeacher(int teacher) {
this.teacher = teacher;
}
public String getTenantId() { public String getTenantId() {
return tenantId; return tenantId;
} }
@ -244,14 +254,14 @@ public class SysUser extends BaseEntity
this.status = status; 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() public String getLoginIp()
@ -338,7 +348,7 @@ public class SysUser extends BaseEntity
.append("password", getPassword()) .append("password", getPassword())
.append("salt", getSalt()) .append("salt", getSalt())
.append("status", getStatus()) .append("status", getStatus())
.append("delFlag", getDelFlag()) .append("delFlag", getDeleteFlag())
.append("loginIp", getLoginIp()) .append("loginIp", getLoginIp())
.append("loginDate", getLoginDate()) .append("loginDate", getLoginDate())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())

@ -39,7 +39,7 @@ public class UserDetailsServiceImpl implements UserDetailsService
log.info("登录用户:{} 不存在.", username); log.info("登录用户:{} 不存在.", username);
throw new ServiceException("登录用户:" + username + " 不存在"); throw new ServiceException("登录用户:" + username + " 不存在");
} }
else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) else if (UserStatus.DELETED.getCode().equals(user.getDeleteFlag()))
{ {
log.info("登录用户:{} 已被删除.", username); log.info("登录用户:{} 已被删除.", username);
throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); throw new ServiceException("对不起,您的账号:" + username + " 已被删除");

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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<Long> excludeProductIds;
private List<Long> ids;
private List<Long> brandIds;
private List<Long> CategoryIds;
}

@ -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;
}

@ -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;
}

@ -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<ProductCategoryVO> children;
}

@ -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<Sku> skus;
private Brand brand;
}

@ -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<Sku> skuList;
}

@ -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;
}

@ -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<Brand> {
/**
*
*
* @param brand
* @return
*/
List<Brand> selectByEntity(Brand brand);
}

@ -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<ProductCategory> {
/**
*
*
* @param productCategory
* @return
*/
List<ProductCategory> selectByEntity(ProductCategory productCategory);
}

@ -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<Product> {
/**
*
*
* @param product
* @return
*/
List<Product> selectByEntity(Product product);
}

@ -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;
/**
* skuMapper
*
* @author zcc
*/
public interface SkuMapper extends BaseMapper<Sku> {
/**
* sku
*
* @param sku sku
* @return sku
*/
List<Sku> selectByEntity(Sku sku);
int updateStockById(@Param("skuId")Long skuId, @Param("optDate")LocalDateTime optDate, @Param("quantity")Integer quantity);
}

@ -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<Brand> selectList(BrandQuery query, Pageable page) {
if (page != null) {
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
}
QueryWrapper<Brand> 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);
}
}

@ -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<ProductCategoryVO> selectList(ProductCategoryQuery query, Pageable page) {
if (page != null) {
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
}
QueryWrapper<ProductCategory> 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<ProductCategory> productCategories = productCategoryMapper.selectList(qw);
List<ProductCategoryVO> productCategoryVOS = BeanUtil.copyToList(productCategories,ProductCategoryVO.class);
return formatTree(productCategoryVOS);
}
private List<ProductCategoryVO> formatTree(List<ProductCategoryVO> nodes) {
List<ProductCategoryVO> tree = new ArrayList<>();
List<ProductCategoryVO> 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<ProductCategoryVO> 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);
}
}

@ -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<Sku> qw = new QueryWrapper<>();
qw.eq("product_id", product.getId());
List<Sku> skus = skuMapper.selectList(qw);
productVO.setSkuList(skus);
return productVO;
}
/**
*
*
* @param query
* @param page
* @return
*/
public List<Product> selectList(ProductQuery query, Pageable page) {
if (page != null) {
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
}
QueryWrapper<Product> 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<Brand> brands= brandMapper.selectList(new QueryWrapper<Brand>()
.eq("store_id",SecurityUtils.getDeptId())
.like("name","%".concat(query.getBrandNameLike()).concat("%")));
if (brands.size()>0){
List<Long> brandsIds = brands.stream()
.map(it -> it.getId()).collect(Collectors.toList());
query.setBrandIds(brandsIds);
}
}
if (ObjectUtil.isNotEmpty(query.getProductCategoryNameLike())){
List<ProductCategory> categories= productCategoryMapper.selectList(new QueryWrapper<ProductCategory>()
.eq("store_id",SecurityUtils.getDeptId())
.like("type_name","%".concat(query.getProductCategoryNameLike()).concat("%")));
if (categories.size()>0){
List<Long> 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<Sku> 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<Long> 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<Sku> skuList = productVO.getSkuList();
product.setUpdateBy(userId);
product.setUpdateTime(LocalDateTime.now());
productMapper.updateById(product);
//查找库中所有的sku
Map<String,Object> map = new HashMap<>();
map.put("product_id", product.getId());
Map<Long, Sku> skuMap = skuMapper.selectByMap(map).stream().collect(Collectors.toMap(it -> it.getId(), it -> it));
//针对已有的进行编辑
List<Sku> 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<Sku> 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<Long> 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<Sku> 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;
}
}

@ -1,12 +1,13 @@
package com.ruoyi.system.domain; 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;
import com.ruoyi.common.annotation.Excel.ColumnType; import com.ruoyi.common.annotation.Excel.ColumnType;
import com.ruoyi.common.core.domain.BaseEntity; 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 * sys_post
@ -36,6 +37,15 @@ public class SysPost extends BaseEntity
/** 状态0正常 1停用 */ /** 状态0正常 1停用 */
@Excel(name = "状态", readConverterExp = "0=正常,1=停用") @Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private String status; private String status;
private String tenantId;
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
/** 用户是否存在此岗位标识 默认不存在 */ /** 用户是否存在此岗位标识 默认不存在 */
private boolean flag = false; private boolean flag = false;

@ -1,8 +1,9 @@
package com.ruoyi.system.mapper; package com.ruoyi.system.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysDept;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* *
@ -26,7 +27,9 @@ public interface SysDeptMapper
* @param deptCheckStrictly * @param deptCheckStrictly
* @return * @return
*/ */
public List<Integer> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly); public List<Integer> selectDeptListByRoleId(@Param("roleId") Long roleId
, @Param("deptCheckStrictly") boolean deptCheckStrictly
, @Param("tenantId") String tenantId);
/** /**
* ID * ID

@ -1,7 +1,9 @@
package com.ruoyi.system.mapper; package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.domain.SysPost;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* *
@ -23,7 +25,7 @@ public interface SysPostMapper
* *
* @return * @return
*/ */
public List<SysPost> selectPostAll(); public List<SysPost> selectPostAll(String tenantId);
/** /**
* ID * ID
@ -39,7 +41,7 @@ public interface SysPostMapper
* @param userId ID * @param userId ID
* @return ID * @return ID
*/ */
public List<Integer> selectPostListByUserId(Long userId); public List<Integer> selectPostListByUserId(@Param("userId") Long userId,@Param("tenantId") String tenantId);
/** /**
* *

@ -1,9 +1,11 @@
package com.ruoyi.system.mapper; package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysRole;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import java.util.List;
/** /**
* *
* *
@ -40,7 +42,7 @@ public interface SysRoleMapper
* @param userId ID * @param userId ID
* @return ID * @return ID
*/ */
public List<Integer> selectRoleListByUserId(Long userId); public List<Integer> selectRoleListByUserId(@Param("userId") Long userId,@Param("tenantId")String tenantId);
/** /**
* ID * ID

@ -1,11 +1,5 @@
package com.ruoyi.system.service.impl; 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.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.TreeSelect; import com.ruoyi.common.core.domain.TreeSelect;
@ -20,6 +14,13 @@ import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.mapper.SysDeptMapper; import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper; import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.service.ISysDeptService; 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;
/** /**
* *
@ -45,6 +46,7 @@ public class SysDeptServiceImpl implements ISysDeptService
@DataScope(deptAlias = "d") @DataScope(deptAlias = "d")
public List<SysDept> selectDeptList(SysDept dept) public List<SysDept> selectDeptList(SysDept dept)
{ {
dept.setTenantId(SecurityUtils.getLoginUser().getNowTenantId());
return deptMapper.selectDeptList(dept); return deptMapper.selectDeptList(dept);
} }
@ -103,7 +105,7 @@ public class SysDeptServiceImpl implements ISysDeptService
public List<Integer> selectDeptListByRoleId(Long roleId) public List<Integer> selectDeptListByRoleId(Long roleId)
{ {
SysRole role = roleMapper.selectRoleById(roleId); SysRole role = roleMapper.selectRoleById(roleId);
return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly(),SecurityUtils.getLoginUser().getNowTenantId());
} }
/** /**
@ -210,6 +212,7 @@ public class SysDeptServiceImpl implements ISysDeptService
throw new ServiceException("部门停用,不允许新增"); throw new ServiceException("部门停用,不允许新增");
} }
dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
dept.setTenantId(SecurityUtils.getLoginUser().getNowTenantId());
return deptMapper.insertDept(dept); return deptMapper.insertDept(dept);
} }

@ -1,15 +1,17 @@
package com.ruoyi.system.service.impl; 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.constant.UserConstants;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.mapper.SysPostMapper; import com.ruoyi.system.mapper.SysPostMapper;
import com.ruoyi.system.mapper.SysUserPostMapper; import com.ruoyi.system.mapper.SysUserPostMapper;
import com.ruoyi.system.service.ISysPostService; import com.ruoyi.system.service.ISysPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* *
@ -34,6 +36,7 @@ public class SysPostServiceImpl implements ISysPostService
@Override @Override
public List<SysPost> selectPostList(SysPost post) public List<SysPost> selectPostList(SysPost post)
{ {
post.setTenantId(SecurityUtils.getLoginUser().getNowTenantId());
return postMapper.selectPostList(post); return postMapper.selectPostList(post);
} }
@ -45,7 +48,7 @@ public class SysPostServiceImpl implements ISysPostService
@Override @Override
public List<SysPost> selectPostAll() public List<SysPost> selectPostAll()
{ {
return postMapper.selectPostAll(); return postMapper.selectPostAll(SecurityUtils.getLoginUser().getNowTenantId());
} }
/** /**
@ -69,7 +72,8 @@ public class SysPostServiceImpl implements ISysPostService
@Override @Override
public List<Integer> selectPostListByUserId(Long userId) public List<Integer> selectPostListByUserId(Long userId)
{ {
return postMapper.selectPostListByUserId(userId);
return postMapper.selectPostListByUserId(userId,SecurityUtils.getLoginUser().getNowTenantId());
} }
/** /**
@ -162,6 +166,7 @@ public class SysPostServiceImpl implements ISysPostService
@Override @Override
public int insertPost(SysPost post) public int insertPost(SysPost post)
{ {
post.setTenantId(SecurityUtils.getLoginUser().getNowTenantId());
return postMapper.insertPost(post); return postMapper.insertPost(post);
} }

@ -122,7 +122,7 @@ public class SysRoleServiceImpl implements ISysRoleService
@Override @Override
public List<Integer> selectRoleListByUserId(Long userId) public List<Integer> selectRoleListByUserId(Long userId)
{ {
return roleMapper.selectRoleListByUserId(userId); return roleMapper.selectRoleListByUserId(userId,SecurityUtils.getLoginUser().getNowTenantId());
} }
/** /**

@ -6,13 +6,16 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.RestResponse; 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.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.page.RespPage; import com.ruoyi.common.page.RespPage;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.SysTenant; 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.ReqBusinessAddTenant;
import com.ruoyi.system.domain.vo.ReqSearchSysTenant; import com.ruoyi.system.domain.vo.ReqSearchSysTenant;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysTenantMapper; import com.ruoyi.system.mapper.SysTenantMapper;
import com.ruoyi.system.mapper.SysUserRoleMapper; import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.system.service.ISysUserService; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -35,6 +39,8 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
private ISysUserService userService; private ISysUserService userService;
@Autowired @Autowired
private SysUserRoleMapper userRoleMapper; private SysUserRoleMapper userRoleMapper;
@Autowired
private SysDeptMapper deptMapper;
@Override @Override
public List<SysTenant> selectUserTenantList(String userId, String limitTenantUserId) { public List<SysTenant> selectUserTenantList(String userId, String limitTenantUserId) {
return baseMapper.selectUserTenantList(userId, limitTenantUserId); return baseMapper.selectUserTenantList(userId, limitTenantUserId);
@ -129,7 +135,7 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
sysTenant.setEndTime(DateUtil.parse(DateUtil.format(sysTenant.getEndTime(),"yyyy-MM-dd 23:59:59")));//,"yyyy-MM-dd 23:59:59" sysTenant.setEndTime(DateUtil.parse(DateUtil.format(sysTenant.getEndTime(),"yyyy-MM-dd 23:59:59")));//,"yyyy-MM-dd 23:59:59"
this.save(sysTenant); this.save(sysTenant);
try { // try {
// TenantContextHolder.setTenant(sysTenant.getTenantId()); // TenantContextHolder.setTenant(sysTenant.getTenantId());
// 保存用户 // 保存用户
if (StringUtils.isAnyEmpty(reqBusinessAddTenant.getUsername(), reqBusinessAddTenant.getPassword())) { if (StringUtils.isAnyEmpty(reqBusinessAddTenant.getUsername(), reqBusinessAddTenant.getPassword())) {
@ -142,18 +148,38 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
if (!usernameUnique) { if (!usernameUnique) {
return RestResponse.failure(("用户名已被注册,请修改后重新提交")); return RestResponse.failure(("用户名已被注册,请修改后重新提交"));
} }
//部门
SysDept sysDept=new SysDept();
sysDept.setTenantId(sysTenant.getTenantId());
sysDept.setDeptName(sysTenant.getTenantName());
sysDept.setDeptType("2");
sysDept.setParentId(0l);
sysDept.setAncestors("0");
deptMapper.insertDept(sysDept);
SysUser sysUser = reqBusinessAddTenant.transferToSysUser(); SysUser sysUser = reqBusinessAddTenant.transferToSysUser();
sysUser.setTenantId(sysTenant.getTenantId()); sysUser.setTenantId(sysTenant.getTenantId());
sysUser.setCreateBy(loginUser.getUserId()); sysUser.setCreateBy(loginUser.getUserId());
sysUser.setPassword(SecurityUtils.encryptPassword(sysUser.getPassword())); sysUser.setPassword(SecurityUtils.encryptPassword(sysUser.getPassword()));
sysUser.setDeptId(sysDept.getDeptId());
userService.insertUser(sysUser); userService.insertUser(sysUser);
sysDept.setLeaderId(sysUser.getUserId());
deptMapper.updateDept(sysDept);
// 用户角色 // 用户角色
userRoleMapper.countRoleAndUserId(100l,loginUser.getUserId()); SysUserRole userRole=new SysUserRole();
} catch (Exception e) { userRole.setRoleId(100l);
e.printStackTrace(); userRole.setUserId(sysUser.getUserId());
} List<SysUserRole> list=new ArrayList<>();
list.add(userRole);
userRoleMapper.batchUserRole(list);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
return RestResponse.success(); return RestResponse.success();
} }

@ -61,6 +61,10 @@ public class SysUserServiceImpl implements ISysUserService
@DataScope(deptAlias = "d", userAlias = "u") @DataScope(deptAlias = "d", userAlias = "u")
public List<SysUser> selectUserList(SysUser user) public List<SysUser> selectUserList(SysUser user)
{ {
if (! SecurityUtils.isAdmin(SecurityUtils.getUserId())){
user.setTenantId(SecurityUtils.getLoginUser().getNowTenantId());
}
return userMapper.selectUserList(user); return userMapper.selectUserList(user);
} }
@ -440,6 +444,7 @@ public class SysUserServiceImpl implements ISysUserService
List<SysUserRole> list = new ArrayList<SysUserRole>(); List<SysUserRole> list = new ArrayList<SysUserRole>();
for (Long roleId : roleIds) for (Long roleId : roleIds)
{ {
SysUserRole ur = new SysUserRole(); SysUserRole ur = new SysUserRole();
ur.setUserId(userId); ur.setUserId(userId);
ur.setRoleId(roleId); ur.setRoleId(roleId);
@ -563,4 +568,5 @@ public class SysUserServiceImpl implements ISysUserService
} }
} }

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.mall.mapper.BrandMapper">
<resultMap type="Brand" id="BrandResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="sort" column="sort"/>
<result property="showStatus" column="show_status"/>
<result property="logo" column="logo"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectBrandVo">
select id, name, sort, show_status, logo, create_by, create_time, update_by, update_time from pms_brand
</sql>
<select id="selectByEntity" parameterType="Brand" resultMap="BrandResult">
<include refid="selectBrandVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="sort != null "> and sort = #{sort}</if>
<if test="showStatus != null "> and show_status = #{showStatus}</if>
<if test="logo != null and logo != ''"> and logo = #{logo}</if>
</where>
</select>
</mapper>

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.mall.mapper.ProductCategoryMapper">
<resultMap type="ProductCategory" id="ProductCategoryResult">
<result property="id" column="id"/>
<result property="parentId" column="parent_id"/>
<result property="name" column="name"/>
<result property="level" column="level"/>
<result property="showStatus" column="show_status"/>
<result property="sort" column="sort"/>
<result property="icon" column="icon"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time" />
<result property="storeId" column="store_id" />
</resultMap>
<sql id="selectProductCategoryVo">
select id, parent_id, name, level, show_status, sort, icon, create_by, create_time, update_by, update_time from pms_product_category
</sql>
<select id="selectByEntity" parameterType="ProductCategory" resultMap="ProductCategoryResult">
<include refid="selectProductCategoryVo"/>
<where>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="level != null "> and level = #{level}</if>
<if test="showStatus != null "> and show_status = #{showStatus}</if>
<if test="sort != null "> and sort = #{sort}</if>
<if test="icon != null and icon != ''"> and icon = #{icon}</if>
</where>
</select>
</mapper>

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.mall.mapper.ProductMapper">
<resultMap type="Product" id="ProductResult">
<result property="id" column="id"/>
<result property="brandId" column="brand_id"/>
<result property="categoryId" column="category_id"/>
<result property="outProductId" column="out_product_id"/>
<result property="name" column="name"/>
<result property="pic" column="pic"/>
<result property="albumPics" column="album_pics"/>
<result property="publishStatus" column="publish_status"/>
<result property="sort" column="sort"/>
<result property="price" column="price"/>
<result property="unit" column="unit"/>
<result property="weight" column="weight"/>
<result property="detailHtml" column="detail_html"/>
<result property="detailMobileHtml" column="detail_mobile_html"/>
<result property="brandName" column="brand_name"/>
<result property="productCategoryName" column="product_category_name"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectProductVo">
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
</sql>
<select id="selectByEntity" parameterType="Product" resultMap="ProductResult">
<include refid="selectProductVo"/>
<where>
<if test="brandId != null "> and brand_id = #{brandId}</if>
<if test="categoryId != null "> and category_id = #{categoryId}</if>
<if test="outProductId != null and outProductId != ''"> and out_product_id = #{outProductId}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="pic != null and pic != ''"> and pic = #{pic}</if>
<if test="albumPics != null and albumPics != ''"> and album_pics = #{albumPics}</if>
<if test="publishStatus != null "> and publish_status = #{publishStatus}</if>
<if test="sort != null "> and sort = #{sort}</if>
<if test="price != null "> and price = #{price}</if>
<if test="unit != null and unit != ''"> and unit = #{unit}</if>
<if test="weight != null "> and weight = #{weight}</if>
<if test="detailHtml != null and detailHtml != ''"> and detail_html = #{detailHtml}</if>
<if test="detailMobileHtml != null and detailMobileHtml != ''"> and detail_mobile_html = #{detailMobileHtml}</if>
<if test="brandName != null and brandName != ''"> and brand_name like concat('%', #{brandName}, '%')</if>
<if test="productCategoryName != null and productCategoryName != ''"> and product_category_name like concat('%', #{productCategoryName}, '%')</if>
</where>
</select>
</mapper>

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.mall.mapper.SkuMapper">
<resultMap type="Sku" id="SkuResult">
<result property="id" column="id"/>
<result property="productId" column="product_id"/>
<result property="outSkuId" column="out_sku_id"/>
<result property="price" column="price"/>
<result property="pic" column="pic"/>
<result property="spData" column="sp_data"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectSkuVo">
select id, product_id, out_sku_id, price, pic, sp_data, create_by, create_time, update_by, update_time from pms_sku
</sql>
<update id="updateStockById">
update
pms_sku
set
stock = stock - #{quantity},
update_time = #{optDate}
where id = #{skuId}
</update>
<select id="selectByEntity" parameterType="Sku" resultMap="SkuResult">
<include refid="selectSkuVo"/>
<where>
<if test="productId != null "> and product_id = #{productId}</if>
<if test="outSkuId != null and outSkuId != ''"> and out_sku_id = #{outSkuId}</if>
<if test="price != null "> and price = #{price}</if>
<if test="pic != null and pic != ''"> and pic = #{pic}</if>
<if test="spData != null and spData != ''"> and sp_data = #{spData}</if>
</where>
</select>
</mapper>

@ -20,10 +20,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="leaderId" column="leader_id" />
<result property="deptType" column="dept_type" />
<result property="tenantId" column="tenant_id" />
</resultMap> </resultMap>
<sql id="selectDeptVo"> <sql id="selectDeptVo">
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 from sys_dept d
</sql> </sql>
@ -42,6 +47,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND status = #{status} AND status = #{status}
</if> </if>
<if test="tenantId != null and tenantId != ''">
AND tenant_id = #{tenantId}
</if>
<!-- 数据范围过滤 --> <!-- 数据范围过滤 -->
${params.dataScope} ${params.dataScope}
order by d.parent_id, d.order_num order by d.parent_id, d.order_num
@ -52,9 +60,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from sys_dept d from sys_dept d
left join sys_role_dept rd on d.dept_id = rd.dept_id left join sys_role_dept rd on d.dept_id = rd.dept_id
where rd.role_id = #{roleId} where rd.role_id = #{roleId}
AND tenant_id = #{tenantId}
<if test="deptCheckStrictly"> <if test="deptCheckStrictly">
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}) 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})
</if> </if>
order by d.parent_id, d.order_num order by d.parent_id, d.order_num
</select> </select>
@ -85,7 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where dept_name=#{deptName} and parent_id = #{parentId} limit 1 where dept_name=#{deptName} and parent_id = #{parentId} limit 1
</select> </select>
<insert id="insertDept" parameterType="SysDept"> <insert id="insertDept" parameterType="SysDept" useGeneratedKeys="true" keyProperty="deptId">
insert into sys_dept( insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if> <if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if> <if test="parentId != null and parentId != 0">parent_id,</if>
@ -95,6 +105,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="leader != null and leader != ''">leader,</if> <if test="leader != null and leader != ''">leader,</if>
<if test="phone != null and phone != ''">phone,</if> <if test="phone != null and phone != ''">phone,</if>
<if test="email != null and email != ''">email,</if> <if test="email != null and email != ''">email,</if>
<if test="tenantId != null and tenantId != ''">tenant_id,</if>
<if test="deptType != null and deptType != ''">dept_type,</if>
<if test="status != null">status,</if> <if test="status != null">status,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
create_time create_time
@ -107,6 +119,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="leader != null and leader != ''">#{leader},</if> <if test="leader != null and leader != ''">#{leader},</if>
<if test="phone != null and phone != ''">#{phone},</if> <if test="phone != null and phone != ''">#{phone},</if>
<if test="email != null and email != ''">#{email},</if> <if test="email != null and email != ''">#{email},</if>
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
<if test="deptType != null and deptType != ''">#{deptType},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
sysdate() sysdate()
@ -121,8 +135,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if> <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if> <if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
<if test="leader != null">leader = #{leader},</if> <if test="leader != null">leader = #{leader},</if>
<if test="leaderId != null">leader_id = #{leaderId},</if>
<if test="phone != null">phone = #{phone},</if> <if test="phone != null">phone = #{phone},</if>
<if test="email != null">email = #{email},</if> <if test="email != null">email = #{email},</if>
<if test="tenantId != null and tenantId != ''">tenant_id =#{tenantId},</if>
<if test="deptType != null and deptType != ''">dept_type =#{deptType},</if>
<if test="status != null and status != ''">status = #{status},</if> <if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
update_time = sysdate() update_time = sysdate()

@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult"> <select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult">
<include refid="selectPostVo"/> <include refid="selectPostVo"/>
<where> <where>
tenant_id = #{tenantId}
<if test="postCode != null and postCode != ''"> <if test="postCode != null and postCode != ''">
AND post_code like concat('%', #{postCode}, '%') AND post_code like concat('%', #{postCode}, '%')
</if> </if>
@ -39,6 +40,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectPostAll" resultMap="SysPostResult"> <select id="selectPostAll" resultMap="SysPostResult">
<include refid="selectPostVo"/> <include refid="selectPostVo"/>
where 1=1
<if test="tenantId != null and tenantId != ''">
and tenant_id=#{tenantId}
</if>
</select> </select>
<select id="selectPostById" parameterType="Long" resultMap="SysPostResult"> <select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
@ -46,12 +52,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where post_id = #{postId} where post_id = #{postId}
</select> </select>
<select id="selectPostListByUserId" parameterType="Long" resultType="Integer"> <select id="selectPostListByUserId" resultType="Integer">
select p.post_id select p.post_id
from sys_post p from sys_post p
left join sys_user_post up on up.post_id = p.post_id 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 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}
</select> </select>
<select id="selectPostsByUserName" parameterType="String" resultMap="SysPostResult"> <select id="selectPostsByUserName" parameterType="String" resultMap="SysPostResult">
@ -95,6 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">status,</if> <if test="status != null and status != ''">status,</if>
<if test="remark != null and remark != ''">remark,</if> <if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="tenantId != null">tenant_id,</if>
create_time create_time
)values( )values(
<if test="postId != null and postId != 0">#{postId},</if> <if test="postId != null and postId != 0">#{postId},</if>
@ -104,6 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="tenantId != null">#{tenantId},</if>
sysdate() sysdate()
) )
</insert> </insert>

@ -66,12 +66,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectRoleVo"/> <include refid="selectRoleVo"/>
</select> </select>
<select id="selectRoleListByUserId" parameterType="Long" resultType="Integer"> <select id="selectRoleListByUserId" resultType="Integer">
select r.role_id select r.role_id
from sys_role r from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id 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 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> </select>
<select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult"> <select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult">

@ -15,7 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="avatar" column="avatar" /> <result property="avatar" column="avatar" />
<result property="password" column="password" /> <result property="password" column="password" />
<result property="status" column="status" /> <result property="status" column="status" />
<result property="delFlag" column="del_flag" /> <result property="deleteFlag" column="delete_flag" />
<result property="loginIp" column="login_ip" /> <result property="loginIp" column="login_ip" />
<result property="loginDate" column="login_date" /> <result property="loginDate" column="login_date" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectUserVo"> <sql id="selectUserVo">
select u.user_id, u.dept_id, u.user_name, u.nick_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, select u.user_id, u.dept_id, u.user_name, u.nick_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_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status, d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,u.tenant_id r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,u.tenant_id
from sys_user u from sys_user u
@ -57,9 +57,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql> </sql>
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
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 left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0' where u.delete_flag = '0'
<if test="userId != null and userId != 0"> <if test="userId != null and userId != 0">
AND u.user_id = #{userId} AND u.user_id = #{userId}
</if> </if>
@ -69,6 +70,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND u.status = #{status} AND u.status = #{status}
</if> </if>
<if test="tenantId != null and tenantId != ''">
AND u.tenant_id = #{tenantId}
</if>
<if test="phonenumber != null and phonenumber != ''"> <if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%') AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if> </if>
@ -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_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_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_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}
<if test="userName != null and userName != ''"> <if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%') AND u.user_name like concat('%', #{userName}, '%')
</if> </if>
@ -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_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_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_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_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})
<if test="userName != null and userName != ''"> <if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%') AND u.user_name like concat('%', #{userName}, '%')
@ -146,6 +150,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into sys_user( insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if> <if test="userId != null and userId != 0">user_id,</if>
<if test="deptId != null and deptId != 0">dept_id,</if> <if test="deptId != null and deptId != 0">dept_id,</if>
<if test="tenantId != null and tenantId != ''">tenant_id,</if>
<if test="userName != null and userName != ''">user_name,</if> <if test="userName != null and userName != ''">user_name,</if>
<if test="nickName != null and nickName != ''">nick_name,</if> <if test="nickName != null and nickName != ''">nick_name,</if>
<if test="email != null and email != ''">email,</if> <if test="email != null and email != ''">email,</if>
@ -156,10 +161,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">status,</if> <if test="status != null and status != ''">status,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="remark != null and remark != ''">remark,</if> <if test="remark != null and remark != ''">remark,</if>
<if test="teacher != null and teacher != ''">teacher,</if>
create_time create_time
)values( )values(
<if test="userId != null and userId != ''">#{userId},</if> <if test="userId != null and userId != ''">#{userId},</if>
<if test="deptId != null and deptId != ''">#{deptId},</if> <if test="deptId != null and deptId != ''">#{deptId},</if>
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
<if test="userName != null and userName != ''">#{userName},</if> <if test="userName != null and userName != ''">#{userName},</if>
<if test="nickName != null and nickName != ''">#{nickName},</if> <if test="nickName != null and nickName != ''">#{nickName},</if>
<if test="email != null and email != ''">#{email},</if> <if test="email != null and email != ''">#{email},</if>
@ -170,6 +177,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="teacher != null and teacher != ''">#{teacher},</if>
sysdate() sysdate()
) )
</insert> </insert>
@ -190,6 +198,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="loginDate != null">login_date = #{loginDate},</if> <if test="loginDate != null">login_date = #{loginDate},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="teacher != null">teacher = #{teacher},</if>
update_time = sysdate() update_time = sysdate()
</set> </set>
where user_id = #{userId} where user_id = #{userId}
@ -208,11 +217,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<delete id="deleteUserById" parameterType="Long"> <delete id="deleteUserById" parameterType="Long">
update sys_user set del_flag = '2' where user_id = #{userId} update sys_user set delelete_flag = '2' where user_id = #{userId}
</delete> </delete>
<delete id="deleteUserByIds" parameterType="Long"> <delete id="deleteUserByIds" parameterType="Long">
update sys_user set del_flag = '2' where user_id in update sys_user set delete_flag = '2' where user_id in
<foreach collection="array" item="userId" open="(" separator="," close=")"> <foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId} #{userId}
</foreach> </foreach>

Loading…
Cancel
Save