11.25超市

master
hanmou 2023-11-25 08:11:48 +08:00
parent 952f713c9e
commit 9bc401daa5
15 changed files with 502 additions and 1 deletions

View File

@ -7,6 +7,7 @@
<file url="file://$PROJECT_DIR$/bwie-common/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-gateway/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-gateway/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-models/bwie-merch/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-models/bwie-system/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-models/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-models/src/main/resources" charset="UTF-8" />

View File

@ -0,0 +1,31 @@
package com.bwie.common.domain;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @ClassName Import
* @Description
* @Author XingHua.Han
* @Date 2023/11/24 14:44
*/
@Data
public class Import {
private Integer importId;
private Integer merchId;
private Integer planNum;
private Date importTime;
private Integer merchName;
private String merchType;
private BigDecimal merchPrice;
private String barCode;
private BigDecimal salesProPrice;
private Date merchDeadTime;
private Integer merchNum;
private Integer merchSta;
}

View File

@ -0,0 +1,26 @@
package com.bwie.common.domain;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @ClassName Merch
* @Description
* @Author XingHua.Han
* @Date 2023/11/24 9:25
*/
@Data
public class Merch {
private Integer merchId;
private String merchName;
private String merchType;
private BigDecimal merchPrice;
private String barCode;
private BigDecimal salesProPrice;
private Date merchDeadTime;
private Integer merchNum;
private Integer merchSta;
}

View File

@ -0,0 +1,23 @@
package com.bwie.common.domain.dto;
/**
* @ClassName MerchIns
* @Description
* @Author XingHua.Han
* @Date 2023/11/24 9:30
*/
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class MerchIns {
private String merchName;
private String merchType;
private BigDecimal merchPrice;
private String barCode;
private BigDecimal salesProPrice;
private Date merchDeadTime;
}

View File

@ -0,0 +1,15 @@
package com.bwie.common.domain.dto;
import lombok.Data;
/**
* @ClassName MerchRestock
* @Description
* @Author XingHua.Han
* @Date 2023/11/24 14:38
*/
@Data
public class MerchRestock {
private Integer merchId;
private Integer restockNum;
}

View File

@ -0,0 +1,23 @@
package com.bwie.common.domain.dto;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @ClassName MerchUpd
* @Description
* @Author XingHua.Han
* @Date 2023/11/24 14:07
*/
@Data
public class MerchUpd {
private Integer merchId;
private String merchName;
private String merchType;
private BigDecimal merchPrice;
private String barCode;
private BigDecimal salesProPrice;
private Date merchDeadTime;
}

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bwie</groupId>
<artifactId>bwie-models</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>bwie-merch</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 系统公共 依赖 -->
<dependency>
<groupId>com.bwie</groupId>
<artifactId>bwie-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- SpringBoot Web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.8</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- Mybatis 依赖配置 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
<!-- Pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.1</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,17 @@
package com.bwie.merch;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @ClassName MerchApp
* @Description
* @Author XingHua.Han
* @Date 2023/11/24 15:50
*/
@SpringBootApplication
public class MerchApp {
public static void main(String[] args) {
SpringApplication.run(MerchApp.class);
}
}

View File

@ -0,0 +1,58 @@
package com.bwie.merch.controller;
import com.bwie.common.domain.dto.MerchIns;
import com.bwie.common.domain.dto.MerchRestock;
import com.bwie.common.domain.dto.MerchUpd;
import com.bwie.common.result.Result;
import com.bwie.merch.service.MerchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
/**
* @ClassName MerchController
* @Description
* @Author XingHua.Han
* @Date 2023/11/24 9:17
*/
@RestController
public class MerchController {
@Autowired
private MerchService merchService;
@PostMapping("allShow")
public Result allShow() {
Result result = merchService.allShow();
return result;
}
@PostMapping("insert")
public Result insert(@RequestBody MerchIns merchIns){
Result result = merchService.insert(merchIns);
return result;
}
@PostMapping("delete/{merchId}")
public Result delete(@RequestBody String merchId){
Result result = merchService.delete(merchId);
return result;
}
@PostMapping("update")
public Result update(@RequestBody MerchUpd merchUpd){
Result result = merchService.update(merchUpd);
return result;
}
@PostMapping("listing/merchId")
public Result listing(@RequestBody String merchId){
Result result = merchService.listing(merchId);
return result;
}
@PostMapping("restock")
public Result restock(@RequestBody MerchRestock merchRestock){
Result result = merchService.restock(merchRestock);
return result;
}
@PostMapping("importAllShow")
public Result importAllShow(){
Result result = merchService.importAllShow();
return result;
}
}

View File

@ -0,0 +1,40 @@
package com.bwie.merch.mapper;
import com.bwie.common.domain.Import;
import com.bwie.common.domain.Merch;
import com.bwie.common.domain.dto.MerchIns;
import com.bwie.common.domain.dto.MerchRestock;
import com.bwie.common.domain.dto.MerchUpd;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @ClassName MerchMapper
* @Description
* @Author XingHua.Han
* @Date 2023/11/24 9:23
*/
@Mapper
public interface MerchMapper {
List<Merch> allShow();
void insert(MerchIns merchIns);
void delete(@Param("merchId") String merchId);
void update(MerchUpd merchUpd);
Merch findById(@Param("merchId") String merchId);
void listing(@Param("merchId") String merchId, @Param("i") int i);
void restock(MerchRestock merchRestock);
void insertImport(MerchRestock merchRestock);
List<Import> importAllShow();
}

View File

@ -0,0 +1,30 @@
package com.bwie.merch.service;
import com.bwie.common.domain.dto.MerchIns;
import com.bwie.common.domain.dto.MerchRestock;
import com.bwie.common.domain.dto.MerchUpd;
import com.bwie.common.result.Result;
import org.springframework.web.bind.annotation.RestController;
/**
* @ClassName MercherService
* @Description
* @Author XingHua.Han
* @Date 2023/11/24 9:22
*/
@RestController
public interface MerchService {
Result allShow();
Result insert(MerchIns merchIns);
Result delete(String merchId);
Result update(MerchUpd merchUpd);
Result listing(String merchId);
Result restock(MerchRestock merchRestock);
Result importAllShow();
}

View File

@ -0,0 +1,74 @@
package com.bwie.merch.service.impl;
import com.bwie.common.domain.Import;
import com.bwie.common.domain.Merch;
import com.bwie.common.domain.dto.MerchIns;
import com.bwie.common.domain.dto.MerchRestock;
import com.bwie.common.domain.dto.MerchUpd;
import com.bwie.common.result.Result;
import com.bwie.merch.mapper.MerchMapper;
import com.bwie.merch.service.MerchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @ClassName MerchServiceImpl
* @Description
* @Author XingHua.Han
* @Date 2023/11/24 9:23
*/
@Service
public class MerchServiceImpl implements MerchService {
@Autowired
private MerchMapper merchMapper;
@Override
public Result allShow() {
List<Merch> merchList = merchMapper.allShow();
return Result.success(merchList);
}
@Override
public Result insert(MerchIns merchIns) {
merchMapper.insert(merchIns);
return Result.success();
}
@Override
public Result delete(String merchId) {
merchMapper.delete(merchId);
return Result.success();
}
@Override
public Result update(MerchUpd merchUpd) {
merchMapper.update(merchUpd);
return Result.success();
}
@Override
public Result listing(String merchId) {
Merch merch = merchMapper.findById(merchId);
if(merch.getMerchSta()==1){
merchMapper.listing(merchId,2);
}else{
merchMapper.listing(merchId,1);
}
return Result.success();
}
@Override
public Result restock(MerchRestock merchRestock) {
merchMapper.restock(merchRestock);
merchMapper.insertImport(merchRestock);
return Result.success();
}
@Override
public Result importAllShow() {
List<Import> list = merchMapper.importAllShow();
return Result.success(list);
}
}

View File

@ -0,0 +1,30 @@
# Tomcat
server:
port: 9003
# Spring
spring:
main:
allow-circular-references: true
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
application:
# 应用名称
name: bwie-merch
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 111.229.204.42:8848
config:
# 配置中心地址
server-addr: 111.229.204.42:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: 6296b935-334a-42d6-84cf-508ca67756de

View File

@ -0,0 +1,77 @@
<?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">
<!--
1.在mybats的开发中namespace有特殊的意思一定要是对应接口的全限定名
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
-->
<mapper namespace="com.bwie.merch.mapper.MerchMapper">
<insert id="insert">
INSERT INTO `zhuangao5`.`t_merch`
(`merch_name`,
`merch_type`,
`merch_price`,
`bar_code`,
`sales_pro_price`,
`merch_dead_time`,
`merch_num`,
`merch_sta`)
VALUES (#{merchName},
#{merchType},
#{merchPrice},
#{barCode},
#{salesProPrice},
#{merchDeadTime},
0,
2);
</insert>
<insert id="insertImport">
INSERT INTO `zhuangao5`.`t_import`
( `merch_id`, `plan_num`, `import_time`)
VALUES ( #{merchId}, #{restockNum}, now());
</insert>
<update id="update">
update t_merch set
merch_name=#{merchName},
merch_type=#{merchType},
merch_price=#{merchPrice},
bar_code=#{barCode},
sales_pro_price=#{salesProPrice},
merch_dead_time=#{merchDeadTime}
where
merch_id=#{merchId}
</update>
<update id="listing">
update t_merch set
merch_sta= #{i}
where
merch_id=#{merchId}
</update>
<update id="restock">
update t_merch set
merch_num=merch_num+#{restockNum}
where
merch_id=#{merchId}
</update>
<delete id="delete">
delete from t_merch where merch_id=#{merchId}
</delete>
<!-- 添加 -->
<select id="allShow" resultType="com.bwie.common.domain.Merch">
select * from t_merch
</select>
<select id="findById" resultType="com.bwie.common.domain.Merch">
select * from t_merch where merch_id=#{merchId}
</select>
<select id="importAllShow" resultType="com.bwie.common.domain.Import">
select * from t_import i left join t_merch m on i.merch_id = m.merch_id
</select>
</mapper>

View File

@ -13,6 +13,7 @@
<packaging>pom</packaging>
<modules>
<module>bwie-system</module>
<module>bwie-merch</module>
</modules>
<properties>
@ -21,4 +22,4 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
</project>