diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java index 61f629b..883cb2e 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java @@ -5,6 +5,7 @@ import com.mcwl.common.core.controller.BaseController; import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.common.domain.IdsParam; +import com.mcwl.common.utils.SecurityUtils; import com.mcwl.resource.domain.MallProduct; import com.mcwl.resource.domain.vo.MallProductVo; import com.mcwl.resource.service.MallProductService; @@ -111,6 +112,7 @@ public class MallProductController extends BaseController { @PostMapping("/add") public AjaxResult add(@RequestBody MallProduct mallProduct) { + mallProduct.setUserId(SecurityUtils.getUserId()); mallProduct.setCreateBy(getUsername()); return toAjax(mallProductRuleInfoService.insertMallProduct(mallProduct)); } diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductLikeController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductLikeController.java index 7b33849..844e024 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductLikeController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductLikeController.java @@ -1,6 +1,7 @@ package com.mcwl.web.controller.resource; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mcwl.common.annotation.RepeatSubmit; import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.resource.domain.MallProduct; import com.mcwl.resource.domain.vo.MallProductVo; @@ -22,10 +23,41 @@ public class MallProductLikeController { @Autowired private MallProductLikeService mallProductLikeService; + /** + * 查询用户点赞作品列表 + * @param mallProductVo + * @return + */ @PostMapping("/selectByUserLike") public AjaxResult selectByUserLike(@RequestBody MallProductVo mallProductVo){ Page mallProductPage = mallProductLikeService.selectByUserLike(mallProductVo); return AjaxResult.success(mallProductPage); } + + /** + * 添加/删除点赞商品 + * @param productId + * @return + */ + @RepeatSubmit + @GetMapping("/addLike") + public AjaxResult addLike(@RequestParam Long productId){ + + return mallProductLikeService.addLike(productId); + } + + /** + * 查看作品是否点赞 + * @param productId + * @return + */ + @GetMapping("/selectLike") + public AjaxResult selectLike(@RequestParam Long productId){ + Boolean aBoolean = mallProductLikeService.selectLike(productId); + return AjaxResult.success(aBoolean); + } + + + } diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/SysUserAttentionController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/SysUserAttentionController.java new file mode 100644 index 0000000..8a97096 --- /dev/null +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/SysUserAttentionController.java @@ -0,0 +1,65 @@ +package com.mcwl.web.controller.resource; + +import com.mcwl.common.annotation.RepeatSubmit; +import com.mcwl.common.core.domain.AjaxResult; +import com.mcwl.resource.domain.SysUserInfo; +import com.mcwl.resource.service.impl.SysUserAttentionServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * 关注 + * @author DaiZibo + * @date 2025/1/3 + * @apiNote + */ + +@RequestMapping("/attention") +@RestController +public class SysUserAttentionController { + + @Autowired + private SysUserAttentionServiceImpl sysUserAttentionService; + + + /** + * 添加/取消关注 + * @param userId + * @return + */ + @RepeatSubmit + @GetMapping("/addAttention") + public AjaxResult addAttention(@RequestParam Long userId) { + + return sysUserAttentionService.addAttention(userId); + + } + + /** + *查询是否关注用户 + * @param userId + * @return + */ + @GetMapping("/selectAttention") + public AjaxResult selectAttention(@RequestParam Long userId) { + + Boolean aBoolean = sysUserAttentionService.selectAttention(userId); + + return AjaxResult.success(aBoolean); + } + + /** + * 查询个人粉丝,关注,下载量,喜欢 + * @return + */ + @GetMapping("/selectUserInfo") + public AjaxResult selectUserInfo(){ + + SysUserInfo sysUserInfo = sysUserAttentionService.selectUserInfo(); + + return AjaxResult.success(sysUserInfo); + } +} diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/system/SysUserController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/system/SysUserController.java index 9158537..236581e 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/system/SysUserController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/system/SysUserController.java @@ -247,4 +247,26 @@ public class SysUserController extends BaseController { return success(deptService.selectDeptTreeList(dept)); } + + /** + * 查询个人信息 + * @return + */ + @GetMapping("/selectUserById") + public AjaxResult selectUserById(){ + SysUser sysUser = userService.selectUserInfoById(SecurityUtils.getUserId()); + return success(sysUser); + } + + /** + * 修改用户信息 + * @param sysUser + * @return + */ + @PostMapping("/updateUserInfo") + public AjaxResult updateUserInfo(@RequestBody SysUser sysUser){ + + userService.updateUserInfo(sysUser); + return AjaxResult.success("修改成功"); + } } diff --git a/mcwl-admin/src/test/java/com/mcwl/memberCenter/MemberCenterTest.java b/mcwl-admin/src/test/java/com/mcwl/memberCenter/MemberCenterTest.java index bf2a1d8..d3eea9f 100644 --- a/mcwl-admin/src/test/java/com/mcwl/memberCenter/MemberCenterTest.java +++ b/mcwl-admin/src/test/java/com/mcwl/memberCenter/MemberCenterTest.java @@ -1,76 +1,58 @@ -package com.mcwl.memberCenter; - -import com.mcwl.McWlApplication; -import com.mcwl.common.core.domain.AjaxResult; -import com.mcwl.memberCenter.consumer.EmptyPointsRemindConsumer; -import com.mcwl.memberCenter.service.MemberLevelService; -import com.mcwl.memberCenter.service.MemberService; -import com.mcwl.memberCenter.task.UserMemberTask; -import com.mcwl.web.controller.memberCenter.MemberController; -import com.mcwl.web.controller.memberCenter.MemberLevelController; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = McWlApplication.class) -public class MemberCenterTest { - - - @Autowired - private MemberLevelService memberLevelService; - - @Autowired - private MemberController memberController; - - @Autowired - private MemberService memberService; - - @Autowired - private UserMemberTask userMemberTask; - - @Autowired - private MemberLevelController memberLevelController; - - @Autowired - private EmptyPointsRemindConsumer emptyPointsRemindConsumer; - @Test - public void createUserMember() { - System.out.println(memberService.createUserMember(1L, 1013L, "wechat")); - } - - @Test - public void emptyPointsTaskTest() { - userMemberTask.emptyPointsTsk(); - } - - @Test - public void updateSubscriptionStatusTaskTest() { - userMemberTask.updateSubscriptionStatusTask(); - } - - @Test - public void emptyPointsRemindTaskTst() { - - userMemberTask.emptyPointsRemindTask(); - } - - @Test - public void memberServiceTest() { - System.out.println(memberLevelService.list()); - } - - @Test - public void getPointsTest() { - AjaxResult points = memberController.getPoints(1L); - System.out.println("points = " + points); - } - - @Test - public void getMemberLevelListTest() { - System.out.println("memberLevelController.getMemberBenefitList() = " + memberLevelController.getMemberBenefitList()); - } - -} +//package com.mcwl.memberCenter; +// +//import com.mcwl.McWlApplication; +//import com.mcwl.common.utils.ShareCodeUtils; +//import com.mcwl.memberCenter.consumer.EmptyPointsRemindConsumer; +//import com.mcwl.memberCenter.domain.UserMember; +//import com.mcwl.memberCenter.service.MemberService; +//import com.mcwl.memberCenter.service.UserMemberService; +//import com.mcwl.memberCenter.task.UserMemberTask; +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.junit4.SpringRunner; +// +//@RunWith(SpringRunner.class) +//@SpringBootTest(classes = McWlApplication.class) +//public class MemberTest { +// +// +// @Autowired +// private MemberService memberService; +// +// @Autowired +// private UserMemberService userMemberService; +// +// @Autowired +// private UserMemberTask userMemberTask; +// +// @Autowired +// private EmptyPointsRemindConsumer emptyPointsRemindConsumer; +// @Test +// public void createUserMember() { +// System.out.println(userMemberService.createUserMember(1L, 1013L, "wechat")); +// } +// +// @Test +// public void emptyPointsTaskTest() { +// userMemberTask.emptyPointsTsk(); +// } +// +// @Test +// public void updateSubscriptionStatusTaskTest() { +// userMemberTask.updateSubscriptionStatusTask(); +// } +// +// @Test +// public void emptyPointsRemindTaskTst() { +// +// userMemberTask.emptyPointsRemindTask(); +// } +// +// @Test +// public void memberServiceTest() { +// System.out.println(memberService.list()); +// } +// +//} diff --git a/mcwl-common/src/main/java/com/mcwl/common/core/domain/entity/SysUser.java b/mcwl-common/src/main/java/com/mcwl/common/core/domain/entity/SysUser.java index 58ad819..a73cc15 100644 --- a/mcwl-common/src/main/java/com/mcwl/common/core/domain/entity/SysUser.java +++ b/mcwl-common/src/main/java/com/mcwl/common/core/domain/entity/SysUser.java @@ -1,10 +1,5 @@ package com.mcwl.common.core.domain.entity; -import java.util.Date; -import java.util.List; -import javax.validation.constraints.*; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; import com.mcwl.common.annotation.Excel; import com.mcwl.common.annotation.Excel.ColumnType; import com.mcwl.common.annotation.Excel.Type; @@ -12,11 +7,19 @@ import com.mcwl.common.annotation.Excels; import com.mcwl.common.core.domain.BaseEntity; import com.mcwl.common.xss.Xss; +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + /** * 用户对象 sys_user * * @author mcwl */ + public class SysUser extends BaseEntity { private static final long serialVersionUID = 1L; @@ -89,6 +92,9 @@ public class SysUser extends BaseEntity /** 角色ID */ private Long roleId; + /** 简介 */ + private String brief; + public SysUser() { @@ -297,28 +303,36 @@ public class SysUser extends BaseEntity this.roleId = roleId; } + public String getBrief() { + return brief; + } + + public void setBrief(String brief) { + this.brief = brief; + } + @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("userId", getUserId()) - .append("deptId", getDeptId()) - .append("userName", getUserName()) - .append("nickName", getNickName()) - .append("email", getEmail()) - .append("phonenumber", getPhonenumber()) - .append("sex", getSex()) - .append("avatar", getAvatar()) - .append("password", getPassword()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("loginIp", getLoginIp()) - .append("loginDate", getLoginDate()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .append("dept", getDept()) - .toString(); + return "SysUser{" + + "userId=" + userId + + ", deptId=" + deptId + + ", userName='" + userName + '\'' + + ", nickName='" + nickName + '\'' + + ", email='" + email + '\'' + + ", phonenumber='" + phonenumber + '\'' + + ", sex='" + sex + '\'' + + ", avatar='" + avatar + '\'' + + ", password='" + password + '\'' + + ", status='" + status + '\'' + + ", delFlag='" + delFlag + '\'' + + ", loginIp='" + loginIp + '\'' + + ", loginDate=" + loginDate + + ", dept=" + dept + + ", roles=" + roles + + ", roleIds=" + Arrays.toString(roleIds) + + ", postIds=" + Arrays.toString(postIds) + + ", roleId=" + roleId + + ", brief='" + brief + '\'' + + '}'; } } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/MallProduct.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/MallProduct.java index f2df07a..045a5e4 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/MallProduct.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/MallProduct.java @@ -51,7 +51,7 @@ public class MallProduct extends BaseEntity { private BigDecimal amount; /** - * 状态(0未审核 1公开 2隐私 3未通过) + * 状态(0全部 1未审核 2公开 3隐私 4未通过) */ private String status; /** @@ -71,6 +71,9 @@ public class MallProduct extends BaseEntity { */ private String delFlag; - + /** + * 下载次数 + */ + private Long number; } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/SysUserAttention.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/SysUserAttention.java new file mode 100644 index 0000000..403bc1a --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/SysUserAttention.java @@ -0,0 +1,39 @@ +package com.mcwl.resource.domain; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 关注表 + * + * @author DaiZibo + * @date 2025/1/3 + * @apiNote + */ + +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Data +public class SysUserAttention { + + @TableId + private Long id; + + private Long userId; + + private Long toUserId; + + private String createName; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/SysUserInfo.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/SysUserInfo.java new file mode 100644 index 0000000..626986b --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/SysUserInfo.java @@ -0,0 +1,40 @@ +package com.mcwl.resource.domain; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 个人主页展示(关注,粉丝,下载量...) + * @author DaiZibo + * @date 2025/1/3 + * @apiNote + */ + +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Data +public class SysUserInfo { + + /** + * 关注 + */ + private Long attention = 0L; + + /** + * 粉丝 + */ + private Long bean = 0L; + + /** + * 下载次数 + */ + private Long download = 0L; + + /** + * 点赞次数 + */ + private Long likeCount = 0L; +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/MallProductLikeMapper.java b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/MallProductLikeMapper.java index c147d62..5b58fcc 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/MallProductLikeMapper.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/MallProductLikeMapper.java @@ -1,5 +1,7 @@ package com.mcwl.resource.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mcwl.resource.domain.MallProductLike; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -12,7 +14,14 @@ import java.util.List; */ @Mapper -public interface MallProductLikeMapper { +public interface MallProductLikeMapper extends BaseMapper { List selectByUserId(@Param("userId") Long userId); + MallProductLike selectByUserIdAndProductId(@Param("userId") Long userId, @Param("productId") Long productId); + + void deleteByUserIdAndProductId(@Param("productId") Long productId, @Param("userId") Long userId); + + Long countLike(@Param("userId") Long userId); + + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/MallProductMapper.java b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/MallProductMapper.java index 01b663e..92ce5ce 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/MallProductMapper.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/MallProductMapper.java @@ -17,4 +17,6 @@ import org.apache.ibatis.annotations.Param; public interface MallProductMapper extends BaseMapper { String selectMallProductById(@Param("mallProductId") Long mallProductId); + Long sumNumber(@Param("userId") Long userId); + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/SysUserAttentionMapper.java b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/SysUserAttentionMapper.java new file mode 100644 index 0000000..d092d1f --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/SysUserAttentionMapper.java @@ -0,0 +1,24 @@ +package com.mcwl.resource.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mcwl.resource.domain.SysUserAttention; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * @author DaiZibo + * @date 2025/1/3 + * @apiNote + */ + +@Mapper +public interface SysUserAttentionMapper extends BaseMapper { + SysUserAttention selectAttention(@Param("userId") Long userId, @Param("toUserId") Long toUserId); + + void deleteByUserId(@Param("userId") Long userId, @Param("toUserId") Long toUserId); + + Long selectBean(@Param("userId") Long userId); + + Long selectAttentionCount(@Param("userId") Long userId); + +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/MallProductLikeService.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/MallProductLikeService.java index 7263179..655073c 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/MallProductLikeService.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/MallProductLikeService.java @@ -1,6 +1,7 @@ package com.mcwl.resource.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.resource.domain.MallProduct; import com.mcwl.resource.domain.vo.MallProductVo; @@ -12,4 +13,10 @@ import com.mcwl.resource.domain.vo.MallProductVo; public interface MallProductLikeService { Page selectByUserLike(MallProductVo mallProductVo); + + AjaxResult addLike(Long productId); + + AjaxResult deleteLike(Long productId); + + Boolean selectLike(Long productId); } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/SysUserAttentionService.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/SysUserAttentionService.java new file mode 100644 index 0000000..c0249d8 --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/SysUserAttentionService.java @@ -0,0 +1,19 @@ +package com.mcwl.resource.service; + +import com.mcwl.common.core.domain.AjaxResult; +import com.mcwl.resource.domain.SysUserInfo; + +/** + * 关注表 业务层 + * @author DaiZibo + * @date 2025/1/3 + * @apiNote + */ + +public interface SysUserAttentionService { + AjaxResult addAttention(Long userId); + + Boolean selectAttention(Long userId); + + SysUserInfo selectUserInfo(); +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/MallProductLikeServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/MallProductLikeServiceImpl.java index 1836d2e..621ad77 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/MallProductLikeServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/MallProductLikeServiceImpl.java @@ -1,8 +1,10 @@ package com.mcwl.resource.service.impl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.utils.SecurityUtils; import com.mcwl.resource.domain.MallProduct; +import com.mcwl.resource.domain.MallProductLike; import com.mcwl.resource.domain.vo.MallProductVo; import com.mcwl.resource.mapper.MallProductLikeMapper; import com.mcwl.resource.service.MallProductLikeService; @@ -10,6 +12,7 @@ import com.mcwl.resource.service.MallProductService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Date; import java.util.List; /** @@ -35,6 +38,49 @@ public class MallProductLikeServiceImpl implements MallProductLikeService { List list = mallProductLikeMapper.selectByUserId(userId); //分页查询作品数据 - return mallProductService.pageLike(mallProductVo,list); + return mallProductService.pageLike(mallProductVo, list); } + + @Override + public AjaxResult addLike(Long productId) { + + Boolean aBoolean = selectLike(productId); + if (aBoolean == true){ + //删除点赞记录 + mallProductLikeMapper.deleteByUserIdAndProductId(productId,SecurityUtils.getUserId()); + return AjaxResult.success(false); + } + + MallProductLike mallProductLike = MallProductLike.builder().productId(productId) + .userId(SecurityUtils.getUserId()) + .createName(SecurityUtils.getUsername()) + .createTime(new Date()).build(); + + int insert = mallProductLikeMapper.insert(mallProductLike); + + if (insert<0){ + + return AjaxResult.error("点赞失败",false); + } + return AjaxResult.success(true); + } + + @Override + public AjaxResult deleteLike(Long productId) { + + return AjaxResult.success(); + } + + @Override + public Boolean selectLike(Long productId) { + + MallProductLike mallProductLike1 = mallProductLikeMapper.selectByUserIdAndProductId(SecurityUtils.getUserId(),productId); + + if (mallProductLike1 == null){ + + return false; + } + return true; + } + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/MallProductServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/MallProductServiceImpl.java index c497cdc..629ee43 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/MallProductServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/MallProductServiceImpl.java @@ -80,7 +80,7 @@ public class MallProductServiceImpl extends ServiceImpl mallProductLambdaQueryWrapper = new LambdaQueryWrapper<>(); mallProductLambdaQueryWrapper.in(MallProduct::getProductId,list); + if (mallProductVo.getOrder() == 1){ + mallProductLambdaQueryWrapper.orderByDesc(MallProduct::getProductId); + }else { + mallProductLambdaQueryWrapper.orderByDesc(MallProduct::getNumber); + } + return postMapper.selectPage(mallProductPage,mallProductLambdaQueryWrapper); } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/SysUserAttentionServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/SysUserAttentionServiceImpl.java new file mode 100644 index 0000000..4de0d65 --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/SysUserAttentionServiceImpl.java @@ -0,0 +1,80 @@ +package com.mcwl.resource.service.impl; + +import com.mcwl.common.core.domain.AjaxResult; +import com.mcwl.common.utils.SecurityUtils; +import com.mcwl.resource.domain.SysUserAttention; +import com.mcwl.resource.domain.SysUserInfo; +import com.mcwl.resource.mapper.MallProductLikeMapper; +import com.mcwl.resource.mapper.MallProductMapper; +import com.mcwl.resource.mapper.SysUserAttentionMapper; +import com.mcwl.resource.service.SysUserAttentionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; + +/** + * 关注表 业务实现层 + * + * @author DaiZibo + * @date 2025/1/3 + * @apiNote + */ + +@Service +public class SysUserAttentionServiceImpl implements SysUserAttentionService { + + + @Autowired + private MallProductMapper mallProductMapper; + + @Autowired + private MallProductLikeMapper mallProductLikeMapper; + + @Autowired + private SysUserAttentionMapper sysUserAttentionMapper; + + @Override + public AjaxResult addAttention(Long userId) { + + //查看是否已关注 + Boolean aBoolean = selectAttention(userId); + if (aBoolean == true){ + //取关 + sysUserAttentionMapper.deleteByUserId(SecurityUtils.getUserId(),userId); + return AjaxResult.success(false); + } + + //关注 + SysUserAttention sysUserAttention = SysUserAttention.builder().userId(SecurityUtils.getUserId()) + .toUserId(userId) + .createName(SecurityUtils.getUsername()) + .createTime(new Date()) + .build(); + sysUserAttentionMapper.insert(sysUserAttention); + return AjaxResult.success(true); + } + + @Override + public Boolean selectAttention(Long userId) { + + SysUserAttention sysUserAttention = sysUserAttentionMapper.selectAttention(SecurityUtils.getUserId(),userId); + + if (sysUserAttention == null){ + return false; + } + + return true; + } + + @Override + public SysUserInfo selectUserInfo() { + + Long userId = SecurityUtils.getUserId(); + + return SysUserInfo.builder().bean(sysUserAttentionMapper.selectBean(userId)) + .download(mallProductMapper.sumNumber(userId)) + .likeCount(mallProductLikeMapper.countLike(userId)) + .attention(sysUserAttentionMapper.selectAttentionCount(userId)).build(); + } +} diff --git a/mcwl-resource/src/main/resources/mapper/resource/MallProductLikeMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/MallProductLikeMapper.xml index b4b2fa9..e6855cb 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/MallProductLikeMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/MallProductLikeMapper.xml @@ -3,9 +3,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + delete from mall_product_like where user_id = #{userId} and product_id = #{productId} + + + + + diff --git a/mcwl-resource/src/main/resources/mapper/resource/MallProductMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/MallProductMapper.xml index 1e8d1c8..a7bf8ea 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/MallProductMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/MallProductMapper.xml @@ -24,4 +24,8 @@ del_flag from mall_product where product_id =#{mallProductId} + + diff --git a/mcwl-resource/src/main/resources/mapper/resource/SysUserAttentionMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/SysUserAttentionMapper.xml new file mode 100644 index 0000000..0b4e312 --- /dev/null +++ b/mcwl-resource/src/main/resources/mapper/resource/SysUserAttentionMapper.xml @@ -0,0 +1,22 @@ + + + + + delete from sys_user_attention where user_id = #{userId} and to_user_id = #{toUserId} + + + + + + + + + diff --git a/mcwl-system/src/main/java/com/mcwl/system/mapper/SysUserMapper.java b/mcwl-system/src/main/java/com/mcwl/system/mapper/SysUserMapper.java index 447ec48..8cd762f 100644 --- a/mcwl-system/src/main/java/com/mcwl/system/mapper/SysUserMapper.java +++ b/mcwl-system/src/main/java/com/mcwl/system/mapper/SysUserMapper.java @@ -128,4 +128,8 @@ public interface SysUserMapper SysUser selectUserByPhone(@Param("phone") String phone); + void updateUserInfo(SysUser sysUser); + + SysUser selectUserInfoById(@Param("userId") Long userId); + } diff --git a/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserService.java b/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserService.java index cce0eaa..f3df3e2 100644 --- a/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserService.java +++ b/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserService.java @@ -208,4 +208,9 @@ public interface ISysUserService SysUser selectUserByPhone(String phone); void addUser(String openid,String type,String phone); + + void updateUserInfo(SysUser sysUser); + + SysUser selectUserInfoById(Long userId); + } diff --git a/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java b/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java index e505698..6c203b6 100644 --- a/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java +++ b/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java @@ -587,6 +587,18 @@ public class SysUserServiceImpl implements ISysUserService } + @Override + public void updateUserInfo(SysUser sysUser) { + + userMapper.updateUserInfo(sysUser); + } + + @Override + public SysUser selectUserInfoById(Long userId) { + + return userMapper.selectUserInfoById(userId); + } + /** * 生成随机密码 * @param length diff --git a/mcwl-system/src/main/resources/mapper/system/SysUserMapper.xml b/mcwl-system/src/main/resources/mapper/system/SysUserMapper.xml index 6dc0cb2..4c7d436 100644 --- a/mcwl-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/mcwl-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -147,6 +147,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where u.phonenumber = #{phone} and u.del_flag = '0' + + insert into sys_user( user_id, @@ -212,6 +216,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update sys_user set password = #{password} where user_name = #{userName} + + update sys_user set nick_name = #{nickName}, + avatar = #{avatar}, + brief = #{brief} + where user_id = #{userId} + + update sys_user set del_flag = '2' where user_id = #{userId}