master:档口装修功能;
parent
4c616264c7
commit
e9ba3fe08a
|
|
@ -1,91 +1,66 @@
|
||||||
package com.ruoyi.web.controller.xkt;
|
package com.ruoyi.web.controller.xkt;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.XktBaseController;
|
import com.ruoyi.common.core.controller.XktBaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.web.controller.xkt.vo.storeHomepage.StoreHomeVO;
|
||||||
import com.ruoyi.xkt.domain.StoreHomepage;
|
import com.ruoyi.xkt.dto.storeHomepage.StoreHomeDTO;
|
||||||
import com.ruoyi.xkt.service.IStoreHomepageService;
|
import com.ruoyi.xkt.service.IStoreHomepageService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 档口首页Controller
|
* 档口首页装修Controller
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2025-03-26
|
* @date 2025-03-26
|
||||||
*/
|
*/
|
||||||
|
@Api(tags = "档口首页装修")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/rest/v1/store-homepages")
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/rest/v1/store-homes")
|
||||||
public class StoreHomepageController extends XktBaseController {
|
public class StoreHomepageController extends XktBaseController {
|
||||||
@Autowired
|
|
||||||
private IStoreHomepageService storeHomepageService;
|
final IStoreHomepageService storeHomeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询档口首页列表
|
* 新增档口首页装修数据
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:homepage:list')")
|
|
||||||
@GetMapping("/list")
|
|
||||||
public TableDataInfo list(StoreHomepage storeHomepage) {
|
|
||||||
startPage();
|
|
||||||
List<StoreHomepage> list = storeHomepageService.selectStoreHomepageList(storeHomepage);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出档口首页列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:homepage:export')")
|
|
||||||
@Log(title = "档口首页", businessType = BusinessType.EXPORT)
|
|
||||||
@PostMapping("/export")
|
|
||||||
public void export(HttpServletResponse response, StoreHomepage storeHomepage) {
|
|
||||||
List<StoreHomepage> list = storeHomepageService.selectStoreHomepageList(storeHomepage);
|
|
||||||
ExcelUtil<StoreHomepage> util = new ExcelUtil<StoreHomepage>(StoreHomepage.class);
|
|
||||||
util.exportExcel(response, list, "档口首页数据");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取档口首页详细信息
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:homepage:query')")
|
|
||||||
@GetMapping(value = "/{storeHomeId}")
|
|
||||||
public R getInfo(@PathVariable("storeHomeId") Long storeHomeId) {
|
|
||||||
return success(storeHomepageService.selectStoreHomepageByStoreHomeId(storeHomeId));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增档口首页
|
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:homepage:add')")
|
@PreAuthorize("@ss.hasPermi('system:homepage:add')")
|
||||||
@Log(title = "档口首页", businessType = BusinessType.INSERT)
|
@ApiOperation(value = "新增档口首页装修数据", httpMethod = "POST", response = R.class)
|
||||||
@PostMapping
|
@Log(title = "新增档口首页装修数据", businessType = BusinessType.INSERT)
|
||||||
public R add(@RequestBody StoreHomepage storeHomepage) {
|
@PostMapping("/{storeId}/{templateNum}")
|
||||||
return success(storeHomepageService.insertStoreHomepage(storeHomepage));
|
public R<Integer> add(@PathVariable("storeId") Long storeId, @PathVariable("templateNum") Integer templateNum,
|
||||||
|
@Validated @RequestBody StoreHomeVO homepageVO) {
|
||||||
|
return R.ok(storeHomeService.insert(storeId, templateNum, BeanUtil.toBean(homepageVO, StoreHomeDTO.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改档口首页
|
* 查询档口首页装修数据
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:sale:query')")
|
||||||
|
@ApiOperation(value = "查询档口首页装修数据", httpMethod = "GET", response = R.class)
|
||||||
|
@GetMapping(value = "/{storeId}")
|
||||||
|
public R<StoreHomeVO> getInfo(@PathVariable("storeId") Long storeId) {
|
||||||
|
return R.ok(BeanUtil.toBean(storeHomeService.selectByStoreId(storeId), StoreHomeVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改档口首页装修数据
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:homepage:edit')")
|
@PreAuthorize("@ss.hasPermi('system:homepage:edit')")
|
||||||
@Log(title = "档口首页", businessType = BusinessType.UPDATE)
|
@ApiOperation(value = "修改档口首页装修数据", httpMethod = "PUT", response = R.class)
|
||||||
@PutMapping
|
@Log(title = "修改档口首页装修数据", businessType = BusinessType.UPDATE)
|
||||||
public R edit(@RequestBody StoreHomepage storeHomepage) {
|
@PutMapping("/{storeId}/{templateNum}")
|
||||||
return success(storeHomepageService.updateStoreHomepage(storeHomepage));
|
public R<Integer> edit(@PathVariable("storeId") Long storeId, @PathVariable("templateNum") Integer templateNum,
|
||||||
|
@Validated @RequestBody StoreHomeVO homepageVO) {
|
||||||
|
return R.ok(storeHomeService.updateStoreHomepage(storeId, templateNum, BeanUtil.toBean(homepageVO, StoreHomeDTO.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除档口首页
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:homepage:remove')")
|
|
||||||
@Log(title = "档口首页", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{storeHomeIds}")
|
|
||||||
public R remove(@PathVariable Long[] storeHomeIds) {
|
|
||||||
return success(storeHomepageService.deleteStoreHomepageByStoreHomeIds(storeHomeIds));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ public class StoreProductController extends XktBaseController {
|
||||||
@PutMapping("/prod-status")
|
@PutMapping("/prod-status")
|
||||||
public R editProdStatus(@Validated @RequestBody StoreProdStatusVO prodStatusVO) {
|
public R editProdStatus(@Validated @RequestBody StoreProdStatusVO prodStatusVO) {
|
||||||
storeProdService.updateStoreProductStatus(BeanUtil.toBean(prodStatusVO, StoreProdStatusDTO.class));
|
storeProdService.updateStoreProductStatus(BeanUtil.toBean(prodStatusVO, StoreProdStatusDTO.class));
|
||||||
return success();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.ruoyi.web.controller.xkt.vo.storeHomepage;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author liujiang
|
||||||
|
* @version v1.0
|
||||||
|
* @date 2025/3/27 15:12
|
||||||
|
*/
|
||||||
|
@ApiModel("档口首页装修")
|
||||||
|
@Data
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class StoreHomeVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "档口首页装修", required = true)
|
||||||
|
List<HomePageFileVO> fileList;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "档口首页文件")
|
||||||
|
public static class HomePageFileVO {
|
||||||
|
@ApiModelProperty(value = "文件名称")
|
||||||
|
private String fileName;
|
||||||
|
@ApiModelProperty(value = "文件路径")
|
||||||
|
private String fileUrl;
|
||||||
|
@ApiModelProperty(value = "文件大小")
|
||||||
|
private BigDecimal fileSize;
|
||||||
|
@ApiModelProperty(value = "文件类型 1轮播大图 2轮播小图 3店家推荐 4人气爆款 5当季新品 6销量排行")
|
||||||
|
private Integer fileType;
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private Integer orderNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,102 +1,87 @@
|
||||||
package com.ruoyi.system.domain;
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.XktBaseEntity;
|
||||||
|
import com.ruoyi.common.xss.Xss;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import java.util.Date;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
|
||||||
import com.ruoyi.common.xss.Xss;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知公告表 sys_notice
|
* 通知公告表 sys_notice
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class SysNotice extends BaseEntity
|
@EqualsAndHashCode(callSuper = true)
|
||||||
{
|
@Data
|
||||||
|
public class SysNotice extends XktBaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 公告ID */
|
/**
|
||||||
|
* 公告ID
|
||||||
|
*/
|
||||||
private Long noticeId;
|
private Long noticeId;
|
||||||
|
|
||||||
/** 公告标题 */
|
/**
|
||||||
|
* 公告标题
|
||||||
|
*/
|
||||||
private String noticeTitle;
|
private String noticeTitle;
|
||||||
|
|
||||||
/** 公告类型(1通知 2公告) */
|
/**
|
||||||
|
* 公告类型(1通知 2公告)
|
||||||
|
*/
|
||||||
private String noticeType;
|
private String noticeType;
|
||||||
|
|
||||||
/** 公告内容 */
|
/**
|
||||||
|
* 公告内容
|
||||||
|
*/
|
||||||
private String noticeContent;
|
private String noticeContent;
|
||||||
|
|
||||||
/** 公告状态(0正常 1关闭) */
|
/**
|
||||||
|
* 1 系统 2 档口
|
||||||
|
*/
|
||||||
|
private Integer ownerType;
|
||||||
|
/**
|
||||||
|
* 生效开始时间 yyyy-MM-dd HH:mm
|
||||||
|
*/
|
||||||
|
private Date effectStart;
|
||||||
|
/**
|
||||||
|
* 生效结束时间 yyyy-MM-dd HH:mm
|
||||||
|
*/
|
||||||
|
private Date effectEnd;
|
||||||
|
/**
|
||||||
|
* 是否永久生效
|
||||||
|
*/
|
||||||
|
private Integer perpetuity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公告状态(0正常 1关闭)
|
||||||
|
*/
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
public Long getNoticeId()
|
|
||||||
{
|
|
||||||
return noticeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNoticeId(Long noticeId)
|
|
||||||
{
|
|
||||||
this.noticeId = noticeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNoticeTitle(String noticeTitle)
|
|
||||||
{
|
|
||||||
this.noticeTitle = noticeTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Xss(message = "公告标题不能包含脚本字符")
|
@Xss(message = "公告标题不能包含脚本字符")
|
||||||
@NotBlank(message = "公告标题不能为空")
|
@NotBlank(message = "公告标题不能为空")
|
||||||
@Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
|
@Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
|
||||||
public String getNoticeTitle()
|
public String getNoticeTitle() {
|
||||||
{
|
|
||||||
return noticeTitle;
|
return noticeTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNoticeType(String noticeType)
|
|
||||||
{
|
|
||||||
this.noticeType = noticeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNoticeType()
|
|
||||||
{
|
|
||||||
return noticeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNoticeContent(String noticeContent)
|
|
||||||
{
|
|
||||||
this.noticeContent = noticeContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNoticeContent()
|
|
||||||
{
|
|
||||||
return noticeContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(String status)
|
|
||||||
{
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatus()
|
|
||||||
{
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
.append("noticeId", getNoticeId())
|
.append("noticeId", getNoticeId())
|
||||||
.append("noticeTitle", getNoticeTitle())
|
.append("noticeTitle", getNoticeTitle())
|
||||||
.append("noticeType", getNoticeType())
|
.append("noticeType", getNoticeType())
|
||||||
.append("noticeContent", getNoticeContent())
|
.append("noticeContent", getNoticeContent())
|
||||||
.append("status", getStatus())
|
.append("status", getStatus())
|
||||||
.append("createBy", getCreateBy())
|
.append("createBy", getCreateBy())
|
||||||
.append("createTime", getCreateTime())
|
.append("createTime", getCreateTime())
|
||||||
.append("updateBy", getUpdateBy())
|
.append("updateBy", getUpdateBy())
|
||||||
.append("updateTime", getUpdateTime())
|
.append("updateTime", getUpdateTime())
|
||||||
.append("remark", getRemark())
|
.toString();
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -622,9 +622,13 @@ drop table if exists sys_notice;
|
||||||
create table sys_notice (
|
create table sys_notice (
|
||||||
notice_id int(4) not null auto_increment comment '公告ID',
|
notice_id int(4) not null auto_increment comment '公告ID',
|
||||||
notice_title varchar(50) not null comment '公告标题',
|
notice_title varchar(50) not null comment '公告标题',
|
||||||
notice_type char(1) not null comment '公告类型(1通知 2公告)',
|
notice_type tinyint(1) not null comment '公告类型(1通知 2公告)',
|
||||||
|
owner_type char(1) not null comment '公告拥有者(1系统 2档口)',
|
||||||
notice_content longblob default null comment '公告内容',
|
notice_content longblob default null comment '公告内容',
|
||||||
status char(1) default '0' comment '公告状态(0正常 1关闭)',
|
status char(1) default '0' comment '公告状态(0正常 1关闭)',
|
||||||
|
effect_start datetime comment '公告生效时间(yyyy-MM-dd HH:mm)',
|
||||||
|
effect_end datetime comment '公告失效时间(yyyy-MM-dd HH:mm)',
|
||||||
|
perpetuity tinyint(1) comment '是否永久生效',
|
||||||
create_by varchar(64) default '' comment '创建者',
|
create_by varchar(64) default '' comment '创建者',
|
||||||
create_time datetime comment '创建时间',
|
create_time datetime comment '创建时间',
|
||||||
update_by varchar(64) default '' comment '更新者',
|
update_by varchar(64) default '' comment '更新者',
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.ruoyi.common.annotation.Excel;
|
||||||
import com.ruoyi.common.core.domain.XktBaseEntity;
|
import com.ruoyi.common.core.domain.XktBaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
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;
|
||||||
|
|
||||||
|
|
@ -16,7 +17,9 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
public class StoreHomepage extends XktBaseEntity {
|
public class StoreHomepage extends XktBaseEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -35,7 +38,7 @@ public class StoreHomepage extends XktBaseEntity {
|
||||||
* 档口各位置类型
|
* 档口各位置类型
|
||||||
*/
|
*/
|
||||||
@Excel(name = "档口各位置类型")
|
@Excel(name = "档口各位置类型")
|
||||||
private Long type;
|
private Integer type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 档口各位置文件ID
|
* 档口各位置文件ID
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.ruoyi.xkt.dto.storeHomepage;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author liujiang
|
||||||
|
* @version v1.0
|
||||||
|
* @date 2025/3/27 15:12
|
||||||
|
*/
|
||||||
|
@ApiModel("档口首页装修")
|
||||||
|
@Data
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class StoreHomeDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "档口首页装修模板Num")
|
||||||
|
private Integer templateNum;
|
||||||
|
@ApiModelProperty(value = "档口首页装修")
|
||||||
|
List<HomePageFileDTO> fileList;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "档口首页文件")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public static class HomePageFileDTO {
|
||||||
|
@ApiModelProperty(value = "文件名称")
|
||||||
|
private String fileName;
|
||||||
|
@ApiModelProperty(value = "文件路径")
|
||||||
|
private String fileUrl;
|
||||||
|
@ApiModelProperty(value = "文件大小")
|
||||||
|
private BigDecimal fileSize;
|
||||||
|
@ApiModelProperty(value = "文件类型 1轮播大图 2轮播小图 3店家推荐 4人气爆款 5当季新品 6销量排行")
|
||||||
|
private Integer fileType;
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private Integer orderNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.ruoyi.xkt.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author liangyq
|
||||||
|
* @date 2025-04-02 23:42
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum HomepageType {
|
||||||
|
|
||||||
|
// 轮播大图
|
||||||
|
SLIDING_PICTURE(1, "轮播大图"),
|
||||||
|
// 轮播小图
|
||||||
|
SLIDING_PICTURE_SMALL(2, "轮播小图"),
|
||||||
|
// 店家推荐
|
||||||
|
STORE_RECOMMENDED(3, "店家推荐"),
|
||||||
|
// 人气爆款
|
||||||
|
POPULAR_STYLES(4, "人气爆款"),
|
||||||
|
// 当季新品
|
||||||
|
SEASON_NEW_PRODUCTS(5, "当季新品"),
|
||||||
|
// 销量排行
|
||||||
|
SALES_RANKING(6, "销量排行"),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
private final Integer value;
|
||||||
|
private final String label;
|
||||||
|
|
||||||
|
public static HomepageType of(Integer value) {
|
||||||
|
for (HomepageType e : HomepageType.values()) {
|
||||||
|
if (e.getValue().equals(value)) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package com.ruoyi.xkt.service;
|
package com.ruoyi.xkt.service;
|
||||||
|
|
||||||
import com.ruoyi.xkt.domain.StoreHomepage;
|
import com.ruoyi.xkt.dto.storeHomepage.StoreHomeDTO;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 档口首页Service接口
|
* 档口首页Service接口
|
||||||
|
|
@ -11,51 +9,33 @@ import java.util.List;
|
||||||
* @date 2025-03-26
|
* @date 2025-03-26
|
||||||
*/
|
*/
|
||||||
public interface IStoreHomepageService {
|
public interface IStoreHomepageService {
|
||||||
/**
|
|
||||||
* 查询档口首页
|
|
||||||
*
|
|
||||||
* @param storeHomeId 档口首页主键
|
|
||||||
* @return 档口首页
|
|
||||||
*/
|
|
||||||
public StoreHomepage selectStoreHomepageByStoreHomeId(Long storeHomeId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询档口首页列表
|
* 新增档口首页各部分图
|
||||||
*
|
*
|
||||||
* @param storeHomepage 档口首页
|
* @param storeId 档口ID
|
||||||
* @return 档口首页集合
|
* @param templateNum 选择的模板No
|
||||||
|
* @param homepageDTO 新增档口首页各部分图
|
||||||
|
* @return Integer
|
||||||
*/
|
*/
|
||||||
public List<StoreHomepage> selectStoreHomepageList(StoreHomepage storeHomepage);
|
Integer insert(Long storeId, Integer templateNum, StoreHomeDTO homepageDTO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增档口首页
|
* 获取档口首页各个部分的图信息
|
||||||
*
|
*
|
||||||
* @param storeHomepage 档口首页
|
* @param storeId 档口ID
|
||||||
* @return 结果
|
* @return StoreHomeDTO
|
||||||
*/
|
*/
|
||||||
public int insertStoreHomepage(StoreHomepage storeHomepage);
|
StoreHomeDTO selectByStoreId(Long storeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改档口首页
|
* 更新档口首页各部分图信息
|
||||||
*
|
*
|
||||||
* @param storeHomepage 档口首页
|
* @param storeId 档口ID
|
||||||
* @return 结果
|
* @param templateNum 选择的模板Num
|
||||||
|
* @param homeDTO 更新的dto
|
||||||
|
* @return Integer
|
||||||
*/
|
*/
|
||||||
public int updateStoreHomepage(StoreHomepage storeHomepage);
|
Integer updateStoreHomepage(Long storeId, Integer templateNum, StoreHomeDTO homeDTO);
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除档口首页
|
|
||||||
*
|
|
||||||
* @param storeHomeIds 需要删除的档口首页主键集合
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteStoreHomepageByStoreHomeIds(Long[] storeHomeIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除档口首页信息
|
|
||||||
*
|
|
||||||
* @param storeHomeId 档口首页主键
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteStoreHomepageByStoreHomeId(Long storeHomeId);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,29 @@
|
||||||
package com.ruoyi.xkt.service.impl;
|
package com.ruoyi.xkt.service.impl;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.ruoyi.common.constant.Constants;
|
||||||
|
import com.ruoyi.common.constant.HttpStatus;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
|
import com.ruoyi.xkt.domain.Store;
|
||||||
import com.ruoyi.xkt.domain.StoreHomepage;
|
import com.ruoyi.xkt.domain.StoreHomepage;
|
||||||
|
import com.ruoyi.xkt.domain.SysFile;
|
||||||
|
import com.ruoyi.xkt.dto.storeHomepage.StoreHomeDTO;
|
||||||
import com.ruoyi.xkt.mapper.StoreHomepageMapper;
|
import com.ruoyi.xkt.mapper.StoreHomepageMapper;
|
||||||
|
import com.ruoyi.xkt.mapper.StoreMapper;
|
||||||
|
import com.ruoyi.xkt.mapper.SysFileMapper;
|
||||||
import com.ruoyi.xkt.service.IStoreHomepageService;
|
import com.ruoyi.xkt.service.IStoreHomepageService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 档口首页Service业务层处理
|
* 档口首页Service业务层处理
|
||||||
|
|
@ -16,82 +31,124 @@ import java.util.List;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2025-03-26
|
* @date 2025-03-26
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class StoreHomepageServiceImpl implements IStoreHomepageService {
|
public class StoreHomepageServiceImpl implements IStoreHomepageService {
|
||||||
@Autowired
|
|
||||||
private StoreHomepageMapper storeHomepageMapper;
|
final SysFileMapper fileMapper;
|
||||||
|
final StoreHomepageMapper storeHomeMapper;
|
||||||
|
final StoreMapper storeMapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询档口首页
|
* 新增档口首页各部分图
|
||||||
*
|
*
|
||||||
* @param storeHomeId 档口首页主键
|
* @param storeId 档口ID
|
||||||
* @return 档口首页
|
* @param templateNum 使用的模板No
|
||||||
|
* @param homepageDTO 新增档口首页各部分图
|
||||||
|
* @return Integer
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Integer insert(Long storeId, Integer templateNum, StoreHomeDTO homepageDTO) {
|
||||||
|
Integer count = this.insertToSysFile(storeId, homepageDTO);
|
||||||
|
// 当前档口首页各部分总的文件大小
|
||||||
|
BigDecimal totalSize = homepageDTO.getFileList().stream().map(x -> ObjectUtils.defaultIfNull(x.getFileSize(), BigDecimal.ZERO)).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
Store store = Optional.ofNullable(this.storeMapper.selectOne(new LambdaQueryWrapper<Store>().eq(Store::getId, storeId).eq(Store::getDelFlag, Constants.UNDELETED)))
|
||||||
|
.orElseThrow(() -> new ServiceException("档口不存在!", HttpStatus.ERROR));
|
||||||
|
store.setTemplateNum(templateNum);
|
||||||
|
// 更新档口首页使用的总的文件容量
|
||||||
|
store.setStorageUsage(ObjectUtils.defaultIfNull(store.getStorageUsage(), BigDecimal.ZERO).add(totalSize));
|
||||||
|
this.storeMapper.updateById(store);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取档口首页各个部分的图信息
|
||||||
|
*
|
||||||
|
* @param storeId 档口ID
|
||||||
|
* @return StoreHomeDTO
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public StoreHomepage selectStoreHomepageByStoreHomeId(Long storeHomeId) {
|
public StoreHomeDTO selectByStoreId(Long storeId) {
|
||||||
return storeHomepageMapper.selectStoreHomepageByStoreHomeId(storeHomeId);
|
Store store = Optional.ofNullable(this.storeMapper.selectOne(new LambdaQueryWrapper<Store>()
|
||||||
|
.eq(Store::getId, storeId).eq(Store::getDelFlag, Constants.UNDELETED)))
|
||||||
|
.orElseThrow(() -> new ServiceException("档口不存在!", HttpStatus.ERROR));
|
||||||
|
List<StoreHomepage> homeList = this.storeHomeMapper.selectList(new LambdaQueryWrapper<StoreHomepage>()
|
||||||
|
.eq(StoreHomepage::getStoreId, storeId).eq(StoreHomepage::getDelFlag, Constants.UNDELETED));
|
||||||
|
List<SysFile> fileList = Optional.ofNullable(this.fileMapper.selectList(new LambdaQueryWrapper<SysFile>()
|
||||||
|
.in(SysFile::getId, homeList.stream().map(StoreHomepage::getFileId).collect(Collectors.toList()))
|
||||||
|
.eq(SysFile::getDelFlag, Constants.UNDELETED)))
|
||||||
|
.orElseThrow(() -> new ServiceException("文件不存在", HttpStatus.ERROR));
|
||||||
|
Map<Long, SysFile> fileMap = fileList.stream().collect(Collectors.toMap(SysFile::getId, x -> x));
|
||||||
|
return new StoreHomeDTO() {{
|
||||||
|
setTemplateNum(store.getTemplateNum());
|
||||||
|
setFileList(homeList.stream().map(x -> BeanUtil.toBean(x, StoreHomeDTO.HomePageFileDTO.class)
|
||||||
|
.setFileType(x.getType()).setFileName(fileMap.get(x.getFileId()).getFileName())
|
||||||
|
.setFileUrl(fileMap.get(x.getFileId()).getFileUrl()).setFileSize(fileMap.get(x.getFileId()).getFileSize()))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询档口首页列表
|
* 更新档口首页各部分图信息
|
||||||
*
|
*
|
||||||
* @param storeHomepage 档口首页
|
* @param storeId 档口ID
|
||||||
* @return 档口首页
|
* @param templateNum 选择的模板Num
|
||||||
*/
|
* @param homeDTO 更新的dto
|
||||||
@Override
|
* @return Integer
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public List<StoreHomepage> selectStoreHomepageList(StoreHomepage storeHomepage) {
|
|
||||||
return storeHomepageMapper.selectStoreHomepageList(storeHomepage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增档口首页
|
|
||||||
*
|
|
||||||
* @param storeHomepage 档口首页
|
|
||||||
* @return 结果
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int insertStoreHomepage(StoreHomepage storeHomepage) {
|
public Integer updateStoreHomepage(Long storeId, Integer templateNum, StoreHomeDTO homeDTO) {
|
||||||
storeHomepage.setCreateTime(DateUtils.getNowDate());
|
// 先将所有的档口模板的文件都删除掉
|
||||||
return storeHomepageMapper.insertStoreHomepage(storeHomepage);
|
List<StoreHomepage> oldHomeList = this.storeHomeMapper.selectList(new LambdaQueryWrapper<StoreHomepage>()
|
||||||
|
.eq(StoreHomepage::getStoreId, storeId).eq(StoreHomepage::getDelFlag, Constants.UNDELETED));
|
||||||
|
if (CollectionUtils.isNotEmpty(oldHomeList)) {
|
||||||
|
oldHomeList.forEach(x -> x.setDelFlag(Constants.DELETED));
|
||||||
|
this.storeHomeMapper.updateById(oldHomeList);
|
||||||
|
}
|
||||||
|
// 新增档口首页各部分图
|
||||||
|
Integer count = this.insertToSysFile(storeId, homeDTO);
|
||||||
|
List<SysFile> fileList = Optional.ofNullable(this.fileMapper.selectList(new LambdaQueryWrapper<SysFile>()
|
||||||
|
.in(SysFile::getId, oldHomeList.stream().map(StoreHomepage::getFileId).collect(Collectors.toList()))
|
||||||
|
.eq(SysFile::getDelFlag, Constants.UNDELETED)))
|
||||||
|
.orElseThrow(() -> new ServiceException("文件不存在", HttpStatus.ERROR));
|
||||||
|
// 旧的档口首页各部分文件大小
|
||||||
|
BigDecimal oldTotalSize = fileList.stream().map(x -> ObjectUtils.defaultIfNull(x.getFileSize(), BigDecimal.ZERO)).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
// 新的文件大小
|
||||||
|
BigDecimal newTotalSize = homeDTO.getFileList().stream().map(x -> ObjectUtils.defaultIfNull(x.getFileSize(), BigDecimal.ZERO)).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
// 新的文件大小和旧的文件大小的差值
|
||||||
|
BigDecimal diffFileSize = newTotalSize.subtract(oldTotalSize);
|
||||||
|
Store store = Optional.ofNullable(this.storeMapper.selectOne(new LambdaQueryWrapper<Store>()
|
||||||
|
.eq(Store::getId, storeId).eq(Store::getDelFlag, Constants.UNDELETED)))
|
||||||
|
.orElseThrow(() -> new ServiceException("档口不存在!", HttpStatus.ERROR));
|
||||||
|
store.setTemplateNum(templateNum);
|
||||||
|
store.setStorageUsage(ObjectUtils.defaultIfNull(store.getStorageUsage(), BigDecimal.ZERO).add(diffFileSize));
|
||||||
|
this.storeMapper.updateById(store);
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改档口首页
|
|
||||||
*
|
|
||||||
* @param storeHomepage 档口首页
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public int updateStoreHomepage(StoreHomepage storeHomepage) {
|
|
||||||
storeHomepage.setUpdateTime(DateUtils.getNowDate());
|
|
||||||
return storeHomepageMapper.updateStoreHomepage(storeHomepage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除档口首页
|
* 将数据插入到系统文件表中
|
||||||
*
|
*
|
||||||
* @param storeHomeIds 需要删除的档口首页主键
|
* @param storeId 档口ID
|
||||||
* @return 结果
|
* @param homepageDTO 文件DTO
|
||||||
|
* @return 插入的数量
|
||||||
*/
|
*/
|
||||||
@Override
|
private Integer insertToSysFile(Long storeId, StoreHomeDTO homepageDTO) {
|
||||||
@Transactional
|
// 将文件插入到SysFile表中
|
||||||
public int deleteStoreHomepageByStoreHomeIds(Long[] storeHomeIds) {
|
List<SysFile> fileList = BeanUtil.copyToList(homepageDTO.getFileList(), SysFile.class);
|
||||||
return storeHomepageMapper.deleteStoreHomepageByStoreHomeIds(storeHomeIds);
|
this.fileMapper.insert(fileList);
|
||||||
|
// 将文件名称和文件ID映射到Map中
|
||||||
|
Map<String, Long> fileMap = fileList.stream().collect(Collectors.toMap(SysFile::getFileName, SysFile::getId));
|
||||||
|
List<StoreHomepage> homepageList = homepageDTO.getFileList().stream().map(x -> BeanUtil.toBean(x, StoreHomepage.class).setStoreId(storeId).setType(x.getFileType())
|
||||||
|
.setFileId(Optional.ofNullable(fileMap.get(x.getFileName())).orElseThrow(() -> new ServiceException("文件不存在", HttpStatus.ERROR))))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
return this.storeHomeMapper.insert(homepageList).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除档口首页信息
|
|
||||||
*
|
|
||||||
* @param storeHomeId 档口首页主键
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public int deleteStoreHomepageByStoreHomeId(Long storeHomeId) {
|
|
||||||
return storeHomepageMapper.deleteStoreHomepageByStoreHomeId(storeHomeId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue