2 Commits e0a48dbf00 ... 6574636eec

Author SHA1 Message Date
  yubin 6574636eec 收藏商品 3 days ago
  yubin 9a170f393a 1 4 days ago

+ 206 - 0
mall-api/src/main/java/com/txz/mall/dto/MidFavoriteDTO.java

@@ -0,0 +1,206 @@
+/*
+*
+* MidFavoriteDTO.java
+* Copyright(C) 2017-2020 fendo公司
+* @date 2025-08-13
+*/
+package com.txz.mall.dto;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class MidFavoriteDTO implements Serializable {
+    /**
+     * 
+     */
+    private Long id;
+
+    /**
+     * 用户id
+     */
+    private Long userId;
+
+    /**
+     * 商品id
+     */
+    private Long productId;
+
+    /**
+     * 创建人
+     */
+    private String createUser;
+
+    /**
+     * 更新人
+     */
+    private String updateUser;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 删除标识 1是0否
+     */
+    private Byte isValid;
+
+    /**
+     * 版本号
+     */
+    private String version;
+
+    /**
+     * m_mid_favorite
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 
+     * @return id 
+     */
+    public Long getId() {
+        return id;
+    }
+
+    /**
+     * 
+     * @param id 
+     */
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    /**
+     * 用户id
+     * @return user_id 用户id
+     */
+    public Long getUserId() {
+        return userId;
+    }
+
+    /**
+     * 用户id
+     * @param userId 用户id
+     */
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    /**
+     * 商品id
+     * @return product_id 商品id
+     */
+    public Long getProductId() {
+        return productId;
+    }
+
+    /**
+     * 商品id
+     * @param productId 商品id
+     */
+    public void setProductId(Long productId) {
+        this.productId = productId;
+    }
+
+    /**
+     * 创建人
+     * @return create_user 创建人
+     */
+    public String getCreateUser() {
+        return createUser;
+    }
+
+    /**
+     * 创建人
+     * @param createUser 创建人
+     */
+    public void setCreateUser(String createUser) {
+        this.createUser = createUser;
+    }
+
+    /**
+     * 更新人
+     * @return update_user 更新人
+     */
+    public String getUpdateUser() {
+        return updateUser;
+    }
+
+    /**
+     * 更新人
+     * @param updateUser 更新人
+     */
+    public void setUpdateUser(String updateUser) {
+        this.updateUser = updateUser;
+    }
+
+    /**
+     * 更新时间
+     * @return update_time 更新时间
+     */
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    /**
+     * 更新时间
+     * @param updateTime 更新时间
+     */
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    /**
+     * 创建时间
+     * @return create_time 创建时间
+     */
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    /**
+     * 创建时间
+     * @param createTime 创建时间
+     */
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    /**
+     * 删除标识 1是0否
+     * @return is_valid 删除标识 1是0否
+     */
+    public Byte getIsValid() {
+        return isValid;
+    }
+
+    /**
+     * 删除标识 1是0否
+     * @param isValid 删除标识 1是0否
+     */
+    public void setIsValid(Byte isValid) {
+        this.isValid = isValid;
+    }
+
+    /**
+     * 版本号
+     * @return version 版本号
+     */
+    public String getVersion() {
+        return version;
+    }
+
+    /**
+     * 版本号
+     * @param version 版本号
+     */
+    public void setVersion(String version) {
+        this.version = version;
+    }
+}

+ 54 - 54
mall-service/src/main/java/com/txz/mall/controller/appcontroller/AppBannerController.java

@@ -32,60 +32,60 @@ public class AppBannerController {
     @Resource
     private BannerService bannerService;
 
-    @PostMapping("/add")
-    @ApiOperation(value = "轮播图新增")
-    public Result add(@RequestBody Banner banner) {
-        if (banner == null) {
-            return Result.fail(ResultCode.OBJECT_IS_NULL);
-        }
-        try {
-            banner.setCreateTime(new Date());
-//            banner.setCreateUserId(userId);
-            bannerService.save(banner);
-        } catch (Exception e) {
-            log.error("新增对象操作异常e:{}", e);
-            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
-        }
-        return Result.success();
-    }
-
-    @DeleteMapping("/delete")
-    @ApiOperation(value = "轮播图删除")
-    public Result delete(@RequestParam Long id) {
-        if (id == null) {
-            return Result.fail(ResultCode.ID_IS_NULL);
-        }
-        try {
-            Banner banner = new Banner();
-            banner.setId(id);
-            banner.setIsDelete(1);
-            bannerService.update(banner);
-        } catch (Exception e) {
-            log.error("删除对象操作异常e:{}", e);
-            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
-        }
-        return Result.success();
-    }
-
-    @PutMapping("/update")
-    @ApiOperation(value = "轮播图更新")
-    public Result update(@RequestBody Banner banner) {
-        if (banner == null) {
-            return Result.fail(ResultCode.OBJECT_IS_NULL);
-        }
-        if (banner.getId() == null) {
-            return Result.fail(ResultCode.ID_IS_NULL);
-        }
-        try {
-            banner.setUpdateTime(new Date());
-//            banner.setUpdateUserId(userId);
-            bannerService.update(banner);
-        } catch (Exception e) {
-            log.error("更新对象操作异常e:{}", e);
-            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
-        }
-        return Result.success();
-    }
+//    @PostMapping("/add")
+//    @ApiOperation(value = "轮播图新增")
+//    public Result add(@RequestBody Banner banner) {
+//        if (banner == null) {
+//            return Result.fail(ResultCode.OBJECT_IS_NULL);
+//        }
+//        try {
+//            banner.setCreateTime(new Date());
+////            banner.setCreateUserId(userId);
+//            bannerService.save(banner);
+//        } catch (Exception e) {
+//            log.error("新增对象操作异常e:{}", e);
+//            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+//        }
+//        return Result.success();
+//    }
+//
+//    @DeleteMapping("/delete")
+//    @ApiOperation(value = "轮播图删除")
+//    public Result delete(@RequestParam Long id) {
+//        if (id == null) {
+//            return Result.fail(ResultCode.ID_IS_NULL);
+//        }
+//        try {
+//            Banner banner = new Banner();
+//            banner.setId(id);
+//            banner.setIsDelete(1);
+//            bannerService.update(banner);
+//        } catch (Exception e) {
+//            log.error("删除对象操作异常e:{}", e);
+//            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+//        }
+//        return Result.success();
+//    }
+//
+//    @PutMapping("/update")
+//    @ApiOperation(value = "轮播图更新")
+//    public Result update(@RequestBody Banner banner) {
+//        if (banner == null) {
+//            return Result.fail(ResultCode.OBJECT_IS_NULL);
+//        }
+//        if (banner.getId() == null) {
+//            return Result.fail(ResultCode.ID_IS_NULL);
+//        }
+//        try {
+//            banner.setUpdateTime(new Date());
+////            banner.setUpdateUserId(userId);
+//            bannerService.update(banner);
+//        } catch (Exception e) {
+//            log.error("更新对象操作异常e:{}", e);
+//            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+//        }
+//        return Result.success();
+//    }
 
     @GetMapping("/detail")
     @ApiOperation(value = "轮播图获取详情")

+ 256 - 0
mall-service/src/main/java/com/txz/mall/controller/appcontroller/MidFavoriteController.java

@@ -0,0 +1,256 @@
+package com.txz.mall.controller.appcontroller;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.txz.mall.core.AuthService;
+import com.txz.mall.core.Result;
+import com.txz.mall.core.ServiceException;
+import com.txz.mall.dto.MidFavoriteDTO;
+import com.txz.mall.model.MidFavorite;
+import com.txz.mall.model.StoreCombination;
+import com.txz.mall.model.StoreProduct;
+import com.txz.mall.service.MidFavoriteService;
+
+import com.txz.mall.core.ResultCode;
+
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.txz.mall.service.StoreCombinationService;
+import com.txz.mall.service.StoreProductService;
+import com.txz.mall.util.EasyToUseUtil;
+import com.txz.mall.web.bo.MidFavoriteBO;
+import com.txz.mall.web.param.BasePageParam;
+import com.txz.mall.web.param.MidFavoriteParam;
+import com.txz.mall.web.param.TopLevelEntity;
+import com.txz.mall.web.param.addparam.MidFavoriteAddParam;
+import io.swagger.annotations.ApiModelProperty;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.ObjectUtils;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import tk.mybatis.mapper.entity.Condition;
+import tk.mybatis.mapper.entity.Example.Criteria;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.validation.annotation.Validated;
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+* Created by CodeGenerator on 2025/08/13.
+*/
+@Api(tags = "[后台]midFavorite管理")
+@RestController
+@RequestMapping("/mid/favorite")
+public class MidFavoriteController {
+
+	private static Logger log = LoggerFactory.getLogger(MidFavoriteController.class);
+
+    @Resource
+    private MidFavoriteService midFavoriteService;
+	@Resource
+	private StoreCombinationService  storeCombinationService;
+
+	@Resource
+	private StoreProductService storeProductService;
+
+    @PostMapping("/add")
+	@ApiOperation(value = "midFavorite新增")
+	public Result add(@RequestBody MidFavoriteAddParam midFavoriteAddParam) {
+    	if(ObjectUtils.isEmpty(midFavoriteAddParam)){
+    		return Result.fail(ResultCode.OBJECT_IS_NULL);
+    	}
+
+		if(CollectionUtils.isEmpty(midFavoriteAddParam.getProductIdList())){
+			return Result.fail(ResultCode.OBJECT_IS_NULL);
+		}
+
+		Condition condition3 = new Condition(StoreCombination.class);
+		Criteria criteria3 = condition3.createCriteria();
+		criteria3.andEqualTo("isDelete", 0);
+		criteria3.andIn("id",midFavoriteAddParam.getProductIdList());
+
+		Map<Long, StoreProduct> productId_StoreProduct= new HashMap<>();
+		List<StoreProduct> storeProductList = storeProductService.findByCondition(condition3);
+		if(CollectionUtils.isEmpty(storeProductList)){
+			throw new ServiceException("商品id不存在");
+		}
+		Long tokenUserId = AuthService.getTokenUserId(null);
+		Condition condition = new Condition(MidFavorite.class);
+		Criteria criteria = condition.createCriteria();
+		criteria.andEqualTo("isValid", 1);
+		criteria.andEqualTo("userId",tokenUserId);
+		criteria.andIn("productId",midFavoriteAddParam.getProductIdList());
+
+		List<MidFavorite> list = midFavoriteService.findByCondition(condition);
+		if(!CollectionUtils.isEmpty(list)){
+			throw new ServiceException("重复收藏同样的商品");
+		}
+		List<MidFavorite> midFavoriteList = new ArrayList<>();
+
+		List<Long> productIdList = midFavoriteAddParam.getProductIdList();
+		for (Long l : productIdList) {
+			MidFavorite midFavorite = new MidFavorite();
+			EasyToUseUtil.appCreateAssignment(midFavorite);
+			midFavorite.setProductId(l);
+			midFavoriteList.add(midFavorite);
+		}
+
+    	try {
+    		midFavoriteService.save(midFavoriteList);
+		} catch (Exception e) {
+			log.error("新增对象midFavorite操作异常e:{}",e);
+			return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+		}
+        return Result.success();
+    }
+
+    @DeleteMapping("/delete")
+	@ApiOperation(value = "midFavorite删除")
+	public Result delete(@RequestParam Long id) {
+    	if(id == null){
+    		return Result.fail(ResultCode.ID_IS_NULL);
+    	}
+
+    	try {
+            MidFavorite midFavorite = new MidFavorite();
+			EasyToUseUtil.appDeleteAssignment(midFavorite);
+			midFavorite.setId(id);
+			midFavoriteService.update(midFavorite);
+		} catch (Exception e) {
+			log.error("midFavorite删除对象操作异常e:{}",e);
+			return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+		}
+        return Result.success();
+    }
+
+//    @PutMapping("/update")
+//	@ApiOperation(value = "midFavorite更新")
+//	public Result update(@RequestBody MidFavorite midFavorite) {
+//    	if(midFavorite == null){
+//    		return Result.fail(ResultCode.OBJECT_IS_NULL);
+//    	}
+//    	if(midFavorite.getId() == null){
+//    		return Result.fail(ResultCode.ID_IS_NULL);
+//    	}
+//    	try {
+//    		midFavorite.setUpdateTime(new Date());
+////            midFavorite.setUpdateUserId(userId);
+//    		midFavoriteService.update(midFavorite);
+//		} catch (Exception e) {
+//			log.error("更新对象操作异常e:{}",e);
+//			return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+//		}
+//        return Result.success();
+//    }
+
+//    @GetMapping("/detail")
+//	@ApiOperation(value = "midFavorite获取详情")
+//	public Result<MidFavorite> detail(@RequestParam Long id) {
+//    	if(id == null){
+//    		return Result.fail(ResultCode.ID_IS_NULL);
+//    	}
+//    	MidFavorite midFavorite = null;
+//    	try {
+//    		midFavorite = midFavoriteService.findById(id);
+//		} catch (Exception e) {
+//			log.error("查询对象操作异常e:{}",e);
+//			return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+//		}
+//        return Result.success(midFavorite);
+//    }
+
+
+
+    @PostMapping("/list")
+	@ApiOperation(value = "midFavorite获取列表")
+	public Result list(@RequestBody MidFavoriteParam midFavoriteParam) {
+
+		Long tokenUserId = AuthService.getTokenUserId(null);
+        PageHelper.startPage(midFavoriteParam.getPage(), midFavoriteParam.getSize());
+
+
+        Condition condition = new Condition(MidFavorite.class);
+        Criteria criteria = condition.createCriteria();
+		criteria.andEqualTo("isValid", 1);
+		criteria.andEqualTo("userId",tokenUserId);
+		condition.setOrderByClause("create_time DESC");
+
+
+
+
+		PageInfo pageInfo = null;
+		try {
+    		 List<MidFavorite> list = midFavoriteService.findByCondition(condition);
+
+			 if(!CollectionUtils.isEmpty(list)){
+
+				 List<Long> productIdList = list.stream().map(MidFavorite::getProductId).collect(Collectors.toList());
+
+				 Condition condition2 = new Condition(StoreCombination.class);
+				 Criteria criteria2 = condition2.createCriteria();
+				 criteria2.andEqualTo("isDelete", 0);
+				 criteria2.andIn("productId",productIdList);
+				 List<StoreCombination> byCondition = storeCombinationService.findByCondition(condition2);
+
+
+				 Condition condition3 = new Condition(StoreCombination.class);
+				 Criteria criteria3 = condition3.createCriteria();
+				 criteria3.andEqualTo("isDelete", 0);
+				 criteria3.andIn("id",productIdList);
+
+				 Map<Long, StoreProduct> productId_StoreProduct= new HashMap<>();
+				 List<StoreProduct> storeProductList = storeProductService.findByCondition(condition3);
+				 if(!CollectionUtils.isEmpty(storeProductList)){
+
+					 productId_StoreProduct = storeProductList.stream().collect(Collectors.toMap(StoreProduct::getId, a -> a, (b, c) -> c));
+				 }
+
+
+
+				 if(!CollectionUtils.isEmpty(byCondition)){
+					 Map<Long, StoreCombination> productIdMap = byCondition.stream().collect(Collectors.toMap(StoreCombination::getProductId, a -> a, (c, d) -> d));
+					 Map<Long, StoreProduct> finalProductId_StoreProduct = productId_StoreProduct;
+					 List<MidFavoriteBO> resultList = list.stream().map(a -> {
+
+						 MidFavoriteBO bean = new MidFavoriteBO();
+						 bean.setId(a.getId());
+						 bean.setProductId(a.getProductId());
+						 StoreProduct storeProduct = finalProductId_StoreProduct.get(bean.getProductId());
+						 StoreCombination storeCombination = productIdMap.get(bean.getProductId());
+						 if(!ObjectUtils.isEmpty(storeCombination)){
+							 bean.setCId(storeCombination.getId());
+							 bean.setPrice(storeCombination.getPrice());
+							 bean.setSales(storeCombination.getSales());
+							 bean.setImage(storeCombination.getImage());
+							 bean.setStoreName(storeCombination.getProductName());
+						 }else if(!ObjectUtils.isEmpty(storeProduct)){
+							 bean.setImage(storeProduct.getImage());
+							 bean.setStoreName(storeProduct.getStoreName());
+						 }
+
+						 return bean;
+					 }).collect(Collectors.toList());
+					 pageInfo = new PageInfo(resultList);
+				 }
+
+			 }
+
+
+		} catch (Exception e) {
+			log.error("查询对象操作异常e:{}",e);
+			return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+		}
+        return Result.success(pageInfo);
+    }
+}

+ 7 - 0
mall-service/src/main/java/com/txz/mall/dao/MidFavoriteMapper.java

@@ -0,0 +1,7 @@
+package com.txz.mall.dao;
+
+import com.txz.mall.core.Mapper;
+import com.txz.mall.model.MidFavorite;
+
+public interface MidFavoriteMapper extends Mapper<MidFavorite> {
+}

+ 216 - 0
mall-service/src/main/java/com/txz/mall/model/MidFavorite.java

@@ -0,0 +1,216 @@
+package com.txz.mall.model;
+
+import java.util.Date;
+import javax.persistence.*;
+
+@Table(name = "m_mid_favorite")
+public class MidFavorite {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
+    /**
+     * 用户id
+     */
+    @Column(name = "user_id")
+    private Long userId;
+
+    /**
+     * 商品id
+     */
+    @Column(name = "product_id")
+    private Long productId;
+
+    /**
+     * 创建人
+     */
+    @Column(name = "create_user")
+    private String createUser;
+
+    /**
+     * 更新人
+     */
+    @Column(name = "update_user")
+    private String updateUser;
+
+    /**
+     * 更新时间
+     */
+    @Column(name = "update_time")
+    private Date updateTime;
+
+    /**
+     * 创建时间
+     */
+    @Column(name = "create_time")
+    private Date createTime;
+
+    /**
+     * 删除标识 1是0否
+     */
+    @Column(name = "is_valid")
+    private Byte isValid;
+
+    /**
+     * 版本号
+     */
+    private Integer version;
+
+    /**
+     * @return id
+     */
+    public Long getId() {
+        return id;
+    }
+
+    /**
+     * @param id
+     */
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    /**
+     * 获取用户id
+     *
+     * @return user_id - 用户id
+     */
+    public Long getUserId() {
+        return userId;
+    }
+
+    /**
+     * 设置用户id
+     *
+     * @param userId 用户id
+     */
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    /**
+     * 获取商品id
+     *
+     * @return product_id - 商品id
+     */
+    public Long getProductId() {
+        return productId;
+    }
+
+    /**
+     * 设置商品id
+     *
+     * @param productId 商品id
+     */
+    public void setProductId(Long productId) {
+        this.productId = productId;
+    }
+
+    /**
+     * 获取创建人
+     *
+     * @return create_user - 创建人
+     */
+    public String getCreateUser() {
+        return createUser;
+    }
+
+    /**
+     * 设置创建人
+     *
+     * @param createUser 创建人
+     */
+    public void setCreateUser(String createUser) {
+        this.createUser = createUser;
+    }
+
+    /**
+     * 获取更新人
+     *
+     * @return update_user - 更新人
+     */
+    public String getUpdateUser() {
+        return updateUser;
+    }
+
+    /**
+     * 设置更新人
+     *
+     * @param updateUser 更新人
+     */
+    public void setUpdateUser(String updateUser) {
+        this.updateUser = updateUser;
+    }
+
+    /**
+     * 获取更新时间
+     *
+     * @return update_time - 更新时间
+     */
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    /**
+     * 设置更新时间
+     *
+     * @param updateTime 更新时间
+     */
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    /**
+     * 获取创建时间
+     *
+     * @return create_time - 创建时间
+     */
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    /**
+     * 设置创建时间
+     *
+     * @param createTime 创建时间
+     */
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    /**
+     * 获取删除标识 1是0否
+     *
+     * @return is_valid - 删除标识 1是0否
+     */
+    public Byte getIsValid() {
+        return isValid;
+    }
+
+    /**
+     * 设置删除标识 1是0否
+     *
+     * @param isValid 删除标识 1是0否
+     */
+    public void setIsValid(Byte isValid) {
+        this.isValid = isValid;
+    }
+
+    /**
+     * 获取版本号
+     *
+     * @return version - 版本号
+     */
+    public Integer getVersion() {
+        return version;
+    }
+
+    /**
+     * 设置版本号
+     *
+     * @param version 版本号
+     */
+    public void setVersion(Integer version) {
+        this.version = version;
+    }
+}

+ 11 - 0
mall-service/src/main/java/com/txz/mall/service/MidFavoriteService.java

@@ -0,0 +1,11 @@
+package com.txz.mall.service;
+import com.txz.mall.model.MidFavorite;
+import com.txz.mall.core.Service;
+
+
+/**
+ * Created by CodeGenerator on 2025/08/13.
+ */
+public interface MidFavoriteService extends Service<MidFavorite> {
+
+}

+ 22 - 0
mall-service/src/main/java/com/txz/mall/service/impl/MidFavoriteServiceImpl.java

@@ -0,0 +1,22 @@
+package com.txz.mall.service.impl;
+
+import com.txz.mall.dao.MidFavoriteMapper;
+import com.txz.mall.model.MidFavorite;
+import com.txz.mall.service.MidFavoriteService;
+import com.txz.mall.core.AbstractService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+
+
+/**
+ * Created by CodeGenerator on 2025/08/13.
+ */
+@Service
+@Transactional
+public class MidFavoriteServiceImpl extends AbstractService<MidFavorite> implements MidFavoriteService {
+    @Resource
+    private MidFavoriteMapper mMidFavoriteMapper;
+
+}

+ 96 - 0
mall-service/src/main/java/com/txz/mall/util/EasyToUseUtil.java

@@ -0,0 +1,96 @@
+package com.txz.mall.util;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import com.txz.cif.dto.UserDTO;
+import com.txz.mall.core.AuthService;
+import com.txz.mall.dubbo.client.CifUserDubboServiceClient;
+import com.txz.mall.model.MidFavorite;
+import com.txz.mall.web.param.TopLevelEntity;
+import org.apache.poi.ss.formula.functions.T;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Component;
+import org.springframework.util.ObjectUtils;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import java.util.Date;
+@Component
+public class EasyToUseUtil {
+    private static Logger log = LoggerFactory.getLogger(EasyToUseUtil.class);
+    @Resource
+    private  CifUserDubboServiceClient cifUserDubboServiceClient;
+
+    // 2. 定义静态变量,用于静态方法中引用
+    private static EasyToUseUtil instance;
+
+    // 3. 私有化构造器,防止被实例化
+    private EasyToUseUtil() {}
+
+    // 4. 初始化时将实例赋值给静态变量,使静态方法能访问注入的资源
+    @PostConstruct
+    public void init() {
+        instance = this;
+    }
+
+    public static <T> void  appCreateAssignment(Date date, T t){
+        TopLevelEntity topLevelEntity = new TopLevelEntity();
+
+        UserDTO user = new UserDTO();
+        user.setName("Operation");
+        Long tokenUserId = AuthService.getTokenUserId(null);
+        if(!ObjectUtils.isEmpty(tokenUserId)){
+            try{
+                user = instance.cifUserDubboServiceClient.getUser(tokenUserId);
+            }catch (Exception e){
+                log.error("Failed to get user from cifUserDubboServiceClient ,tokenUserId:{}", tokenUserId, e);
+            }
+
+        }
+        Byte b = 1;
+        topLevelEntity.setIsValid(b);
+        topLevelEntity.setVersion(1);
+        topLevelEntity.setCreateTime(date);
+        topLevelEntity.setUpdateTime(date);
+        topLevelEntity.setCreateUser(user.getName());
+        topLevelEntity.setUpdateUser(user.getName());
+        topLevelEntity.setUserId(tokenUserId);
+        BeanUtils.copyProperties(topLevelEntity,t);
+
+    }
+
+    public static <T> void  appCreateAssignment( T t){
+        DateTime date = DateUtil.date();
+        appCreateAssignment(date, t);
+    }
+
+
+    public static <T> void  appDeleteAssignment(Date date, T t){
+        TopLevelEntity topLevelEntity = new TopLevelEntity();
+
+        UserDTO user = new UserDTO();
+        user.setName("Operation");
+        Long tokenUserId = AuthService.getTokenUserId(null);
+        if(!ObjectUtils.isEmpty(tokenUserId)){
+            try{
+                user = instance.cifUserDubboServiceClient.getUser(tokenUserId);
+            }catch (Exception e){
+                log.error("Failed to get user from cifUserDubboServiceClient ,tokenUserId:{}", tokenUserId, e);
+            }
+
+        }
+        Byte b = 0;
+        topLevelEntity.setIsValid(b);
+        topLevelEntity.setUpdateTime(date);
+        topLevelEntity.setUpdateUser(user.getName());
+        BeanUtils.copyProperties(topLevelEntity,t);
+
+    }
+    public static <T> void  appDeleteAssignment(T t){
+        DateTime date = DateUtil.date();
+        appDeleteAssignment(date, t);
+    }
+
+}

+ 39 - 0
mall-service/src/main/java/com/txz/mall/web/bo/MidFavoriteBO.java

@@ -0,0 +1,39 @@
+package com.txz.mall.web.bo;
+
+import com.tencentcloudapi.iot.v20180123.models.Product;
+import com.txz.mall.model.StoreProduct;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+
+import java.math.BigDecimal;
+
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@Getter
+@Setter
+@ApiModel(value="我收藏的商品")
+public class MidFavoriteBO  {
+
+       private Long id;
+
+       @ApiModelProperty(value = "商品id")
+       private Long productId;
+
+       @ApiModelProperty(value = "商品主图")
+       private String image;
+
+       @ApiModelProperty(value = "商品名称")
+       private String storeName;
+
+       @ApiModelProperty(value = "拼团商品价格")
+       private BigDecimal price;
+
+       @ApiModelProperty(value = "拼团商品id")
+       private Long cId;
+
+       @ApiModelProperty(value = "销量")
+       private Integer sales;
+
+}

+ 0 - 1
mall-service/src/main/java/com/txz/mall/web/param/BasePageParam.java

@@ -11,7 +11,6 @@ import javax.validation.constraints.Min;
 import java.io.Serializable;
 
 @Data
-@ApiModel("分页查询参数")
 @NoArgsConstructor
 public class BasePageParam implements Serializable {
 

+ 13 - 0
mall-service/src/main/java/com/txz/mall/web/param/MidFavoriteParam.java

@@ -0,0 +1,13 @@
+package com.txz.mall.web.param;
+
+
+import lombok.NoArgsConstructor;
+
+
+@NoArgsConstructor
+public class MidFavoriteParam extends BasePageParam {
+
+
+
+
+}

+ 44 - 0
mall-service/src/main/java/com/txz/mall/web/param/TopLevelEntity.java

@@ -0,0 +1,44 @@
+package com.txz.mall.web.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class TopLevelEntity implements Serializable {
+
+    /**
+     * 创建人
+     */
+    private String createUser;
+
+    /**
+     * 更新人
+     */
+    private String updateUser;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 删除标识 1是0否
+     */
+    private Byte isValid;
+
+    /**
+     * 版本号
+     */
+    private Integer version;
+
+
+    private Long userId;
+
+}

+ 16 - 0
mall-service/src/main/java/com/txz/mall/web/param/addparam/MidFavoriteAddParam.java

@@ -0,0 +1,16 @@
+package com.txz.mall.web.param.addparam;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class MidFavoriteAddParam {
+
+    @ApiModelProperty(value = "产品id列表")
+    private List<Long> productIdList;
+
+
+}

+ 18 - 0
mall-service/src/main/resources/mapper/MidFavoriteMapper.xml

@@ -0,0 +1,18 @@
+<?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.txz.mall.dao.MidFavoriteMapper">
+  <resultMap id="BaseResultMap" type="com.txz.mall.model.MidFavorite">
+    <!--
+      WARNING - @mbg.generated
+    -->
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="user_id" jdbcType="BIGINT" property="userId" />
+    <result column="product_id" jdbcType="BIGINT" property="productId" />
+    <result column="create_user" jdbcType="VARCHAR" property="createUser" />
+    <result column="update_user" jdbcType="VARCHAR" property="updateUser" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="is_valid" jdbcType="TINYINT" property="isValid" />
+    <result column="version" jdbcType="VARCHAR" property="version" />
+  </resultMap>
+</mapper>

+ 1 - 1
mall-service/src/test/java/CodeGenerator.java

@@ -47,7 +47,7 @@ public class CodeGenerator {
 	public static void main(String[] args) {
 //		genCode("o_lottery","o_lottery_prize","o_lottery_record");
 		// genCode("输入表名","输入自定义Model名称");
-		genCode("m_banner");
+		genCode("m_mid_favorite");
 		//genCode("c_member_coupon");
 	}
 

+ 2 - 2
mall-service/src/test/resources/generator/template/controller.ftl

@@ -54,7 +54,7 @@ public class ${modelNameUpperCamel}Controller {
         return Result.success();
     }
 
-    @GetMapping("/delete")
+    @DeleteMapping("/delete")
 	@ApiOperation(value = "${modelNameLowerCamel}删除")
 	public Result delete(@RequestParam Long id) {
     	if(id == null){
@@ -72,7 +72,7 @@ public class ${modelNameUpperCamel}Controller {
         return Result.success();
     }
 
-    @PostMapping("/update")
+    @PutMapping("/update")
 	@ApiOperation(value = "${modelNameLowerCamel}更新")
 	public Result update(@RequestBody ${modelNameUpperCamel} ${modelNameLowerCamel}) {
     	if(${modelNameLowerCamel} == null){