src/main/java/cc/mrbird/febs/common/enumerates/SocialSourceTypeEnum.java
New file @@ -0,0 +1,25 @@ package cc.mrbird.febs.common.enumerates; import lombok.Getter; /** * **/ @Getter public enum SocialSourceTypeEnum { /** * 来源类型 1-社区 2-评论 */ COMMENT(2), SOCIAL(1), ; private final int value; SocialSourceTypeEnum(int value) { this.value = value; } } src/main/java/cc/mrbird/febs/common/enumerates/SocialTypeEnum.java
New file @@ -0,0 +1,25 @@ package cc.mrbird.febs.common.enumerates; import lombok.Getter; /** * **/ @Getter public enum SocialTypeEnum { /** * 操作类型 1-点赞 2-收藏 */ COLLECT(2), LIKE(1), ; private final int value; SocialTypeEnum(int value) { this.value = value; } } src/main/java/cc/mrbird/febs/mall/controller/clothes/ApiClothesSocialController.java
@@ -45,6 +45,64 @@ return apiClothesSocialService.indexCategory(); } @ApiOperation(value = "社区列表", notes = "社区列表") @ApiResponses({ @ApiResponse(code = 200, message = "success", response = ApiAllSocialVo.class) }) @PostMapping(value = "/allSocial") public FebsResponse allSocial(@RequestBody @Validated ApiAllSocialDto dto) { return apiClothesSocialService.allSocial(dto); } @ApiOperation(value = "社区详情", notes = "社区详情") @ApiResponses({ @ApiResponse(code = 200, message = "success", response = ApiSocialInfoVo.class) }) @PostMapping(value = "/socialInfo") public FebsResponse socialInfo(@RequestBody @Validated ApiSocialInfoDto dto) { return apiClothesSocialService.socialInfo(dto); } @ApiOperation(value = "分享到社区", notes = "分享到社区") @PostMapping(value = "/socialAdd") public FebsResponse socialAdd(@RequestBody @Validated ApiSocialAddDto dto) { return apiClothesSocialService.socialAdd(dto); } @ApiOperation(value = "点赞(心形)", notes = "点赞(心形)") @PostMapping(value = "/addLike") public FebsResponse addLike(@RequestBody @Validated ApiSocialLikeAddDto dto) { return apiClothesSocialService.addLike(dto); } @ApiOperation(value = "评论点赞(心形)", notes = "点赞(心形)") @PostMapping(value = "/addCommentLike") public FebsResponse addCommentLike(@RequestBody @Validated ApiSocialCommentLikeAddDto dto) { return apiClothesSocialService.addCommentLike(dto); } @ApiOperation(value = "收藏(五角星)", notes = "收藏(五角星)") @PostMapping(value = "/addCollect") public FebsResponse addCollect(@RequestBody @Validated ApiSocialCollectAddDto dto) { return apiClothesSocialService.addCollect(dto); } @ApiOperation(value = "我的灵感-跳转到开始设计", notes = "我的灵感-跳转到开始设计") @ApiResponses({ @ApiResponse(code = 200, message = "success", response = ApiClothesSocialMuseVo.class) }) @PostMapping(value = "/museToDesign") public FebsResponse museToDesign(@RequestBody @Validated ApiClothesSocialMuseDto dto) { return apiClothesSocialService.museToDesign(dto); } } src/main/java/cc/mrbird/febs/mall/controller/clothes/ViewClothesTypeController.java
@@ -13,6 +13,9 @@ import cc.mrbird.febs.mall.vo.clothes.AdminClothesTypeInfoVo; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSON; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; @@ -147,6 +150,13 @@ .eq(ClothesSocialMuse::getSocialId, clothesSocial.getId()) .last("LIMIT 1") ); String patternRemark = clothesSocialMuse.getPatternRemark(); if(StrUtil.isNotBlank(patternRemark)){ JSON parse = JSONUtil.parse(patternRemark); clothesSocialMuse.setPatternText(parse.getByPath("text", String.class)); clothesSocialMuse.setPatternImage(parse.getByPath("file", String.class)); } model.addAttribute("socialMuse", clothesSocialMuse); return FebsUtil.view("modules/clothesType/socialMuseUpdate"); src/main/java/cc/mrbird/febs/mall/dto/clothes/ApiAllSocialDto.java
New file @@ -0,0 +1,26 @@ package cc.mrbird.febs.mall.dto.clothes; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "ApiAllSocialDto", description = "参数") public class ApiAllSocialDto { @NotNull(message = "页码不能为空") @ApiModelProperty(value = "页码", example = "1") private Integer pageNow; @NotNull(message = "每页数量不能为空") @ApiModelProperty(value = "每页数量", example = "10") private Integer pageSize; @NotNull(message = "分类不能为空") @ApiModelProperty(value = "分类ID,查询全部传0") private Long categoryId; } src/main/java/cc/mrbird/febs/mall/dto/clothes/ApiClothesSocialMuseDto.java
New file @@ -0,0 +1,16 @@ package cc.mrbird.febs.mall.dto.clothes; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "ApiClothesSocialMuseDto", description = "参数") public class ApiClothesSocialMuseDto { @NotNull(message = "灵感不能为空") @ApiModelProperty(value = "灵感ID") private Long museId; } src/main/java/cc/mrbird/febs/mall/dto/clothes/ApiSocialAddDto.java
New file @@ -0,0 +1,33 @@ package cc.mrbird.febs.mall.dto.clothes; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.util.List; @Data @ApiModel(value = "ApiSocialAddDto", description = "参数") public class ApiSocialAddDto { @NotNull(message = "订单不能为空") @ApiModelProperty(value = "订单ID") private Long orderId; @NotBlank(message = "标题不能为空") @ApiModelProperty(value = "标题") private String title; @NotBlank(message = "封面不能为空") @ApiModelProperty(value = "封面") private String indexFile; @Size(min = 1, message = "正文图片最少一张") @Size(max = 6, message = "正文图片最多六张") @ApiModelProperty(value = "正文图片") private List<String> contentFile; @NotEmpty(message = "正文不能为空") @ApiModelProperty(value = "正文") private String content; } src/main/java/cc/mrbird/febs/mall/dto/clothes/ApiSocialCollectAddDto.java
New file @@ -0,0 +1,16 @@ package cc.mrbird.febs.mall.dto.clothes; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "ApiSocialCollectAddDto", description = "参数") public class ApiSocialCollectAddDto { @NotNull(message = "社区不能为空") @ApiModelProperty(value = "社区ID") private Long socialId; } src/main/java/cc/mrbird/febs/mall/dto/clothes/ApiSocialCommentLikeAddDto.java
New file @@ -0,0 +1,20 @@ package cc.mrbird.febs.mall.dto.clothes; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "ApiSocialCommentLikeAddDto", description = "参数") public class ApiSocialCommentLikeAddDto { @NotNull(message = "社区不能为空") @ApiModelProperty(value = "社区ID") private Long socialId; @NotNull(message = "评论ID不能为空") @ApiModelProperty(value = "评论ID") private Long commentId; } src/main/java/cc/mrbird/febs/mall/dto/clothes/ApiSocialInfoDto.java
New file @@ -0,0 +1,17 @@ package cc.mrbird.febs.mall.dto.clothes; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "ApiMyDraftSaveDto", description = "参数") public class ApiSocialInfoDto { @NotNull(message = "社区不能为空") @ApiModelProperty(value = "社区ID") private Long socialId; } src/main/java/cc/mrbird/febs/mall/dto/clothes/ApiSocialLikeAddDto.java
New file @@ -0,0 +1,16 @@ package cc.mrbird.febs.mall.dto.clothes; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "ApiSocialLikeAddDto", description = "参数") public class ApiSocialLikeAddDto { @NotNull(message = "社区不能为空") @ApiModelProperty(value = "社区ID") private Long socialId; } src/main/java/cc/mrbird/febs/mall/entity/ClothesOrderItem.java
@@ -22,6 +22,7 @@ */ private Long memberId; private Long orderId; private Long itemId; private String name; private BigDecimal price; private Integer itemCnt; src/main/java/cc/mrbird/febs/mall/entity/ClothesSocialComment.java
New file @@ -0,0 +1,24 @@ package cc.mrbird.febs.mall.entity; import cc.mrbird.febs.common.entity.BaseEntity; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @Data @TableName("clothes_social_comment") public class ClothesSocialComment extends BaseEntity { /** * `member_id` bigint(20) DEFAULT NULL, `social_id` bigint(20) DEFAULT NULL COMMENT '来源ID', `parent_id` bigint(20) DEFAULT NULL COMMENT '来源选项ID', `comment` text COMMENT '评论', `show_state` int(11) DEFAULT '0' COMMENT '展示状态 1:显示 0:隐藏', */ private Long memberId; private Long socialId; private Long parentId; private String comment; private Integer showState; } src/main/java/cc/mrbird/febs/mall/entity/ClothesSocialFollow.java
New file @@ -0,0 +1,23 @@ package cc.mrbird.febs.mall.entity; import cc.mrbird.febs.common.entity.BaseEntity; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @Data @TableName("clothes_social_follow") public class ClothesSocialFollow extends BaseEntity { /** * `member_id` bigint(20) DEFAULT NULL, `source_type` int(11) DEFAULT NULL COMMENT '来源类型 1-社区 2-评论', `source_id` bigint(20) DEFAULT NULL COMMENT '来源ID', `source_option_id` bigint(20) DEFAULT NULL COMMENT '来源选项ID', `type` int(11) DEFAULT NULL COMMENT '操作类型 1-关注 2-点赞', */ private Long memberId; private Integer sourceType; private Long sourceId; private Long sourceOptionId; private Integer type; } src/main/java/cc/mrbird/febs/mall/entity/ClothesSocialMuse.java
@@ -1,6 +1,7 @@ package cc.mrbird.febs.mall.entity; import cc.mrbird.febs.common.entity.BaseEntity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -24,6 +25,14 @@ private Long statureId; private Long sizeId; private Long patternId; private String patternRemark; private Long locationId; private Long clothId; @TableField(exist = false) private String patternText; @TableField(exist = false) private String patternImage; } src/main/java/cc/mrbird/febs/mall/mapper/ClothesSocialCommentMapper.java
New file @@ -0,0 +1,7 @@ package cc.mrbird.febs.mall.mapper; import cc.mrbird.febs.mall.entity.ClothesSocialComment; import com.baomidou.mybatisplus.core.mapper.BaseMapper; public interface ClothesSocialCommentMapper extends BaseMapper<ClothesSocialComment> { } src/main/java/cc/mrbird/febs/mall/mapper/ClothesSocialFollowMapper.java
New file @@ -0,0 +1,7 @@ package cc.mrbird.febs.mall.mapper; import cc.mrbird.febs.mall.entity.ClothesSocialFollow; import com.baomidou.mybatisplus.core.mapper.BaseMapper; public interface ClothesSocialFollowMapper extends BaseMapper<ClothesSocialFollow> { } src/main/java/cc/mrbird/febs/mall/mapper/ClothesSocialMapper.java
@@ -1,8 +1,10 @@ package cc.mrbird.febs.mall.mapper; import cc.mrbird.febs.mall.dto.clothes.AdminClothesSocialListDto; import cc.mrbird.febs.mall.dto.clothes.ApiAllSocialDto; import cc.mrbird.febs.mall.entity.ClothesSocial; import cc.mrbird.febs.mall.vo.clothes.AdminClothesSocialListVo; import cc.mrbird.febs.mall.vo.clothes.ApiAllSocialVo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -11,4 +13,6 @@ public interface ClothesSocialMapper extends BaseMapper<ClothesSocial> { IPage<AdminClothesSocialListVo> selectSocialListInPage(Page<AdminClothesSocialListVo> page, @Param("record")AdminClothesSocialListDto dto); Page<ApiAllSocialVo> selectPageInSocial(Page<ApiAllSocialVo> page, @Param("record")ApiAllSocialDto dto); } src/main/java/cc/mrbird/febs/mall/service/ApiClothesSocialService.java
@@ -1,6 +1,7 @@ package cc.mrbird.febs.mall.service; import cc.mrbird.febs.common.entity.FebsResponse; import cc.mrbird.febs.mall.dto.clothes.*; import cc.mrbird.febs.mall.entity.ClothesSocial; import com.baomidou.mybatisplus.extension.service.IService; @@ -8,4 +9,18 @@ FebsResponse allCategory(); FebsResponse indexCategory(); FebsResponse allSocial(ApiAllSocialDto dto); FebsResponse socialInfo(ApiSocialInfoDto dto); FebsResponse socialAdd(ApiSocialAddDto dto); FebsResponse addLike(ApiSocialLikeAddDto dto); FebsResponse addCommentLike(ApiSocialCommentLikeAddDto dto); FebsResponse addCollect(ApiSocialCollectAddDto dto); FebsResponse museToDesign(ApiClothesSocialMuseDto dto); } src/main/java/cc/mrbird/febs/mall/service/impl/ApiClothesOrderServiceImpl.java
@@ -387,6 +387,7 @@ if (ObjectUtil.isNull(cloth)) { throw new FebsException("请选择布料"); } orderItem.setItemId(cloth.getId()); orderItem.setName(cloth.getName()); orderItem.setPrice(cloth.getPrice()); orderItem.setItemCnt(item.getCnt()); @@ -400,6 +401,7 @@ if (ObjectUtil.isNull(size)) { throw new FebsException("请选择尺寸"); } orderItem.setItemId(size.getId()); orderItem.setName(size.getName()); orderItem.setPrice(size.getPrice()); orderItem.setItemCnt(item.getCnt()); @@ -413,6 +415,7 @@ if (ObjectUtil.isNull(location)) { throw new FebsException("请选择图案位置"); } orderItem.setItemId(location.getId()); orderItem.setName(location.getName()); orderItem.setPrice(location.getPrice()); orderItem.setItemCnt(item.getCnt()); @@ -426,6 +429,7 @@ if (ObjectUtil.isNull(pattern)) { throw new FebsException("请选择图案"); } orderItem.setItemId(pattern.getId()); orderItem.setRemark(item.getPatternRemark()); orderItem.setName(pattern.getName()); orderItem.setPrice(pattern.getPrice()); @@ -440,6 +444,7 @@ if (ObjectUtil.isNull(art)) { throw new FebsException("请选择工艺"); } orderItem.setItemId(art.getId()); orderItem.setName(art.getName()); orderItem.setPrice(art.getPrice()); orderItem.setItemCnt(item.getCnt()); @@ -450,6 +455,7 @@ continue; } else if (ClothesOrderItemEnum.CUSTOMIZE.getCode() == item.getType()) { ClothesMemberStature clothesMemberStature = clothesMemberStatureMapper.selectById(item.getSkuId()); orderItem.setItemId(clothesMemberStature.getId()); orderItem.setName(clothesMemberStature.getName()); orderItem.setPrice(BigDecimal.ZERO); orderItem.setItemCnt(item.getCnt()); src/main/java/cc/mrbird/febs/mall/service/impl/ApiClothesSocialServiceImpl.java
@@ -1,26 +1,35 @@ package cc.mrbird.febs.mall.service.impl; import cc.mrbird.febs.common.entity.FebsResponse; import cc.mrbird.febs.common.enumerates.ClothesEnum; import cc.mrbird.febs.common.enumerates.StateUpDownEnum; import cc.mrbird.febs.mall.entity.ClothesSocial; import cc.mrbird.febs.mall.entity.ClothesSocialCategory; import cc.mrbird.febs.mall.entity.HappySocialCircleCategory; import cc.mrbird.febs.mall.mapper.ClothesSocialCategoryMapper; import cc.mrbird.febs.mall.mapper.ClothesSocialMapper; import cc.mrbird.febs.common.enumerates.*; import cc.mrbird.febs.common.exception.FebsException; import cc.mrbird.febs.common.utils.LoginUserUtil; import cc.mrbird.febs.mall.dto.clothes.*; import cc.mrbird.febs.mall.entity.*; import cc.mrbird.febs.mall.mapper.*; import cc.mrbird.febs.mall.service.ApiClothesSocialService; import cc.mrbird.febs.mall.vo.activity.ApiScCategoryInfoVo; import cc.mrbird.febs.mall.vo.clothes.ApiClothesCategoryInfoVo; import cc.mrbird.febs.mall.vo.clothes.*; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSON; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @Slf4j @Service @@ -28,7 +37,29 @@ public class ApiClothesSocialServiceImpl extends ServiceImpl<ClothesSocialMapper, ClothesSocial> implements ApiClothesSocialService { private final ClothesSocialMapper clothesSocialMapper; private final ClothesSocialFileMapper clothesSocialFileMapper; private final ClothesSocialMuseMapper clothesSocialMuseMapper; private final ClothesSocialCategoryMapper clothesSocialCategoryMapper; private final MallMemberMapper mallMemberMapper; private final ClothesTypeMapper clothesTypeMapper; private final ClothesSizeMapper clothesSizeMapper; private final ClothesPatternMapper clothesPatternMapper; private final ClothesLocationMapper clothesLocationMapper; private final ClothesClothMapper clothesClothMapper; private final ClothesArtMapper clothesArtMapper; private final ClothesOrderMapper clothesOrderMapper; private final ClothesOrderItemMapper clothesOrderItemMapper; private final ClothesSocialFollowMapper clothesSocialFollowMapper; private final ClothesTypeClothMapper clothesTypeClothMapper; private final ClothesTypePatternMapper clothesTypePatternMapper; private final ClothesTypeSizeMapper clothesTypeSizeMapper; private final ClothesTypeLocationMapper clothesTypeLocationMapper; private final ClothesTypeArtMapper clothesTypeArtMapper; @Override public FebsResponse allCategory() { @@ -72,4 +103,331 @@ } return new FebsResponse().success().data(vos); } @Override public FebsResponse allSocial(ApiAllSocialDto dto) { // 创建分页对象,传入当前页和每页大小 Page<ApiAllSocialVo> page = new Page<>(dto.getPageNow(), dto.getPageSize()); // 调用Mapper方法获取活动分页数据 Page<ApiAllSocialVo> voPage = clothesSocialMapper.selectPageInSocial(page, dto); return new FebsResponse().success().data(voPage); } @Override public FebsResponse socialInfo(ApiSocialInfoDto dto) { ApiSocialInfoVo apiSocialInfoVo = new ApiSocialInfoVo(); Long socialId = dto.getSocialId(); ClothesSocial clothesSocial = clothesSocialMapper.selectById(socialId); if(ObjectUtil.isNotNull(clothesSocial)){ MallMember mallMember = mallMemberMapper.selectById(clothesSocial.getMemberId()); apiSocialInfoVo.setId(clothesSocial.getId()); apiSocialInfoVo.setMemberName(mallMember.getName()); apiSocialInfoVo.setMemberAvatar(mallMember.getAvatar()); apiSocialInfoVo.setName(clothesSocial.getName()); apiSocialInfoVo.setContent(clothesSocial.getContent()); apiSocialInfoVo.setCreatedTime(clothesSocial.getCreatedTime()); List<ClothesSocialFile> clothesSocialFiles = clothesSocialFileMapper.selectList( Wrappers.lambdaQuery(ClothesSocialFile.class) .select(ClothesSocialFile::getFileUrl) .eq(ClothesSocialFile::getSocialId, socialId) .orderByAsc(ClothesSocialFile::getSeq) ); if(CollUtil.isNotEmpty(clothesSocialFiles)){ apiSocialInfoVo.setImages(clothesSocialFiles.stream().map(ClothesSocialFile::getFileUrl).collect(Collectors.toList())); } ApiSocialMuseVo apiSocialMuseVo = new ApiSocialMuseVo(); ClothesSocialMuse clothesSocialMuse = clothesSocialMuseMapper.selectOne( Wrappers.lambdaQuery(ClothesSocialMuse.class) .eq(ClothesSocialMuse::getSocialId, socialId) .last("LIMIT 1") ); if(ObjectUtil.isNotNull(clothesSocialMuse)){ BigDecimal totalAmount = BigDecimal.ZERO; apiSocialMuseVo.setMuseId(clothesSocialMuse.getId()); apiSocialMuseVo.setPatternImage(clothesSocialMuse.getPatternImage()); apiSocialMuseVo.setPatternText(clothesSocialMuse.getPatternText()); ClothesType clothesType = clothesTypeMapper.selectById(clothesSocialMuse.getTypeId()); if(ObjectUtil.isNotNull(clothesType)){ apiSocialMuseVo.setTypeName(clothesType.getName()); apiSocialMuseVo.setTypeImg(clothesType.getImage()); } ClothesSize clothesSize = clothesSizeMapper.selectById(clothesSocialMuse.getSizeId()); if(ObjectUtil.isNotNull(clothesSize)){ apiSocialMuseVo.setSizeName(clothesSize.getName()); totalAmount = totalAmount.add(clothesSize.getPrice()); } ClothesPattern clothesPattern = clothesPatternMapper.selectById(clothesSocialMuse.getPatternId()); if(ObjectUtil.isNotNull(clothesPattern)){ apiSocialMuseVo.setPatternName(clothesPattern.getName()); totalAmount = totalAmount.add(clothesPattern.getPrice()); } ClothesLocation clothesLocation = clothesLocationMapper.selectById(clothesSocialMuse.getLocationId()); if(ObjectUtil.isNotNull(clothesLocation)){ apiSocialMuseVo.setLocationName(clothesLocation.getName()); totalAmount = totalAmount.add(clothesLocation.getPrice()); } ClothesCloth clothesCloth = clothesClothMapper.selectById(clothesSocialMuse.getClothId()); if(ObjectUtil.isNotNull(clothesCloth)){ apiSocialMuseVo.setClothName(clothesCloth.getName()); totalAmount = totalAmount.add(clothesCloth.getPrice()); } ClothesArt clothesArt = clothesArtMapper.selectById(clothesSocialMuse.getArtId()); if(ObjectUtil.isNotNull(clothesArt)){ apiSocialMuseVo.setArtName(clothesArt.getName()); totalAmount = totalAmount.add(clothesArt.getPrice()); } apiSocialMuseVo.setTotalAmount(totalAmount.setScale(2, RoundingMode.DOWN)); } } return new FebsResponse().success().data(apiSocialInfoVo); } @Override @Transactional public FebsResponse socialAdd(ApiSocialAddDto dto) { Long memberId = LoginUserUtil.getLoginUser().getId(); Long orderId = dto.getOrderId(); ClothesOrder order = clothesOrderMapper.selectOne( Wrappers.lambdaQuery(ClothesOrder.class) .eq(ClothesOrder::getId, orderId) .eq(ClothesOrder::getMemberId, memberId) ); if(ObjectUtil.isNull( order)){ throw new FebsException("请选择订单"); } if(ClothesOrderStatusEnum.FINISH.getValue() != order.getStatus()){ throw new FebsException("订单未确认收货"); } String content = dto.getContent(); List<String> contentFile = dto.getContentFile(); String indexFile = dto.getIndexFile(); String title = dto.getTitle(); ClothesSocial clothesSocial = new ClothesSocial(); clothesSocial.setMemberId(memberId); clothesSocial.setName(title); clothesSocial.setContent(content); clothesSocial.setIndexFile(indexFile); clothesSocialMapper.insert(clothesSocial); if(CollUtil.isNotEmpty(contentFile)){ int i = 0; for (String file : contentFile){ ClothesSocialFile clothesSocialFile = new ClothesSocialFile(); clothesSocialFile.setSocialId(clothesSocial.getId()); clothesSocialFile.setFileUrl(file); clothesSocialFile.setSeq(i); clothesSocialFileMapper.insert(clothesSocialFile); i++; } } ClothesSocialMuse clothesSocialMuse = new ClothesSocialMuse(); clothesSocialMuse.setSocialId(clothesSocial.getId()); clothesSocialMuse.setTypeId(order.getTypeId()); List<ClothesOrderItem> clothesOrderItems = clothesOrderItemMapper.selectList( Wrappers.lambdaQuery(ClothesOrderItem.class) .eq(ClothesOrderItem::getOrderId, orderId) ); if(CollUtil.isEmpty(clothesOrderItems)){ for (ClothesOrderItem item : clothesOrderItems){ if (ClothesOrderItemEnum.CLOTH.getCode() == item.getType()) { ClothesCloth cloth = clothesClothMapper.selectById(item.getItemId()); clothesSocialMuse.setClothId(cloth.getId()); continue; } else if (ClothesOrderItemEnum.SIZE.getCode() == item.getType()) { ClothesSize size = clothesSizeMapper.selectById(item.getItemId()); clothesSocialMuse.setSizeId(size.getId()); continue; } else if (ClothesOrderItemEnum.LOCATION.getCode() == item.getType()) { ClothesLocation location = clothesLocationMapper.selectById(item.getItemId()); clothesSocialMuse.setLocationId(location.getId()); continue; } else if (ClothesOrderItemEnum.PATTERN.getCode() == item.getType()) { ClothesPattern pattern = clothesPatternMapper.selectById(item.getItemId()); clothesSocialMuse.setPatternId(pattern.getId()); clothesSocialMuse.setPatternRemark(item.getRemark()); continue; } else if (ClothesOrderItemEnum.ART.getCode() == item.getType()) { ClothesArt art = clothesArtMapper.selectById(item.getItemId()); clothesSocialMuse.setArtId(art.getId()); continue; }else{ continue; } } } clothesSocialMuseMapper.insert(clothesSocialMuse); return new FebsResponse().success().message("操作成功"); } @Override public FebsResponse addLike(ApiSocialLikeAddDto dto) { Long memberId = LoginUserUtil.getLoginUser().getId(); Long socialId = dto.getSocialId(); ClothesSocial clothesSocial = clothesSocialMapper.selectById(socialId); if(ObjectUtil.isNotNull(clothesSocial)){ ClothesSocialFollow clothesSocialFollow = new ClothesSocialFollow(); clothesSocialFollow.setMemberId(memberId); clothesSocialFollow.setSourceType(SocialSourceTypeEnum.SOCIAL.getValue()); clothesSocialFollow.setSourceId(socialId); clothesSocialFollow.setType(SocialTypeEnum.LIKE.getValue()); clothesSocialFollowMapper.insert(clothesSocialFollow); } return new FebsResponse().success().message("操作成功"); } @Override public FebsResponse addCommentLike(ApiSocialCommentLikeAddDto dto) { Long memberId = LoginUserUtil.getLoginUser().getId(); Long socialId = dto.getSocialId(); ClothesSocial clothesSocial = clothesSocialMapper.selectById(socialId); if(ObjectUtil.isNotNull(clothesSocial)){ ClothesSocialFollow clothesSocialFollow = new ClothesSocialFollow(); clothesSocialFollow.setMemberId(memberId); clothesSocialFollow.setSourceType(SocialSourceTypeEnum.COMMENT.getValue()); clothesSocialFollow.setSourceId(socialId); clothesSocialFollow.setSourceOptionId(dto.getCommentId()); clothesSocialFollow.setType(SocialTypeEnum.LIKE.getValue()); clothesSocialFollowMapper.insert(clothesSocialFollow); } return new FebsResponse().success().message("操作成功"); } @Override public FebsResponse addCollect(ApiSocialCollectAddDto dto) { Long memberId = LoginUserUtil.getLoginUser().getId(); Long socialId = dto.getSocialId(); ClothesSocial clothesSocial = clothesSocialMapper.selectById(socialId); if(ObjectUtil.isNotNull(clothesSocial)){ ClothesSocialFollow clothesSocialFollow = new ClothesSocialFollow(); clothesSocialFollow.setMemberId(memberId); clothesSocialFollow.setSourceType(SocialSourceTypeEnum.SOCIAL.getValue()); clothesSocialFollow.setSourceId(socialId); clothesSocialFollow.setType(SocialTypeEnum.COLLECT.getValue()); clothesSocialFollowMapper.insert(clothesSocialFollow); } return new FebsResponse().success().message("操作成功"); } @Override public FebsResponse museToDesign(ApiClothesSocialMuseDto dto) { Long memberId = LoginUserUtil.getLoginUser().getId(); ApiClothesSocialMuseVo record = new ApiClothesSocialMuseVo(); Long id = dto.getMuseId(); ClothesSocialMuse entity = clothesSocialMuseMapper.selectById(id); if (ObjectUtil.isNotNull(entity)){ Long typeId = entity.getTypeId(); ClothesType clothesType = clothesTypeMapper.selectById(typeId); record.setTypeId(typeId); record.setTypeName(clothesType.getName()); record.setTypeImage(clothesType.getImage()); record.setPatternRemark(entity.getPatternRemark()); Long sizeId = ObjectUtil.defaultIfNull(entity.getSizeId(),0L); List<ClothesTypeSize> clothesTypeSizes = clothesTypeSizeMapper.selectList(Wrappers.<ClothesTypeSize>lambdaQuery().eq(ClothesTypeSize::getTypeId, typeId)); if (CollUtil.isNotEmpty(clothesTypeSizes)){ Set<Long> collect = clothesTypeSizes.stream().map(ClothesTypeSize::getSizeId).collect(Collectors.toSet()); if(CollUtil.isNotEmpty( collect) && collect.contains(sizeId)){ ClothesSize clothesSize = clothesSizeMapper.selectById(sizeId); if(ObjectUtil.isNotNull(clothesSize)){ record.setSizeId(sizeId); record.setSizeName(clothesSize.getName()); record.setSizePrice(clothesSize.getPrice()); } } } Long patternId = ObjectUtil.defaultIfNull(entity.getPatternId(),0L); List<ClothesTypePattern> clothesTypePatterns = clothesTypePatternMapper.selectList(Wrappers.<ClothesTypePattern>lambdaQuery().eq(ClothesTypePattern::getTypeId, typeId)); if (CollUtil.isNotEmpty(clothesTypePatterns)){ Set<Long> patternIds = clothesTypePatterns.stream().map(ClothesTypePattern::getPatternId).collect(Collectors.toSet()); if(CollUtil.isNotEmpty( patternIds) && patternIds.contains(patternId)){ ClothesPattern clothesPattern = clothesPatternMapper.selectById(patternId); if (ObjectUtil.isNotNull(clothesPattern)){ record.setPatternId(patternId); record.setPatternName(clothesPattern.getName()); record.setPatternPrice(clothesPattern.getPrice()); } } } Long locationId = ObjectUtil.defaultIfNull(entity.getLocationId(),0L); List<ClothesTypeLocation> clothesTypeLocations = clothesTypeLocationMapper.selectList(Wrappers.<ClothesTypeLocation>lambdaQuery().eq(ClothesTypeLocation::getTypeId, typeId)); if (CollUtil.isNotEmpty(clothesTypeLocations)){ Set<Long> locationIds = clothesTypeLocations.stream().map(ClothesTypeLocation::getLocationId).collect(Collectors.toSet()); if(CollUtil.isNotEmpty( locationIds) && locationIds.contains(locationId)){ ClothesLocation clothesLocation = clothesLocationMapper.selectById(locationId); if (ObjectUtil.isNotNull(clothesLocation)){ record.setLocationId(locationId); record.setLocationName(clothesLocation.getName()); record.setLocationPrice(clothesLocation.getPrice()); } } } Long artId = ObjectUtil.defaultIfNull(entity.getArtId(),0L); List<ClothesTypeArt> clothesTypeArts = clothesTypeArtMapper.selectList(Wrappers.lambdaQuery(ClothesTypeArt.class).eq(ClothesTypeArt::getTypeId, typeId)); if(CollUtil.isNotEmpty(clothesTypeArts)){ Set<Long> artIds = clothesTypeArts.stream().map(ClothesTypeArt::getArtId).collect(Collectors.toSet()); if (CollUtil.isNotEmpty(artIds) && artIds.contains(artId)){ ClothesArt clothesArt = clothesArtMapper.selectById(artId); if (ObjectUtil.isNotNull(clothesArt)){ record.setArtId(artId); record.setArtName(clothesArt.getName()); record.setArtPrice(clothesArt.getPrice()); } } } Long clothId = ObjectUtil.defaultIfNull(entity.getClothId(),0L); List<ClothesTypeCloth> clothesTypeCloths = clothesTypeClothMapper.selectList(Wrappers.lambdaQuery(ClothesTypeCloth.class).eq(ClothesTypeCloth::getTypeId, typeId)); if(CollUtil.isNotEmpty(clothesTypeCloths)){ Set<Long> clothIds = clothesTypeCloths.stream().map(ClothesTypeCloth::getClothId).collect(Collectors.toSet()); if (CollUtil.isNotEmpty(clothIds) && clothIds.contains(clothId)){ ClothesCloth clothesCloth = clothesClothMapper.selectById(clothId); if (ObjectUtil.isNotNull(clothesCloth)){ record.setClothId(clothId); record.setClothName(clothesCloth.getName()); record.setClothPrice(clothesCloth.getPrice()); } } } BigDecimal amount = record.getClothPrice() .add(record.getLocationPrice()) .add(record.getArtPrice()) .add(record.getSizePrice()) .add(record.getPatternPrice()).setScale(2, RoundingMode.DOWN); record.setAmount(amount); } return new FebsResponse().success().data(record); } public static void main(String[] args) { JSONObject jsonObject = new JSONObject(); jsonObject.putByPath("text", "123"); jsonObject.putByPath("file", "https://excoin.oss-cn-hangzhou.aliyuncs.com/hc/175196952995698f416e2e70648328d04364340c3a36d.png"); String jsonStr = jsonObject.toString(); System.out.println(jsonStr); } } src/main/java/cc/mrbird/febs/mall/service/impl/ClothesTypeServiceImpl.java
@@ -24,6 +24,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -1049,6 +1050,12 @@ entity.setSizeId(dto.getSizeId()); entity.setPatternId(dto.getPatternId()); entity.setArtId(dto.getArtId()); JSONObject jsonObject = new JSONObject(); jsonObject.putByPath("text", dto.getPatternText()); jsonObject.putByPath("file", dto.getPatternImage()); entity.setPatternRemark(jsonObject.toString()); clothesSocialMuseMapper.updateById(entity); } src/main/java/cc/mrbird/febs/mall/vo/clothes/ApiAllSocialVo.java
New file @@ -0,0 +1,22 @@ package cc.mrbird.febs.mall.vo.clothes; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "ApiAllSocialVo", description = "参数") public class ApiAllSocialVo { @ApiModelProperty(value = "id") private Long id; @ApiModelProperty(value = "用户") private String memberName; @ApiModelProperty(value = "头像") private String memberAvatar; @ApiModelProperty(value = "标题") private String name; @ApiModelProperty(value = "封面") private String indexFile; } src/main/java/cc/mrbird/febs/mall/vo/clothes/ApiClothesSocialMuseVo.java
New file @@ -0,0 +1,63 @@ package cc.mrbird.febs.mall.vo.clothes; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; @Data @ApiModel(value = "ApiClothesSocialMuseVo", description = "参数") public class ApiClothesSocialMuseVo { @ApiModelProperty(value = "灵感ID") private Long id; @ApiModelProperty(value = "总价") private BigDecimal amount = BigDecimal.ZERO; @ApiModelProperty(value = "类型ID") private Long typeId; @ApiModelProperty(value = "类型名称") private String typeName; @ApiModelProperty(value = "类型图片") private String typeImage; @ApiModelProperty(value = "工艺ID") private Long artId; @ApiModelProperty(value = "工艺名称") private String artName; @ApiModelProperty(value = "工艺价格") private BigDecimal artPrice = BigDecimal.ZERO; @ApiModelProperty(value = "尺码ID") private Long sizeId; @ApiModelProperty(value = "尺码名称") private String sizeName; @ApiModelProperty(value = "尺码价格") private BigDecimal sizePrice = BigDecimal.ZERO; @ApiModelProperty(value = "图案ID") private Long patternId; @ApiModelProperty(value = "图案名称") private String patternName; @ApiModelProperty(value = "图案价格") private BigDecimal patternPrice = BigDecimal.ZERO; @ApiModelProperty(value = "自定义内容") private String patternRemark; @ApiModelProperty(value = "图案位置ID") private Long locationId; @ApiModelProperty(value = "图案位置") private String locationName; @ApiModelProperty(value = "图案位置价格") private BigDecimal locationPrice = BigDecimal.ZERO; @ApiModelProperty(value = "布料ID") private Long clothId; @ApiModelProperty(value = "布料名称") private String clothName; @ApiModelProperty(value = "布料价格") private BigDecimal clothPrice = BigDecimal.ZERO; } src/main/java/cc/mrbird/febs/mall/vo/clothes/ApiSocialInfoVo.java
New file @@ -0,0 +1,36 @@ package cc.mrbird.febs.mall.vo.clothes; import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; import java.util.List; @Data @ApiModel(value = "ApiSocialInfoVo", description = "参数") public class ApiSocialInfoVo { @ApiModelProperty(value = "社区ID") private Long id; @ApiModelProperty(value = "用户") private String memberName; @ApiModelProperty(value = "头像") private String memberAvatar; @ApiModelProperty(value = "标题") private String name; @ApiModelProperty(value = "内容") private String content; @ApiModelProperty(value = "创建时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createdTime; @ApiModelProperty(value = "内容图集") private List<String> images; @ApiModelProperty(value = "我的灵感") private ApiSocialMuseVo muse; } src/main/java/cc/mrbird/febs/mall/vo/clothes/ApiSocialMuseVo.java
New file @@ -0,0 +1,39 @@ package cc.mrbird.febs.mall.vo.clothes; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; @Data @ApiModel(value = "ApiSocialMuseVo", description = "参数") public class ApiSocialMuseVo { @ApiModelProperty(value = "灵感ID") private Long museId ; @ApiModelProperty(value = "价格") private BigDecimal totalAmount; @ApiModelProperty(value = "设计类型") private String typeName; @ApiModelProperty(value = "设计类型图片") private String typeImg; @ApiModelProperty(value = "工艺名称") private String artName; @ApiModelProperty(value = "尺码名称") private String sizeName; @ApiModelProperty(value = "图案名称") private String patternName; @ApiModelProperty(value = "图案图片内容") private String patternImage; @ApiModelProperty(value = "图案文案内容") private String patternText; @ApiModelProperty(value = "图案位置名称") private String locationName; @ApiModelProperty(value = "布料名称") private String clothName; } src/main/resources/mapper/modules/ClothesSocialCommentMapper.xml
New file @@ -0,0 +1,6 @@ <?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="cc.mrbird.febs.mall.mapper.ClothesSocialCommentMapper"> </mapper> src/main/resources/mapper/modules/ClothesSocialFollowMapper.xml
New file @@ -0,0 +1,6 @@ <?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="cc.mrbird.febs.mall.mapper.ClothesSocialFollowMapper"> </mapper> src/main/resources/mapper/modules/ClothesSocialMapper.xml
@@ -31,4 +31,25 @@ order by a.order_cnt asc, a.created_time desc </select> <select id="selectPageInSocial" resultType="cc.mrbird.febs.mall.vo.clothes.ApiAllSocialVo"> select b.name as memberName, b.avatar as memberAvatar, a.id as id, a.name as name, a.index_file as indexFile from clothes_social a left join mall_member b on a.member_id = b.id <where> and a.state = 1 and a.del_flag = 0 <if test="record != null"> <if test="record.categoryId != 0"> and a.category_id = #{record.categoryId} </if> </if> </where> order by a.hot_state desc, a.created_time desc </select> </mapper> src/main/resources/templates/febs/views/modules/clothesType/socialMuseUpdate.html
@@ -36,6 +36,39 @@ </div> </div> <div class="layui-row layui-col-space10 layui-form-item"> <div class="layui-col-lg6"> <label class="layui-form-label">图案-文字:</label> <div class="layui-input-block"> <input type="text" name="patternText" placeholder="" autocomplete="off" class="layui-input"> </div> </div> </div> <div class="layui-row layui-col-space10 layui-form-item"> <div class="layui-col-lg6"> <label class="layui-form-label">图案-图片:</label> <div class="layui-input-block"> <div class="layui-upload"> <button type="button" class="layui-btn layui-btn-normal layui-btn" id="patternImageUploadButton">上传</button> <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;"> <div class="layui-upload-list" id="patternImageUpload"></div> </blockquote> </div> </div> </div> </div> <div class="layui-row layui-col-space10 layui-form-item febs-hide"> <div class="layui-col-lg6"> <label class="layui-form-label">图案:</label> <div class="layui-input-block"> <input type="text" id="patternImage" name="patternImage" autocomplete="off" class="layui-input" readonly> </div> </div> </div> <div class="layui-row layui-col-space10 layui-form-item"> <div class="layui-col-lg6"> <label class="layui-form-label febs-form-item-require">位置:</label> @@ -107,6 +140,23 @@ formSelects.render(); //图片上传 upload.render({ elem: '#patternImageUploadButton' ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 ,accept: 'file' //普通文件 ,size: 10240 //限制文件大小,单位 KB ,before: function(obj){ //预读本地文件示例,不支持ie8 obj.preview(function(index, file, result){ $('#patternImageUpload').html('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img single-image" style="width: 130px">') }); } ,done: function(res){ $("#patternImage").val(res.data.src); } }); let scArt = xmSelect.render({ el: '#sc-art', @@ -266,8 +316,13 @@ form.val("sc-muse-update-form", { "id": socialMuse.id, "patternImage": socialMuse.patternImage, "patternText": socialMuse.patternText, }); $('#patternImageUpload').append('<img src="' + socialMuse.patternImage + '" alt="" class="layui-upload-img single-image" style="width: 130px">'); $("#patternImage").val(socialMuse.patternImage); var artList = []; artList.push(socialMuse.artId); scArt.setValue(artList);