7 changed files with 477 additions and 0 deletions
-
82src/main/java/com/xujie/modules/part/controller/PartController.java
-
27src/main/java/com/xujie/modules/part/dao/PartMapper.java
-
95src/main/java/com/xujie/modules/part/entity/Part.java
-
28src/main/java/com/xujie/modules/part/service/Iface/IPartService.java
-
72src/main/java/com/xujie/modules/part/service/Impl/PartServiceImpl.java
-
88src/main/java/com/xujie/modules/part/vo/PartVo.java
-
85src/main/resources/mapper/part/mapperXml/PartMapper.xml
@ -0,0 +1,82 @@ |
|||||
|
package com.xujie.modules.part.controller; |
||||
|
import com.xujie.common.utils.PageUtils; |
||||
|
import com.xujie.common.utils.R; |
||||
|
import com.xujie.modules.part.entity.Part; |
||||
|
import com.xujie.modules.part.service.Iface.IPartService; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* API |
||||
|
* </p> |
||||
|
* |
||||
|
* @author jyy |
||||
|
* @since 2026-03-09 |
||||
|
*/ |
||||
|
@Api(tags = "") |
||||
|
@RestController |
||||
|
@RequestMapping("/part") |
||||
|
public class PartController { |
||||
|
|
||||
|
@Autowired |
||||
|
private IPartService baseService; |
||||
|
|
||||
|
/** |
||||
|
* 保存数据 |
||||
|
*/ |
||||
|
@PostMapping("/save") |
||||
|
@ApiOperation("保存") |
||||
|
public R save(@Validated @RequestBody Part model) { |
||||
|
baseService.saveModel(model); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 获取分页 |
||||
|
*/ |
||||
|
@PostMapping("/searchPartList") |
||||
|
@ApiOperation("分頁") |
||||
|
public R page(@RequestBody Part page){ |
||||
|
PageUtils myPage = baseService.myPage(page); |
||||
|
return R.ok().put("page", myPage); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 获取list |
||||
|
*/ |
||||
|
@PostMapping("/list") |
||||
|
@ApiOperation("获取list") |
||||
|
public R list(@RequestBody Part query){ |
||||
|
List<Part> rows = baseService.getListByModel(query); |
||||
|
return R.ok().put("rows", rows); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据主键获取实体对象 |
||||
|
*/ |
||||
|
@PostMapping("/get") |
||||
|
public R get(@RequestBody Part data) { |
||||
|
baseService.get(data); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 删除对象 |
||||
|
*/ |
||||
|
@PostMapping("/delete") |
||||
|
@ResponseBody |
||||
|
public R delete(@RequestBody Part data) { |
||||
|
baseService.delete(data); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
package com.xujie.modules.part.dao; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.xujie.modules.part.entity.Part; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* Mapper 接口 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author jyy |
||||
|
* @since 2026-03-09 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface PartMapper extends BaseMapper<Part> { |
||||
|
|
||||
|
List<Part> getListByModel(Part data); |
||||
|
|
||||
|
IPage<Part> myPage(Page<Part> page, @Param("query") Part data); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,95 @@ |
|||||
|
package com.xujie.modules.part.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.xujie.common.utils.QueryPage; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import lombok.experimental.Accessors; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* |
||||
|
* </p> |
||||
|
* |
||||
|
* @author jyy |
||||
|
* @since 2026-03-09 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@Accessors(chain = true) |
||||
|
@TableName("part") |
||||
|
@ApiModel(value = "Part对象", description = "") |
||||
|
public class Part extends QueryPage { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
@ApiModelProperty(value = "工厂") |
||||
|
private String site; |
||||
|
|
||||
|
@ApiModelProperty(value = "产品编码") |
||||
|
private String partNo; |
||||
|
|
||||
|
@ApiModelProperty(value = "产品名称") |
||||
|
private String partDesc; |
||||
|
|
||||
|
@ApiModelProperty(value = "备注") |
||||
|
private String remark; |
||||
|
|
||||
|
@ApiModelProperty(value = "创建人") |
||||
|
private String createBy; |
||||
|
|
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
@ApiModelProperty(value = "创建时间") |
||||
|
private Date createDate; |
||||
|
|
||||
|
@ApiModelProperty(value = "修改人") |
||||
|
private String updateBy; |
||||
|
|
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
@ApiModelProperty(value = "修改时间") |
||||
|
private Date updateDate; |
||||
|
|
||||
|
@ApiModelProperty(value = "NPC货号") |
||||
|
private String npc; |
||||
|
|
||||
|
@ApiModelProperty(value = "产品规格") |
||||
|
private String partSpec; |
||||
|
|
||||
|
@ApiModelProperty(value = "采购员名称") |
||||
|
private String buyerName; |
||||
|
|
||||
|
@ApiModelProperty(value = "采购员id") |
||||
|
private Integer buyerId; |
||||
|
|
||||
|
@ApiModelProperty(value = "sourcing负责人名称") |
||||
|
private String sourcingName; |
||||
|
|
||||
|
@ApiModelProperty(value = "sourcing负责人id") |
||||
|
private Integer sourcingId; |
||||
|
|
||||
|
@ApiModelProperty(value = "产品分类") |
||||
|
private String category; |
||||
|
|
||||
|
@ApiModelProperty(value = "计量单位") |
||||
|
private String unit; |
||||
|
|
||||
|
@ApiModelProperty(value = "状态(启用N,禁用Y)") |
||||
|
private String status; |
||||
|
|
||||
|
@ApiModelProperty(value = "属性模板") |
||||
|
private String codeNo; |
||||
|
|
||||
|
private Integer id; |
||||
|
|
||||
|
public Object getKey() { |
||||
|
return this.id; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
package com.xujie.modules.part.service.Iface; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.xujie.common.utils.PageUtils; |
||||
|
import com.xujie.modules.part.entity.Part; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* 服务类 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author jyy |
||||
|
* @since 2026-03-09 |
||||
|
*/ |
||||
|
public interface IPartService extends IService<Part> { |
||||
|
|
||||
|
void saveModel(Part model); |
||||
|
|
||||
|
PageUtils myPage(Part page); |
||||
|
|
||||
|
List<Part> getListByModel(Part query); |
||||
|
|
||||
|
Part get(Part model); |
||||
|
|
||||
|
void delete(Part model); |
||||
|
} |
||||
@ -0,0 +1,72 @@ |
|||||
|
package com.xujie.modules.part.service.Impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.xujie.common.utils.PageUtils; |
||||
|
import com.xujie.modules.part.dao.PartMapper; |
||||
|
import com.xujie.modules.part.entity.Part; |
||||
|
import com.xujie.modules.part.service.Iface.IPartService; |
||||
|
import org.apache.commons.collections4.CollectionUtils; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* 服务实现类 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author jyy |
||||
|
* @since 2026-03-09 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class PartServiceImpl extends ServiceImpl<PartMapper, Part> implements IPartService { |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void saveModel(Part model){ |
||||
|
if(model.getId() != null){ |
||||
|
model.setUpdateDate(new Date()); |
||||
|
baseMapper.updateById(model); |
||||
|
return; |
||||
|
} |
||||
|
model.setCreateDate(new Date()); |
||||
|
baseMapper.insert(model); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<Part> getListByModel(Part query){ |
||||
|
return baseMapper.getListByModel(query); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public PageUtils myPage(Part data){ |
||||
|
IPage<Part> resultList = baseMapper.myPage(new Page<Part>(data.getPage(), data.getLimit()), data); |
||||
|
return new PageUtils(resultList); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Part get(Part model){ |
||||
|
List<Part> list = baseMapper.getListByModel(model); |
||||
|
if(!CollectionUtils.isEmpty(list)){ |
||||
|
return list.get(0); |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void delete(Part model){ |
||||
|
if(model.getId() == null){ |
||||
|
return; |
||||
|
} |
||||
|
baseMapper.deleteById(model.getId()); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,88 @@ |
|||||
|
package com.xujie.modules.part.vo; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.xujie.common.utils.QueryPage; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* |
||||
|
* </p> |
||||
|
* |
||||
|
* @author jyy |
||||
|
* @since 2026-03-09 |
||||
|
*/ |
||||
|
@Data |
||||
|
@ApiModel(value = "PartVo对象", description = "") |
||||
|
public class PartVo extends QueryPage { |
||||
|
|
||||
|
@ApiModelProperty(value = "工厂") |
||||
|
private String site; |
||||
|
|
||||
|
@ApiModelProperty(value = "产品编码") |
||||
|
private String partNo; |
||||
|
|
||||
|
@ApiModelProperty(value = "产品名称") |
||||
|
private String partDesc; |
||||
|
|
||||
|
@ApiModelProperty(value = "备注") |
||||
|
private String remark; |
||||
|
|
||||
|
@ApiModelProperty(value = "创建人") |
||||
|
private String createBy; |
||||
|
|
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
@ApiModelProperty(value = "创建时间") |
||||
|
private Date createDate; |
||||
|
|
||||
|
@ApiModelProperty(value = "修改人") |
||||
|
private String updateBy; |
||||
|
|
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
@ApiModelProperty(value = "修改时间") |
||||
|
private Date updateDate; |
||||
|
|
||||
|
@ApiModelProperty(value = "NPC货号") |
||||
|
private String npc; |
||||
|
|
||||
|
@ApiModelProperty(value = "产品规格") |
||||
|
private String partSpec; |
||||
|
|
||||
|
@ApiModelProperty(value = "采购员名称") |
||||
|
private String buyerName; |
||||
|
|
||||
|
@ApiModelProperty(value = "采购员id") |
||||
|
private Integer buyerId; |
||||
|
|
||||
|
@ApiModelProperty(value = "sourcing负责人名称") |
||||
|
private String sourcingName; |
||||
|
|
||||
|
@ApiModelProperty(value = "sourcing负责人id") |
||||
|
private Integer sourcingId; |
||||
|
|
||||
|
@ApiModelProperty(value = "产品分类") |
||||
|
private String category; |
||||
|
|
||||
|
@ApiModelProperty(value = "计量单位") |
||||
|
private String unit; |
||||
|
|
||||
|
@ApiModelProperty(value = "状态(启用N,禁用Y)") |
||||
|
private String status; |
||||
|
|
||||
|
@ApiModelProperty(value = "属性模板") |
||||
|
private String codeNo; |
||||
|
|
||||
|
private Integer id; |
||||
|
|
||||
|
public Object getKey() { |
||||
|
return this.id; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,85 @@ |
|||||
|
<?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.xujie.modules.part.dao.PartMapper"> |
||||
|
|
||||
|
<!-- 通用查询映射结果 --> |
||||
|
<resultMap id="BaseResultMap" type="com.xujie.modules.part.entity.Part"> |
||||
|
<id column="id" property="id" /> |
||||
|
<result column="site" property="site" /> |
||||
|
<result column="part_no" property="partNo" /> |
||||
|
<result column="part_desc" property="partDesc" /> |
||||
|
<result column="remark" property="remark" /> |
||||
|
<result column="create_by" property="createBy" /> |
||||
|
<result column="create_date" property="createDate" /> |
||||
|
<result column="update_by" property="updateBy" /> |
||||
|
<result column="update_date" property="updateDate" /> |
||||
|
<result column="npc" property="npc" /> |
||||
|
<result column="part_spec" property="partSpec" /> |
||||
|
<result column="buyer_name" property="buyerName" /> |
||||
|
<result column="buyer_id" property="buyerId" /> |
||||
|
<result column="sourcing_name" property="sourcingName" /> |
||||
|
<result column="sourcing_id" property="sourcingId" /> |
||||
|
<result column="category" property="category" /> |
||||
|
<result column="unit" property="unit" /> |
||||
|
<result column="status" property="status" /> |
||||
|
<result column="code_no" property="codeNo" /> |
||||
|
</resultMap> |
||||
|
|
||||
|
<!-- 通用查询结果列 --> |
||||
|
<sql id="BaseColumnList"> |
||||
|
site, part_no, part_desc, remark, create_by, create_date, update_by, update_date, npc, part_spec, buyer_name, buyer_id, sourcing_name, sourcing_id, category, unit, status, code_no, id |
||||
|
</sql> |
||||
|
|
||||
|
<select id="getListByModel" resultType="com.xujie.modules.part.entity.Part"> |
||||
|
select <include refid="BaseColumnList" /> |
||||
|
from part |
||||
|
where 1=1 |
||||
|
<if test="site != null and site != '' "> and site = #{site}</if> |
||||
|
<if test="partNo != null and partNo != '' "> and part_no = #{partNo}</if> |
||||
|
<if test="partDesc != null and partDesc != '' "> and part_desc = #{partDesc}</if> |
||||
|
<if test="remark != null and remark != '' "> and remark = #{remark}</if> |
||||
|
<if test="createBy != null and createBy != '' "> and create_by = #{createBy}</if> |
||||
|
<if test="createDate != null and createDate != '' "> and create_date = #{createDate}</if> |
||||
|
<if test="updateBy != null and updateBy != '' "> and update_by = #{updateBy}</if> |
||||
|
<if test="updateDate != null and updateDate != '' "> and update_date = #{updateDate}</if> |
||||
|
<if test="npc != null and npc != '' "> and npc = #{npc}</if> |
||||
|
<if test="partSpec != null and partSpec != '' "> and part_spec = #{partSpec}</if> |
||||
|
<if test="buyerName != null and buyerName != '' "> and buyer_name = #{buyerName}</if> |
||||
|
<if test="buyerId != null "> and buyer_id = #{buyerId}</if> |
||||
|
<if test="sourcingName != null and sourcingName != '' "> and sourcing_name = #{sourcingName}</if> |
||||
|
<if test="sourcingId != null "> and sourcing_id = #{sourcingId}</if> |
||||
|
<if test="category != null and category != '' "> and category = #{category}</if> |
||||
|
<if test="unit != null and unit != '' "> and unit = #{unit}</if> |
||||
|
<if test="status != null "> and status = #{status}</if> |
||||
|
<if test="codeNo != null and codeNo != '' "> and code_no = #{codeNo}</if> |
||||
|
<if test="id != null "> and id = #{id}</if> |
||||
|
ORDER BY id |
||||
|
</select> |
||||
|
|
||||
|
<select id="myPage" resultType="com.xujie.modules.part.entity.Part"> |
||||
|
select |
||||
|
<include refid="BaseColumnList"/> |
||||
|
from part |
||||
|
where site = '${query.site}' |
||||
|
<if test="query.id != null "> and id = '${query.id}'</if> |
||||
|
<if test="query.partNo != null and query.partNo != '' "> and part_no like '%${query.partNo}%'</if> |
||||
|
<if test="query.partDesc != null and query.partDesc != '' "> and part_desc like '%${query.partDesc}%'</if> |
||||
|
<if test="query.remark != null and query.remark != '' "> and remark like '%${query.remark}%'</if> |
||||
|
<if test="query.createBy != null and query.createBy != '' "> and create_by like '%${query.createBy}%'</if> |
||||
|
<if test="query.createDate != null "> and create_date like '%${query.createDate}%'</if> |
||||
|
<if test="query.updateBy != null and query.updateBy != '' "> and update_by like '%${query.updateBy}%'</if> |
||||
|
<if test="query.updateDate != null "> and update_date like '%${query.updateDate}%'</if> |
||||
|
<if test="query.npc != null and query.npc != '' "> and npc like '%${query.npc}%'</if> |
||||
|
<if test="query.partSpec != null and query.partSpec != '' "> and part_spec like '%${query.partSpec}%'</if> |
||||
|
<if test="query.buyerName != null and query.buyerName != '' "> and buyer_name like '%${query.buyerName}%'</if> |
||||
|
<if test="query.buyerId != null "> and buyer_id = '${query.buyerId}'</if> |
||||
|
<if test="query.sourcingName != null and query.sourcingName != '' "> and sourcing_name like '%${query.sourcingName}%'</if> |
||||
|
<if test="query.sourcingId != null "> and sourcing_id = '${query.sourcingId}'</if> |
||||
|
<if test="query.category != null and query.category != '' "> and category like '%${query.category}%'</if> |
||||
|
<if test="query.unit != null and query.unit != '' "> and unit like '%${query.unit}%'</if> |
||||
|
<if test="query.status != null and query.status != ''"> and status = '${query.status}'</if> |
||||
|
<if test="query.codeNo != null and query.codeNo != '' "> and code_no like '%${query.codeNo}%'</if> |
||||
|
ORDER BY id |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue