商品评论

dev798
wxy 2024-05-08 16:59:26 +08:00
parent 89c4c773d5
commit 8e4e9c8527
6 changed files with 543 additions and 0 deletions

View File

@ -0,0 +1,101 @@
package com.nuyu.product.domain;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* mall_product_stock_log
*
* @author muyu
* @date 2024-05-08
*/
@Data
public class MallProductStockLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
private Integer pageSize=10;
private Integer pageNum=1;
/** 商品 */
@Excel(name = "商品")
private Long productId;
/** 商品SKU */
@Excel(name = "商品SKU")
private Long productRuleCententId;
/** 录入库存数量 */
@Excel(name = "录入库存数量")
private Long stockNum;
/** 乐观锁 */
@Excel(name = "乐观锁")
private Long revision;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setProductId(Long productId)
{
this.productId = productId;
}
public Long getProductId()
{
return productId;
}
public void setProductRuleCententId(Long productRuleCententId)
{
this.productRuleCententId = productRuleCententId;
}
public Long getProductRuleCententId()
{
return productRuleCententId;
}
public void setStockNum(Long stockNum)
{
this.stockNum = stockNum;
}
public Long getStockNum()
{
return stockNum;
}
public void setRevision(Long revision)
{
this.revision = revision;
}
public Long getRevision()
{
return revision;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("productId", getProductId())
.append("productRuleCententId", getProductRuleCententId())
.append("stockNum", getStockNum())
.append("revision", getRevision())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.toString();
}
}

View File

@ -0,0 +1,107 @@
package com.muyu.product.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.github.pagehelper.PageInfo;
import com.muyu.common.core.web.domain.AjaxResult;
import com.muyu.product.service.MallProductStockLogService;
import com.nuyu.product.domain.MallProductInfo;
import com.nuyu.product.domain.MallProductStockLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author muyu
* @date 2024-05-08
*/
@RestController
@RequestMapping("/stock")
public class MallProductStockLogController extends BaseController
{
@Autowired
private MallProductStockLogService mallProductStockLogService;
/**
*
*/
@RequiresPermissions("product:stock:list")
@GetMapping("/list")
public AjaxResult list(MallProductStockLog mallProductStockLog){
PageInfo<MallProductStockLog> info=mallProductStockLogService.list(mallProductStockLog);
return AjaxResult.success(info);
}
/**
*
*/
@RequiresPermissions("product:stock:export")
@Log(title = "商品库存录入记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MallProductStockLog mallProductStockLog)
{
List<MallProductStockLog> list = mallProductStockLogService.selectMallProductStockLogList(mallProductStockLog);
ExcelUtil<MallProductStockLog> util = new ExcelUtil<MallProductStockLog>(MallProductStockLog.class);
util.exportExcel(response, list, "商品库存录入记录数据");
}
/**
*
*/
@RequiresPermissions("product:stock:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id)
{
return success(mallProductStockLogService.selectMallProductStockLogById(id));
}
/**
*
*/
@RequiresPermissions("product:stock:add")
@Log(title = "商品库存录入记录", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody MallProductStockLog mallProductStockLog)
{
return toAjax(mallProductStockLogService.insertMallProductStockLog(mallProductStockLog));
}
/**
*
*/
@RequiresPermissions("product:stock:edit")
@Log(title = "商品库存录入记录", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody MallProductStockLog mallProductStockLog)
{
return toAjax(mallProductStockLogService.updateMallProductStockLog(mallProductStockLog));
}
/**
*
*/
@RequiresPermissions("product:stock:remove")
@Log(title = "商品库存录入记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(mallProductStockLogService.deleteMallProductStockLogByIds(ids));
}
}

View File

@ -0,0 +1,67 @@
package com.muyu.product.mapper;
import com.nuyu.product.domain.MallProductStockLog;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* Mapper
*
* @author muyu
* @date 2024-05-08
*/
@Mapper
public interface MallProductStockLogMapper
{
/**
*
*
* @param id
* @return
*/
public MallProductStockLog selectMallProductStockLogById(Long id);
/**
*
*
* @param mallProductStockLog
* @return
*/
public List<MallProductStockLog> selectMallProductStockLogList(MallProductStockLog mallProductStockLog);
/**
*
*
* @param mallProductStockLog
* @return
*/
public int insertMallProductStockLog(MallProductStockLog mallProductStockLog);
/**
*
*
* @param mallProductStockLog
* @return
*/
public int updateMallProductStockLog(MallProductStockLog mallProductStockLog);
/**
*
*
* @param id
* @return
*/
public int deleteMallProductStockLogById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteMallProductStockLogByIds(Long[] ids);
List<MallProductStockLog> list(MallProductStockLog mallProductStockLog);
}

View File

@ -0,0 +1,114 @@
package com.muyu.product.service.Impl;
import java.util.List;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.product.mapper.MallProductStockLogMapper;
import com.muyu.product.service.MallProductStockLogService;
import com.nuyu.product.domain.MallProductInfo;
import com.nuyu.product.domain.MallProductStockLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service
*
* @author muyu
* @date 2024-05-08
*/
@Service
public class MallProductStockLogServiceImpl implements MallProductStockLogService
{
@Autowired
private MallProductStockLogMapper mallProductStockLogMapper;
/**
*
*
* @param id
* @return
*/
@Override
public MallProductStockLog selectMallProductStockLogById(Long id)
{
return mallProductStockLogMapper.selectMallProductStockLogById(id);
}
/**
*
*
* @param mallProductStockLog
* @return
*/
@Override
public List<MallProductStockLog> selectMallProductStockLogList(MallProductStockLog mallProductStockLog)
{
return mallProductStockLogMapper.selectMallProductStockLogList(mallProductStockLog);
}
/**
*
*
* @param mallProductStockLog
* @return
*/
@Override
public int insertMallProductStockLog(MallProductStockLog mallProductStockLog)
{
mallProductStockLog.setCreateTime(DateUtils.getNowDate());
return mallProductStockLogMapper.insertMallProductStockLog(mallProductStockLog);
}
/**
*
*
* @param mallProductStockLog
* @return
*/
@Override
public int updateMallProductStockLog(MallProductStockLog mallProductStockLog)
{
return mallProductStockLogMapper.updateMallProductStockLog(mallProductStockLog);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteMallProductStockLogByIds(Long[] ids)
{
return mallProductStockLogMapper.deleteMallProductStockLogByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteMallProductStockLogById(Long id)
{
return mallProductStockLogMapper.deleteMallProductStockLogById(id);
}
/**
*
*
* @param mallProductStockLog
* @return
*/
@Override
public PageInfo<MallProductStockLog> list(MallProductStockLog mallProductStockLog) {
PageHelper.startPage(mallProductStockLog.getPageNum(),mallProductStockLog.getPageSize());
List<MallProductStockLog> products = mallProductStockLogMapper.list(mallProductStockLog);
PageInfo<MallProductStockLog> pageInfo = new PageInfo<>(products);
return pageInfo;
}
}

View File

@ -0,0 +1,71 @@
package com.muyu.product.service;
import com.github.pagehelper.PageInfo;
import com.nuyu.product.domain.MallProductStockLog;
import java.util.List;
/**
* Service
*
* @author muyu
* @date 2024-05-08
*/
public interface MallProductStockLogService
{
/**
*
*
* @param id
* @return
*/
public MallProductStockLog selectMallProductStockLogById(Long id);
/**
*
*
* @param mallProductStockLog
* @return
*/
public List<MallProductStockLog> selectMallProductStockLogList(MallProductStockLog mallProductStockLog);
/**
*
*
* @param mallProductStockLog
* @return
*/
public int insertMallProductStockLog(MallProductStockLog mallProductStockLog);
/**
*
*
* @param mallProductStockLog
* @return
*/
public int updateMallProductStockLog(MallProductStockLog mallProductStockLog);
/**
*
*
* @param ids
* @return
*/
public int deleteMallProductStockLogByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteMallProductStockLogById(Long id);
/**
*
* @param mallProductStockLog
* @return
*/
PageInfo<MallProductStockLog> list(MallProductStockLog mallProductStockLog);
}

View File

@ -0,0 +1,83 @@
<?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.muyu.product.mapper.MallProductStockLogMapper">
<resultMap type="com.nuyu.product.domain.MallProductStockLog" id="MallProductStockLogResult">
<result property="id" column="id" />
<result property="productId" column="product_id" />
<result property="productRuleCententId" column="product_rule_centent_id" />
<result property="stockNum" column="stock_num" />
<result property="revision" column="revision" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectMallProductStockLogVo">
select id, product_id, product_rule_centent_id, stock_num, revision, create_by, create_time from mall_product_stock_log
</sql>
<select id="selectMallProductStockLogList" parameterType="com.nuyu.product.domain.MallProductStockLog" resultMap="MallProductStockLogResult">
<include refid="selectMallProductStockLogVo"/>
<where>
<if test="stockNum != null "> and stock_num = #{stockNum}</if>
</where>
</select>
<select id="selectMallProductStockLogById" parameterType="Long" resultMap="MallProductStockLogResult">
<include refid="selectMallProductStockLogVo"/>
where id = #{id}
</select>
<select id="list" resultType="com.nuyu.product.domain.MallProductStockLog">
<include refid="selectMallProductStockLogVo"/>
<where>
<if test="stockNum != null "> and stock_num = #{stockNum}</if>
</where>
</select>
<insert id="insertMallProductStockLog" parameterType="com.nuyu.product.domain.MallProductStockLog" useGeneratedKeys="true" keyProperty="id">
insert into mall_product_stock_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="productId != null">product_id,</if>
<if test="productRuleCententId != null">product_rule_centent_id,</if>
<if test="stockNum != null">stock_num,</if>
<if test="revision != null">revision,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="productId != null">#{productId},</if>
<if test="productRuleCententId != null">#{productRuleCententId},</if>
<if test="stockNum != null">#{stockNum},</if>
<if test="revision != null">#{revision},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateMallProductStockLog" parameterType="com.nuyu.product.domain.MallProductStockLog">
update mall_product_stock_log
<trim prefix="SET" suffixOverrides=",">
<if test="productId != null">product_id = #{productId},</if>
<if test="productRuleCententId != null">product_rule_centent_id = #{productRuleCententId},</if>
<if test="stockNum != null">stock_num = #{stockNum},</if>
<if test="revision != null">revision = #{revision},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteMallProductStockLogById" parameterType="Long">
delete from mall_product_stock_log where id = #{id}
</delete>
<delete id="deleteMallProductStockLogByIds" parameterType="String">
delete from mall_product_stock_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>