feat: 智聪记账管理,物价管理-商品信息管理代码提交。

This commit is contained in:
tianyongbao
2025-03-19 15:56:58 +08:00
parent e85ad8aea7
commit f523aaf7f9
8 changed files with 607 additions and 0 deletions

View File

@@ -0,0 +1,115 @@
package com.intc.invest.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.annotation.Resource;
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.intc.common.log.annotation.Log;
import com.intc.common.log.enums.BusinessType;
import com.intc.common.security.annotation.RequiresPermissions;
import com.intc.invest.domain.ProductInfor;
import com.intc.invest.domain.vo.ProductInforVo;
import com.intc.invest.domain.dto.ProductInforDto;
import com.intc.invest.service.IProductInforService;
import com.intc.common.core.web.controller.BaseController;
import com.intc.common.core.web.domain.AjaxResult;
import com.intc.common.core.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.intc.common.core.web.page.TableDataInfo;
/**
* 商品基础信息Controller
*
* @author tianyongbao
* @date 2025-03-19
*/
@Api(tags=" 商品基础信息")
@RestController
@RequestMapping("/productInfor")
public class ProductInforController extends BaseController
{
@Resource
private IProductInforService productInforService;
/**
* 查询商品基础信息列表
*/
@ApiOperation(value="查询商品基础信息列表",response = ProductInforVo.class)
@RequiresPermissions("invest:productInfor:list")
@GetMapping("/list")
public TableDataInfo list(ProductInforDto productInforDto)
{
startPage();
List<ProductInforVo> list = productInforService.selectProductInforList(productInforDto);
return getDataTable(list);
}
/**
* 导出商品基础信息列表
*/
@ApiOperation(value="导出商品基础信息列表")
@RequiresPermissions("invest:productInfor:export")
@Log(title = "商品基础信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ProductInforDto productInforDto)
{
List<ProductInforVo> list = productInforService.selectProductInforList(productInforDto);
ExcelUtil<ProductInforVo> util = new ExcelUtil<ProductInforVo>(ProductInforVo.class);
util.exportExcel(response, list, "商品基础信息数据");
}
/**
* 获取商品基础信息详细信息
*/
@ApiOperation(value="获取商品基础信息详细信息")
@RequiresPermissions("invest:productInfor:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(productInforService.selectProductInforById(id));
}
/**
* 新增商品基础信息
*/
@ApiOperation(value="新增商品基础信息")
@RequiresPermissions("invest:productInfor:add")
@Log(title = "商品基础信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ProductInfor productInfor)
{
return toAjax(productInforService.insertProductInfor(productInfor));
}
/**
* 修改商品基础信息
*/
@ApiOperation(value="修改商品基础信息")
@RequiresPermissions("invest:productInfor:edit")
@Log(title = "商品基础信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ProductInfor productInfor)
{
return toAjax(productInforService.updateProductInfor(productInfor));
}
/**
* 删除商品基础信息
*/
@ApiOperation(value="删除商品基础信息")
@RequiresPermissions("invest:productInfor:remove")
@Log(title = "商品基础信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(productInforService.deleteProductInforByIds(ids));
}
}

View File

@@ -0,0 +1,77 @@
package com.intc.invest.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.intc.common.core.annotation.Excel;
import com.intc.common.core.web.domain.BaseEntity;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.*;
/**
* 商品基础信息对象 product_infor
*
* @author tianyongbao
* @date 2025-03-19
*/
@ApiModel("商品基础信息对象")
@Data
public class ProductInfor extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 商品名称 */
@ApiModelProperty(value="商品名称)")
@NotNull(message="商品名称不能为空")
@Excel(name = "商品名称")
private String name;
/** 类别 */
@ApiModelProperty(value="类别)")
@NotNull(message="类别不能为空")
@Excel(name = "类别")
private String category;
/** 单位 */
@ApiModelProperty(value="单位)")
@NotNull(message="单位不能为空")
@Excel(name = "单位")
private String unit;
/** 更新者 */
private String updatedBy;
/** 删除标志0代表存在 1代表删除 */
private String delFlag;
/** 预留字段 */
private String fields;
/** 预留字段1 */
private int ranking;
/** 编号 */
private String code;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("category", getCategory())
.append("unit", getUnit())
.append("remark", getRemark())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateTime", getUpdateTime())
.append("updatedBy", getUpdatedBy())
.append("delFlag", getDelFlag())
.append("fields", getFields())
.append("ranking", getRanking())
.append("code", getCode())
.toString();
}
}

View File

@@ -0,0 +1,36 @@
package com.intc.invest.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 商品基础信息Dto对象 product_infor
*
* @author tianyongbao
* @date 2025-03-19
*/
@ApiModel("商品基础信息Dto对象")
@Data
public class ProductInforDto implements Serializable
{
private static final long serialVersionUID = 1L;
/** 商品名称 */
@ApiModelProperty(value="商品名称")
private String name;
/** 商品编码 */
@ApiModelProperty(value="商品编码")
private String code;
/** 类别 */
@ApiModelProperty(value="类别")
private String category;
/** 单位 */
@ApiModelProperty(value="单位")
private String unit;
}

View File

@@ -0,0 +1,17 @@
package com.intc.invest.domain.vo;
import com.intc.invest.domain.ProductInfor;
import lombok.Data;
import io.swagger.annotations.ApiModel;
/**
* 商品基础信息Vo对象 product_infor
*
* @author tianyongbao
* @date 2025-03-19
*/
@ApiModel("商品基础信息Vo对象")
@Data
public class ProductInforVo extends ProductInfor
{
}

View File

@@ -0,0 +1,79 @@
package com.intc.invest.mapper;
import java.util.List;
import com.intc.invest.domain.ProductInfor;
import com.intc.invest.domain.dto.ProductInforDto;
import com.intc.invest.domain.vo.ProductInforVo;
/**
* 商品基础信息Mapper接口
*
* @author tianyongbao
* @date 2025-03-19
*/
public interface ProductInforMapper
{
/**
* 查询商品基础信息
*
* @param id 商品基础信息主键
* @return 商品基础信息
*/
public ProductInforVo selectProductInforById(Long id);
/**
* 查询商品基础信息列表
*
* @param productInforDto 商品基础信息
* @return 商品基础信息集合
*/
public List<ProductInforVo> selectProductInforList(ProductInforDto productInforDto);
/**
* 新增商品基础信息
*
* @param productInfor 商品基础信息
* @return 结果
*/
public int insertProductInfor(ProductInfor productInfor);
/**
* 修改商品基础信息
*
* @param productInfor 商品基础信息
* @return 结果
*/
public int updateProductInfor(ProductInfor productInfor);
/**
* 删除商品基础信息
*
* @param id 商品基础信息主键
* @return 结果
*/
public int deleteProductInforById(Long id);
/**
* 批量删除商品基础信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteProductInforByIds(Long[] ids);
/**
* 逻辑删除商品基础信息
*
* @param id 商品基础信息主键
* @return 结果
*/
public int removeProductInforById(Long id);
/**
* 批量逻辑删除商品基础信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int removeProductInforByIds(Long[] ids);
}

View File

@@ -0,0 +1,63 @@
package com.intc.invest.service;
import java.util.List;
import com.intc.invest.domain.ProductInfor;
import com.intc.invest.domain.dto.ProductInforDto;
import com.intc.invest.domain.vo.ProductInforVo;
/**
* 商品基础信息Service接口
*
* @author tianyongbao
* @date 2025-03-19
*/
public interface IProductInforService
{
/**
* 查询商品基础信息
*
* @param id 商品基础信息主键
* @return 商品基础信息
*/
public ProductInforVo selectProductInforById(Long id);
/**
* 查询商品基础信息列表
*
* @param productInforDto 商品基础信息
* @return 商品基础信息集合
*/
public List<ProductInforVo> selectProductInforList(ProductInforDto productInforDto);
/**
* 新增商品基础信息
*
* @param productInfor 商品基础信息
* @return 结果
*/
public int insertProductInfor(ProductInfor productInfor);
/**
* 修改商品基础信息
*
* @param productInfor 商品基础信息
* @return 结果
*/
public int updateProductInfor(ProductInfor productInfor);
/**
* 批量删除商品基础信息
*
* @param ids 需要删除的商品基础信息主键集合
* @return 结果
*/
public int deleteProductInforByIds(Long[] ids);
/**
* 删除商品基础信息信息
*
* @param id 商品基础信息主键
* @return 结果
*/
public int deleteProductInforById(Long id);
}

View File

@@ -0,0 +1,103 @@
package com.intc.invest.service.impl;
import com.intc.common.core.utils.DateUtils;
import com.intc.common.core.utils.IdWorker;
import com.intc.common.security.utils.SecurityUtils;
import com.intc.invest.domain.ProductInfor;
import com.intc.invest.domain.dto.ProductInforDto;
import com.intc.invest.domain.vo.ProductInforVo;
import com.intc.invest.mapper.ProductInforMapper;
import com.intc.invest.service.IProductInforService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 商品基础信息Service业务层处理
*
* @author tianyongbao
* @date 2025-03-19
*/
@Service
public class ProductInforServiceImpl implements IProductInforService
{
@Resource
private ProductInforMapper productInforMapper;
/**
* 查询商品基础信息
*
* @param id 商品基础信息主键
* @return 商品基础信息
*/
@Override
public ProductInforVo selectProductInforById(Long id)
{
return productInforMapper.selectProductInforById(id);
}
/**
* 查询商品基础信息列表
*
* @param productInforDto 商品基础信息
* @return 商品基础信息
*/
@Override
public List<ProductInforVo> selectProductInforList(ProductInforDto productInforDto)
{
return productInforMapper.selectProductInforList(productInforDto);
}
/**
* 新增商品基础信息
*
* @param productInfor 商品基础信息
* @return 结果
*/
@Override
public int insertProductInfor(ProductInfor productInfor)
{
productInfor.setCreateTime(DateUtils.getNowDate());
productInfor.setCreateBy(SecurityUtils.getUsername());
productInfor.setId(IdWorker.getId());
return productInforMapper.insertProductInfor(productInfor);
}
/**
* 修改商品基础信息
*
* @param productInfor 商品基础信息
* @return 结果
*/
@Override
public int updateProductInfor(ProductInfor productInfor)
{
productInfor.setUpdateTime(DateUtils.getNowDate());
return productInforMapper.updateProductInfor(productInfor);
}
/**
* 批量删除商品基础信息
*
* @param ids 需要删除的商品基础信息主键
* @return 结果
*/
@Override
public int deleteProductInforByIds(Long[] ids)
{
return productInforMapper.removeProductInforByIds(ids);
}
/**
* 删除商品基础信息信息
*
* @param id 商品基础信息主键
* @return 结果
*/
@Override
public int deleteProductInforById(Long id)
{
return productInforMapper.removeProductInforById(id);
}
}

View File

@@ -0,0 +1,117 @@
<?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.intc.invest.mapper.ProductInforMapper">
<resultMap type="ProductInforVo" id="ProductInforResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="category" column="category" />
<result property="unit" column="unit" />
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updatedBy" column="updated_by" />
<result property="delFlag" column="del_flag" />
<result property="fields" column="fields" />
<result property="ranking" column="ranking" />
<result property="code" column="code" />
</resultMap>
<sql id="selectProductInforVo">
select a.id, a.name, a.category, a.unit, a.remark, a.create_time, a.create_by, a.update_time, a.updated_by, a.del_flag, a.fields, a.ranking, a.code from product_infor a
</sql>
<select id="selectProductInforList" parameterType="ProductInforDto" resultMap="ProductInforResult">
<include refid="selectProductInforVo"/>
<where>
a.del_flag='0'
<if test="name != null and name != ''"> and a.name like '%'|| #{name}||'%'</if>
<if test="code != null and code != ''"> and a.code like '%'|| #{code}||'%'</if>
<if test="category != null and category != ''"> and a.category = #{category}</if>
<if test="unit != null and unit != ''"> and a.unit = #{unit}</if>
</where>
order by a.ranking asc,a.create_time desc
</select>
<select id="selectProductInforById" parameterType="Long" resultMap="ProductInforResult">
<include refid="selectProductInforVo"/>
where a.id = #{id}
</select>
<insert id="insertProductInfor" parameterType="ProductInfor">
insert into product_infor
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="name != null and name != ''">name,</if>
<if test="category != null and category != ''">category,</if>
<if test="unit != null and unit != ''">unit,</if>
<if test="remark != null">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updatedBy != null">updated_by,</if>
<if test="delFlag != null">del_flag,</if>
<if test="fields != null">fields,</if>
<if test="ranking != null">ranking,</if>
<if test="code != null">code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="category != null and category != ''">#{category},</if>
<if test="unit != null and unit != ''">#{unit},</if>
<if test="remark != null">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updatedBy != null">#{updatedBy},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="fields != null">#{fields},</if>
<if test="ranking != null">#{ranking},</if>
<if test="code != null">#{code},</if>
</trim>
</insert>
<update id="updateProductInfor" parameterType="ProductInfor">
update product_infor
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="category != null and category != ''">category = #{category},</if>
<if test="unit != null and unit != ''">unit = #{unit},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="fields != null">fields = #{fields},</if>
<if test="ranking != null">ranking = #{ranking},</if>
<if test="code != null">code = #{code},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteProductInforById" parameterType="Long">
delete from product_infor where id = #{id}
</delete>
<delete id="deleteProductInforByIds" parameterType="String">
delete from product_infor where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<update id="removeProductInforById" parameterType="Long">
update product_infor set del_flag='1' where id = #{id}
</update>
<update id="removeProductInforByIds" parameterType="String">
update product_infor set del_flag='1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>