diff --git a/src/main/java/com/xujie/modules/part/controller/PartController.java b/src/main/java/com/xujie/modules/part/controller/PartController.java new file mode 100644 index 0000000..772e0e2 --- /dev/null +++ b/src/main/java/com/xujie/modules/part/controller/PartController.java @@ -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; + +/** + *

+ * API + *

+ * + * @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 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(); + } + +} diff --git a/src/main/java/com/xujie/modules/part/dao/PartMapper.java b/src/main/java/com/xujie/modules/part/dao/PartMapper.java new file mode 100644 index 0000000..0a84e1d --- /dev/null +++ b/src/main/java/com/xujie/modules/part/dao/PartMapper.java @@ -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; + +/** + *

+ * Mapper 接口 + *

+ * + * @author jyy + * @since 2026-03-09 + */ +@Mapper +public interface PartMapper extends BaseMapper { + + List getListByModel(Part data); + + IPage myPage(Page page, @Param("query") Part data); + +} diff --git a/src/main/java/com/xujie/modules/part/entity/Part.java b/src/main/java/com/xujie/modules/part/entity/Part.java new file mode 100644 index 0000000..aadb435 --- /dev/null +++ b/src/main/java/com/xujie/modules/part/entity/Part.java @@ -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; + +/** + *

+ * + *

+ * + * @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; + } +} diff --git a/src/main/java/com/xujie/modules/part/service/Iface/IPartService.java b/src/main/java/com/xujie/modules/part/service/Iface/IPartService.java new file mode 100644 index 0000000..3d5d22e --- /dev/null +++ b/src/main/java/com/xujie/modules/part/service/Iface/IPartService.java @@ -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; + +/** + *

+ * 服务类 + *

+ * + * @author jyy + * @since 2026-03-09 + */ +public interface IPartService extends IService { + + void saveModel(Part model); + + PageUtils myPage(Part page); + + List getListByModel(Part query); + + Part get(Part model); + + void delete(Part model); +} diff --git a/src/main/java/com/xujie/modules/part/service/Impl/PartServiceImpl.java b/src/main/java/com/xujie/modules/part/service/Impl/PartServiceImpl.java new file mode 100644 index 0000000..eeefe82 --- /dev/null +++ b/src/main/java/com/xujie/modules/part/service/Impl/PartServiceImpl.java @@ -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; + +/** + *

+ * 服务实现类 + *

+ * + * @author jyy + * @since 2026-03-09 + */ +@Service +public class PartServiceImpl extends ServiceImpl 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 getListByModel(Part query){ + return baseMapper.getListByModel(query); + } + + + @Override + public PageUtils myPage(Part data){ + IPage resultList = baseMapper.myPage(new Page(data.getPage(), data.getLimit()), data); + return new PageUtils(resultList); + } + + @Override + public Part get(Part model){ + List 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()); + } + +} diff --git a/src/main/java/com/xujie/modules/part/vo/PartVo.java b/src/main/java/com/xujie/modules/part/vo/PartVo.java new file mode 100644 index 0000000..9db48c0 --- /dev/null +++ b/src/main/java/com/xujie/modules/part/vo/PartVo.java @@ -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; + +/** + *

+ * + *

+ * + * @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; + } +} diff --git a/src/main/resources/mapper/part/mapperXml/PartMapper.xml b/src/main/resources/mapper/part/mapperXml/PartMapper.xml new file mode 100644 index 0000000..1954ee2 --- /dev/null +++ b/src/main/resources/mapper/part/mapperXml/PartMapper.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + +