parent
37e43baf60
commit
734cb109fb
|
@ -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.service.MallProductService;
|
||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||
|
@ -62,6 +63,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));
|
||||
}
|
||||
|
|
|
@ -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<MallProduct> 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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("修改成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,58 +1,58 @@
|
|||
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());
|
||||
}
|
||||
|
||||
}
|
||||
//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());
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
|
@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@ public class MallProduct extends BaseEntity {
|
|||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private Integer productId;
|
||||
private Long productId;
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Integer userId;
|
||||
private Long userId;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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<MallProductLike> {
|
||||
List<Long> 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);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -17,4 +17,6 @@ import org.apache.ibatis.annotations.Param;
|
|||
public interface MallProductMapper extends BaseMapper<MallProduct> {
|
||||
String selectMallProductById(@Param("mallProductId") Long mallProductId);
|
||||
|
||||
Long sumNumber(@Param("userId") Long userId);
|
||||
|
||||
}
|
||||
|
|
|
@ -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> {
|
||||
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);
|
||||
|
||||
}
|
|
@ -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<MallProduct> selectByUserLike(MallProductVo mallProductVo);
|
||||
|
||||
AjaxResult addLike(Long productId);
|
||||
|
||||
AjaxResult deleteLike(Long productId);
|
||||
|
||||
Boolean selectLike(Long productId);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -37,4 +40,47 @@ public class MallProductLikeServiceImpl implements MallProductLikeService {
|
|||
//分页查询作品数据
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public class MallProductServiceImpl extends ServiceImpl<MallProductMapper,MallPr
|
|||
if (mallProductVo.getOrder() == 1){
|
||||
mallProductLambdaQueryWrapper.orderByDesc(MallProduct::getProductId);
|
||||
}else {
|
||||
|
||||
mallProductLambdaQueryWrapper.orderByDesc(MallProduct::getNumber);
|
||||
}
|
||||
|
||||
// 开始时间和结束时间过滤
|
||||
|
@ -107,6 +107,12 @@ public class MallProductServiceImpl extends ServiceImpl<MallProductMapper,MallPr
|
|||
LambdaQueryWrapper<MallProduct> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -3,9 +3,20 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.mcwl.resource.mapper.MallProductLikeMapper">
|
||||
<delete id="deleteByUserIdAndProductId">
|
||||
delete from mall_product_like where user_id = #{userId} and product_id = #{productId}
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="selectByUserId" resultType="java.lang.Long">
|
||||
select product_id FROM mall_product_like WHERE user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectByUserIdAndProductId" resultType="com.mcwl.resource.domain.MallProductLike">
|
||||
select id,user_id,product_id from mall_product_like where user_id = #{userId} and product_id = #{productId}
|
||||
</select>
|
||||
|
||||
<select id="countLike" resultType="java.lang.Long">
|
||||
SELECT count(id)likeCount FROM mall_product_like where user_id = #{userId} ORDER BY(user_id);
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -24,4 +24,8 @@
|
|||
del_flag
|
||||
from mall_product where product_id =#{mallProductId}
|
||||
</select>
|
||||
|
||||
<select id="sumNumber" resultType="java.lang.Long">
|
||||
SELECT sum(number)sum FROM mall_product where user_id = #{userId} ORDER BY(user_id);
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.mcwl.resource.mapper.SysUserAttentionMapper">
|
||||
<delete id="deleteByUserId">
|
||||
delete from sys_user_attention where user_id = #{userId} and to_user_id = #{toUserId}
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="selectAttention" resultType="com.mcwl.resource.domain.SysUserAttention">
|
||||
select id,user_id,to_user_id from sys_user_attention where user_id = #{userId} and to_user_id = #{toUserId}
|
||||
</select>
|
||||
|
||||
<select id="selectBean" resultType="java.lang.Long">
|
||||
SELECT count(id)bean FROM sys_user_attention where to_user_id = #{userId} ORDER BY(to_user_id);
|
||||
</select>
|
||||
|
||||
<select id="selectAttentionCount" resultType="java.lang.Long">
|
||||
SELECT count(id)attention FROM sys_user_attention where user_id = #{userId} ORDER BY(user_id);
|
||||
</select>
|
||||
</mapper>
|
|
@ -128,4 +128,8 @@ public interface SysUserMapper
|
|||
|
||||
SysUser selectUserByPhone(@Param("phone") String phone);
|
||||
|
||||
void updateUserInfo(SysUser sysUser);
|
||||
|
||||
SysUser selectUserInfoById(@Param("userId") Long userId);
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -147,6 +147,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where u.phonenumber = #{phone} and u.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectUserInfoById" resultType="com.mcwl.common.core.domain.entity.SysUser">
|
||||
select user_id,avatar,brief,nick_name from sys_user where user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||
insert into sys_user(
|
||||
<if test="userId != null and userId != 0">user_id,</if>
|
||||
|
@ -212,6 +216,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
update sys_user set password = #{password} where user_name = #{userName}
|
||||
</update>
|
||||
|
||||
<update id="updateUserInfo">
|
||||
update sys_user set nick_name = #{nickName},
|
||||
avatar = #{avatar},
|
||||
brief = #{brief}
|
||||
where user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteUserById" parameterType="Long">
|
||||
update sys_user set del_flag = '2' where user_id = #{userId}
|
||||
</delete>
|
||||
|
|
Loading…
Reference in New Issue