From 79828b3a3174ceccf3445a9364f708ecf1712c8f Mon Sep 17 00:00:00 2001 From: liding <756868258@qq.com> Date: 星期五, 30 五月 2025 17:59:45 +0800 Subject: [PATCH] 供应商 --- /dev/null | 16 -- basic-server/src/main/java/com/ruoyi/basic/service/impl/SupplyServiceImpl.java | 78 +++++++++++++ basic-server/src/main/java/com/ruoyi/basic/controller/SupplyController.java | 55 +++++++++ basic-server/src/main/java/com/ruoyi/basic/dto/SupplyDto.java | 8 + ruoyi-admin/src/main/java/com/ruoyi/PlusCodeGenerator.java | 6 basic-server/src/main/java/com/ruoyi/basic/entity/Supply.java | 74 ++++++++++++ basic-server/src/main/java/com/ruoyi/basic/service/SupplyService.java | 26 ++++ basic-server/src/main/java/com/ruoyi/basic/mapper/SupplyMapper.java | 18 +++ basic-server/src/main/resources/mapper/SupplyMapper.xml | 35 +++++ 9 files changed, 297 insertions(+), 19 deletions(-) diff --git a/basic-server/src/main/java/com/ruoyi/basic/controller/SupplyController.java b/basic-server/src/main/java/com/ruoyi/basic/controller/SupplyController.java new file mode 100644 index 0000000..700cbb4 --- /dev/null +++ b/basic-server/src/main/java/com/ruoyi/basic/controller/SupplyController.java @@ -0,0 +1,55 @@ +package com.ruoyi.basic.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.basic.dto.SupplyDto; +import com.ruoyi.basic.entity.Supply; +import com.ruoyi.basic.service.SupplyService; +import com.ruoyi.common.core.domain.R; +import org.springframework.web.bind.annotation.*; +import lombok.AllArgsConstructor; + +import java.util.List; + +/** + * <p> + * 渚涘簲鍟嗕俊鎭〃 鍓嶇鎺у埗鍣� + * </p> + * + * @author ruoyi + * @since 2025-05-30 + */ + +@RestController +@AllArgsConstructor +@RequestMapping("/basic/supply") +public class SupplyController { + + private SupplyService supplyService; + + /** + * 鏌ヨ + */ + @GetMapping("/list") + public R<IPage<Supply>> list(Page page,SupplyDto supplyDto) { + IPage<Supply> list = supplyService.selectSupplyList(page,supplyDto); + return R.ok(list); + } + + /** + * 鏂板淇敼 + */ + @PostMapping("/addOrEditSupply") + public R addOrEditSupply(@RequestBody SupplyDto supplyDto) { + return R.ok(supplyService.addOrEditSupply(supplyDto)); + } + + /** + * 鍒犻櫎 + */ + @DeleteMapping("/delSupply") + public R remove(@RequestBody Long[] ids) { + return R.ok(supplyService.delSupplyByIds(ids)); + } + +} diff --git a/basic-server/src/main/java/com/ruoyi/basic/controller/TestController1.java b/basic-server/src/main/java/com/ruoyi/basic/controller/TestController1.java deleted file mode 100644 index 6fdddd8..0000000 --- a/basic-server/src/main/java/com/ruoyi/basic/controller/TestController1.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ruoyi.basic.controller; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - - -@RestController -@RequestMapping("test") -public class TestController1 { - - @GetMapping("/list") - public void ss(){ - System.out.println("1111"); - } -} diff --git a/basic-server/src/main/java/com/ruoyi/basic/dto/SupplyDto.java b/basic-server/src/main/java/com/ruoyi/basic/dto/SupplyDto.java new file mode 100644 index 0000000..2c2d085 --- /dev/null +++ b/basic-server/src/main/java/com/ruoyi/basic/dto/SupplyDto.java @@ -0,0 +1,8 @@ +package com.ruoyi.basic.dto; + +import com.ruoyi.basic.entity.Supply; +import lombok.Data; + +@Data +public class SupplyDto extends Supply { +} diff --git a/basic-server/src/main/java/com/ruoyi/basic/entity/Supply.java b/basic-server/src/main/java/com/ruoyi/basic/entity/Supply.java new file mode 100644 index 0000000..f174c36 --- /dev/null +++ b/basic-server/src/main/java/com/ruoyi/basic/entity/Supply.java @@ -0,0 +1,74 @@ +package com.ruoyi.basic.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.ruoyi.common.core.domain.MyBaseEntity; +import lombok.Data; + +/** + * 渚涘簲鍟嗕俊鎭〃 瀹炰綋绫� + * + * @author ruoyi + * @date 2025-05-30 + */ +@Data +@TableName("supply") +public class Supply extends MyBaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 渚涘簲鍟嗗敮涓�鏍囪瘑锛岄噰鐢˙IGSERIAL鑷涓婚敭锛岀‘淇濇暟鎹敮涓�鎬� + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + /** + * 渚涘簲鍟嗗叏绉帮紝涓氬姟鍦烘櫙涓敮涓�璇嗗埆鐨勫悕绉帮紝 + */ + @TableField(value = "supplier_name") + private String supplierName; + /** + * 渚涘簲鍟嗙◣鍔$櫥璁板敮涓�鏍囪瘑锛堝缁熶竴绀句細淇$敤浠g爜锛夛紝鐢ㄤ簬璐㈢◣绠$悊 + */ + @TableField(value = "taxpayer_id") + private String taxpayerId; + /** + * 渚涘簲鍟嗚惀涓氭墽鐓ф敞鍐屽湴鍧�鎴栦富瑕佺粡钀ュ満鎵�锛岄粯璁ょ┖瀛楃涓� + */ + @TableField(value = "business_address") + private String businessAddress; + /** + * 渚涘簲鍟嗘敹娆鹃摱琛岃处鎴蜂俊鎭紝榛樿绌哄瓧绗︿覆锛岀敤浜庤祫閲戝線鏉� + */ + @TableField(value = "bank_account") + private String bankAccount; + /** + * 渚涘簲鍟嗛摱琛岃处鎴风殑寮�鎴锋満鏋勫悕绉帮紝榛樿绌哄瓧绗︿覆锛� + */ + @TableField(value = "bank_name") + private String bankName; + /** + * 渚涘簲鍟嗕笟鍔″鎺ヤ汉濮撳悕 + */ + @TableField(value = "contact_person") + private String contactPerson; + /** + * 渚涘簲鍟嗚仈绯讳汉鐨勮仈绯诲湴鍧� + */ + @TableField(value = "contact_address") + private String contactAddress; + /** + * 渚涘簲鍟嗘墍鍦ㄧ渷浠界殑ID锛堝叧鑱斿湴鍧�瀛楀吀琛級锛岄粯璁�0 + */ + @TableField(value = "province_id") + private Long provinceId; + /** + * 渚涘簲鍟嗘墍鍦ㄥ煄甯傜殑ID锛堝叧鑱斿湴鍧�瀛楀吀琛級锛岄粯璁�0 + */ + @TableField(value = "city_id") + private Long cityId; + /** + * 渚涘簲鍟嗘墍鍦ㄥ尯鍘跨殑ID锛堝叧鑱斿湴鍧�瀛楀吀琛級锛岄粯璁�0锛岀敤浜庡湴鍧�灞傜骇鍒掑垎 + */ + @TableField(value = "district_id") + private Long districtId; +} \ No newline at end of file diff --git a/basic-server/src/main/java/com/ruoyi/basic/mapper/SupplyMapper.java b/basic-server/src/main/java/com/ruoyi/basic/mapper/SupplyMapper.java new file mode 100644 index 0000000..d65d889 --- /dev/null +++ b/basic-server/src/main/java/com/ruoyi/basic/mapper/SupplyMapper.java @@ -0,0 +1,18 @@ +package com.ruoyi.basic.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.basic.entity.Supply; +import org.apache.ibatis.annotations.Mapper; + +/** + * <p> + * 渚涘簲鍟嗕俊鎭〃 Mapper 鎺ュ彛 + * </p> + * + * @author ruoyi + * @since 2025-05-30 + */ +@Mapper +public interface SupplyMapper extends BaseMapper<Supply> { + +} diff --git a/basic-server/src/main/java/com/ruoyi/basic/service/SupplyService.java b/basic-server/src/main/java/com/ruoyi/basic/service/SupplyService.java new file mode 100644 index 0000000..bb36ad7 --- /dev/null +++ b/basic-server/src/main/java/com/ruoyi/basic/service/SupplyService.java @@ -0,0 +1,26 @@ +package com.ruoyi.basic.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.basic.dto.SupplyDto; +import com.ruoyi.basic.entity.Supply; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** + * <p> + * 渚涘簲鍟嗕俊鎭〃 鏈嶅姟绫� + * </p> + * + * @author ruoyi + * @since 2025-05-30 + */ +public interface SupplyService extends IService<Supply> { + + IPage<Supply> selectSupplyList(Page page, SupplyDto supplyDto); + + int addOrEditSupply(SupplyDto supplyDto); + + int delSupplyByIds(Long[] ids); +} diff --git a/basic-server/src/main/java/com/ruoyi/basic/service/impl/SupplyServiceImpl.java b/basic-server/src/main/java/com/ruoyi/basic/service/impl/SupplyServiceImpl.java new file mode 100644 index 0000000..d3ee17e --- /dev/null +++ b/basic-server/src/main/java/com/ruoyi/basic/service/impl/SupplyServiceImpl.java @@ -0,0 +1,78 @@ +package com.ruoyi.basic.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.basic.dto.SupplyDto; +import com.ruoyi.basic.entity.Supply; +import com.ruoyi.basic.mapper.SupplyMapper; +import com.ruoyi.basic.service.SupplyService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.utils.bean.BeanUtils; +import org.springframework.stereotype.Service; +import lombok.RequiredArgsConstructor; +import org.springframework.util.StringUtils; + +import java.util.List; +import java.util.Objects; + +/** + * <p> + * 渚涘簲鍟嗕俊鎭〃 鏈嶅姟瀹炵幇绫� + * </p> + * + * @author ruoyi + * @since 2025-05-30 + */ +@Service +@RequiredArgsConstructor +public class SupplyServiceImpl extends ServiceImpl<SupplyMapper, Supply> implements SupplyService { + + private final SupplyMapper supplyMapper; + + @Override + public IPage<Supply> selectSupplyList(Page page, SupplyDto supplyDto) { + LambdaQueryWrapper<Supply> queryWrapper = new LambdaQueryWrapper<>(); + + // 渚涘簲鍟嗗悕绉版ā绯婃煡璇� + if (StringUtils.hasText(supplyDto.getSupplierName())) { + queryWrapper.like(Supply::getSupplierName, supplyDto.getSupplierName()); + } + + // 绾崇◣浜鸿瘑鍒彿绮剧‘鏌ヨ + if (StringUtils.hasText(supplyDto.getTaxpayerId())) { + queryWrapper.eq(Supply::getTaxpayerId, supplyDto.getTaxpayerId()); + } + + queryWrapper.orderByDesc(Supply::getCreateTime); + return supplyMapper.selectPage(page, queryWrapper); + } + + @Override + public int addOrEditSupply(SupplyDto supplyDto) { + Supply supply = new Supply(); + BeanUtils.copyProperties(supplyDto, supply); + if (Objects.isNull(supplyDto.getId())) { + return supplyMapper.insert(supply); + } else { + return supplyMapper.updateById(supply); + } + } + + @Override + public int delSupplyByIds(Long[] ids) { + // 妫�鏌ュ弬鏁� + if (ids == null || ids.length == 0) { + return 0; + } + + // 鏋勯�犳洿鏂版潯浠� + UpdateWrapper<Supply> updateWrapper = new UpdateWrapper<>(); + updateWrapper.in("id", ids) + .set("deleted", 1); // 璁剧疆 deleted 涓� 1 琛ㄧず宸插垹闄� + + // 鎵ц鎵归噺閫昏緫鍒犻櫎 + return supplyMapper.update(null, updateWrapper); + } +} diff --git a/basic-server/src/main/resources/mapper/SupplyMapper.xml b/basic-server/src/main/resources/mapper/SupplyMapper.xml new file mode 100644 index 0000000..13ba9a6 --- /dev/null +++ b/basic-server/src/main/resources/mapper/SupplyMapper.xml @@ -0,0 +1,35 @@ +<?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.ruoyi.basic.mapper.SupplyMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="BaseResultMap" type="com.ruoyi.basic.entity.Supply"> + <id column="id" property="id" /> + <result column="create_time" property="createTime" /> + <result column="deleted" property="deleted" /> + <result column="update_time" property="updateTime" /> + <result column="create_by" property="createBy" /> + <result column="update_by" property="updateBy" /> + <result column="supplier_name" property="supplierName" /> + <result column="taxpayer_id" property="taxpayerId" /> + <result column="business_address" property="businessAddress" /> + <result column="bank_account" property="bankAccount" /> + <result column="bank_name" property="bankName" /> + <result column="contact_person" property="contactPerson" /> + <result column="contact_address" property="contactAddress" /> + <result column="province_id" property="provinceId" /> + <result column="city_id" property="cityId" /> + <result column="district_id" property="districtId" /> + </resultMap> + + <!-- 閫氱敤鏌ヨ缁撴灉鍒� --> + <sql id="Base_Column_List"> + create_time, + deleted, + update_time, + create_by, + update_by, + id, supplier_name, taxpayer_id, business_address, bank_account, bank_name, contact_person, contact_address, province_id, city_id, district_id + </sql> + +</mapper> \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/PlusCodeGenerator.java b/ruoyi-admin/src/main/java/com/ruoyi/PlusCodeGenerator.java index 9945e44..51c701b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/PlusCodeGenerator.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/PlusCodeGenerator.java @@ -38,8 +38,8 @@ public static void main(String[] args) { String projectPath = System.getProperty("user.dir"); // 鑾峰彇椤圭洰鏍硅矾寰� - String path = "ruoyi-common"; // 妯″潡鍚嶇О - String table = "storage_attachment"; // 琛ㄥ悕锛屽涓〃閫楀彿闅斿紑 + String path = "basic-server"; // 妯″潡鍚嶇О + String table = "supply"; // 琛ㄥ悕锛屽涓〃閫楀彿闅斿紑 // 浠g爜杈撳嚭璺緞閰嶇疆 String outputBasePath = Paths.get(projectPath, path, "src", "main", "java").toString(); @@ -48,7 +48,7 @@ // 浠g爜鐢熸垚鏍稿績閰嶇疆 FastAutoGenerator.create(DB_URL, DB_USERNAME, DB_PASSWORD) .globalConfig(builder -> { - builder.author("chen") // 浣滆�呬俊鎭� + builder.author("ld") // 浣滆�呬俊鎭� .outputDir(outputBasePath) // 浠g爜杈撳嚭鐩綍 .dateType(DateType.ONLY_DATE) // 鏃ユ湡绫诲瀷 .commentDate("yyyy-MM-dd") // 娉ㄩ噴鏃ユ湡鏍煎紡 -- Gitblit v1.9.3