master
李永杰 2023-11-26 14:10:13 +08:00
parent 95f140bff0
commit add4f9d5e6
33 changed files with 1058 additions and 14 deletions

View File

@ -147,12 +147,25 @@ create table tb_import(
list_id int(11) comment '表单编号' primary key auto_increment, list_id int(11) comment '表单编号' primary key auto_increment,
merch_id int(11) comment '商品编号', merch_id int(11) comment '商品编号',
merch_name varchar(20) comment '商品名称', merch_name varchar(20) comment '商品名称',
merch_type varchar(10) comment '商品类型', type_ids varchar(10) comment '商品类型',
merch_price decimal(4,2) comment '价格', merch_price decimal(4,2) comment '价格',
plan_num int(4) comment '计划进货数', plan_num int(4) comment '计划进货数',
import_date date comment '进货日期', import_date date comment '进货日期',
provide_id varchar(10) comment '供货商编号' provide_id varchar(10) comment '供货商编号'
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='进货表'; )ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='进货表';
insert into tb_import (merch_id, merch_name, type_ids, merch_price, plan_num, import_date, provide_id) values ('1','青芒',1,20,400,'2023-11-20 9:00',1);
select list_id,merch_id, merch_name, type_ids, merch_price, plan_num, import_date, provide_id from tb_import;
-- 供货商表
drop table if exists tb_provide;
create table tb_provide(
provide_id int(11) comment '供货商编号' primary key auto_increment,
provide_name varchar(55) comment '供货商名称'
)ENGINE=InnoDB DEFAULT CHARSET = utf8 COLLATE=utf8_general_ci COMMENT='供货商表';
insert into tb_provide (provide_name) values ('供货商1');
insert into tb_provide (provide_name) values ('供货商2');
insert into tb_provide (provide_name) values ('供货商3');
select provide_id, provide_name from tb_provide;
-- 销售表 -- 销售表
drop table if exists tb_sale_list; drop table if exists tb_sale_list;

View File

@ -0,0 +1,52 @@
package com.bwie.common.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.common.domain
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/24
* @Version 1.0
*/
@Data
public class Import {
/**
*
*/
private Integer listId;
/**
*
*/
private Integer merchId;
/**
*
*/
private String merchName;
/**
*
*/
private String typeIds;
/**
*
*/
private BigDecimal merchPrice;
/**
*
*/
private Integer planNum;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date importDate;
/**
*
*/
private String provideId;
}

View File

@ -2,11 +2,14 @@ package com.bwie.common.domain;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @ProjectName: GG-market * @ProjectName: GG-market
@ -17,6 +20,8 @@ import java.util.Date;
* @Version 1.0 * @Version 1.0
*/ */
@Data @Data
@Getter
@Setter
public class Merch implements Serializable { public class Merch implements Serializable {
/** /**
* *
@ -29,7 +34,7 @@ public class Merch implements Serializable {
/** /**
* *
*/ */
private Integer merchType; private String typeIds;
/** /**
* *
*/ */

View File

@ -0,0 +1,52 @@
package com.bwie.common.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.common.domain
* @Description TODO 退
* @Author LiYonJie
* @Date 2023/11/24
* @Version 1.0
*/
@Data
public class Returns {
/**
*
*/
private Integer listId;
/**
*
*/
private Integer merchId;
/**
*
*/
private String merchName;
/**
*
*/
private String typeIds;
/**
*
*/
private BigDecimal merchPrice;
/**
* 退
*/
private Integer planNum;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date returnsDate;
/**
*
*/
private String provideId;
}

View File

@ -1,7 +1,12 @@
package com.bwie.common.domain; package com.bwie.common.domain;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.List;
/** /**
* @ProjectName: GG-market * @ProjectName: GG-market
* @PackageName: com.bwie.common.domain * @PackageName: com.bwie.common.domain
@ -11,17 +16,24 @@ import lombok.Data;
* @Version 1.0 * @Version 1.0
*/ */
@Data @Data
public class Type { public class Type implements Serializable {
/** /**
* Id * Id
*/ */
@JsonAlias(value = "id")
private Integer typeId; private Integer typeId;
/** /**
* *
*/ */
@JsonAlias(value = "label")
private String typeName; private String typeName;
/** /**
* Id * Id
*/ */
private Integer categoryId; private Integer categoryId;
/**
*
*/
private List<Type> children;
} }

View File

@ -0,0 +1,34 @@
package com.bwie.common.domain.request;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.common.domain
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/20
* @Version 1.0
*/
@Data
public class CustomerRequest {
/**
*
*/
private Integer customerId;
/**
*
*/
private String customerName;
/**
*
*/
private Integer vipGrade;
private Integer pageNum = 1;
private Integer pageSize = 5;
}

View File

@ -0,0 +1,17 @@
package com.bwie.common.domain.request;
import lombok.Data;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.common.domain.request
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/24
* @Version 1.0
*/
@Data
public class ImportRequest {
private Integer pageNum = 1;
private Integer pageSize = 5;
}

View File

@ -1,6 +1,10 @@
package com.bwie.common.domain.request; package com.bwie.common.domain.request;
import lombok.Data; import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/** /**
* @ProjectName: GG-market * @ProjectName: GG-market
@ -11,6 +15,8 @@ import lombok.Data;
* @Version 1.0 * @Version 1.0
*/ */
@Data @Data
@Getter
@Setter
public class MerchRequest { public class MerchRequest {
/** /**
@ -24,7 +30,16 @@ public class MerchRequest {
/** /**
* *
*/ */
private Integer merchType; private String typeIds;
/**
*
*/
private Integer startNum;
/**
*
*/
private Integer endNum;
private Integer pageNum = 1; private Integer pageNum = 1;
private Integer pageSize = 5; private Integer pageSize = 5;

View File

@ -0,0 +1,17 @@
package com.bwie.common.domain.request;
import lombok.Data;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.common.domain.request
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/24
* @Version 1.0
*/
@Data
public class ReturnsRequest {
private Integer pageNum = 1;
private Integer pageSize = 5;
}

View File

@ -0,0 +1,16 @@
package com.bwie.common.domain.response;
import com.bwie.common.domain.Customer;
import lombok.Data;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.common.domain.response
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/20
* @Version 1.0
*/
@Data
public class CustomerResponse extends Customer {
}

View File

@ -0,0 +1,17 @@
package com.bwie.common.domain.response;
import com.bwie.common.domain.Import;
import lombok.Data;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.common.domain.response
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/24
* @Version 1.0
*/
@Data
public class ImportResponse extends Import {
}

View File

@ -0,0 +1,16 @@
package com.bwie.common.domain.response;
import com.bwie.common.domain.Returns;
import lombok.Data;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.common.domain.response
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/26
* @Version 1.0
*/
@Data
public class ReturnsResponse extends Returns {
}

View File

@ -0,0 +1,66 @@
package com.bwie.manage.controller;
import com.bwie.common.domain.Customer;
import com.bwie.common.domain.request.CustomerRequest;
import com.bwie.common.domain.response.CustomerResponse;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.manage.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.manage.controller
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/20
* @Version 1.0
*/
@RestController
@RequestMapping("/customer")
public class CustomerController {
@Autowired
private CustomerService customerService;
@PostMapping("/listCustomer")
public Result<PageResult<CustomerResponse>> listCustomer(@RequestBody CustomerRequest customerRequest){
return customerService.listCustomer(customerRequest);
}
@PostMapping("/listVip")
public Result<PageResult<CustomerResponse>> listVip(@RequestBody CustomerRequest customerRequest){
return customerService.listVip(customerRequest);
}
@PostMapping("/addClient")
public Result add(@RequestBody Customer customer){
customerService.add(customer);
return Result.success();
}
@GetMapping("/findByClientId/{customerId}")
public Result findById(@PathVariable("customerId") Integer customerId){
CustomerResponse customer = customerService.findById(customerId);
return Result.success(customer);
}
@PutMapping("/updateClient")
public Result update(@RequestBody Customer customer){
customerService.update(customer);
return Result.success();
}
@DeleteMapping("/delClient/{customerId}")
public Result del(@PathVariable("customerId") Integer customerId){
customerService.del(customerId);
return Result.success();
}
@DeleteMapping("/batchDelClient/{customerIds}")
public Result batchDel(@PathVariable("customerIds") Integer[] customerIds){
customerService.batchDel(customerIds);
return Result.success();
}
}

View File

@ -0,0 +1,40 @@
package com.bwie.manage.controller;
import com.bwie.common.domain.Import;
import com.bwie.common.domain.request.ImportRequest;
import com.bwie.common.domain.response.ImportResponse;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.manage.service.ImportService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.manage.controller
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/24
* @Version 1.0
*/
@RestController
@RequestMapping("/import")
public class ImportController {
@Autowired
private ImportService importService;
@PostMapping("/listImport")
public Result<PageResult<ImportResponse>> list(@RequestBody ImportRequest importRequest){
return importService.list(importRequest);
}
@PostMapping("/addImport")
public Result add(@RequestBody Import imports){
importService.add(imports);
return Result.success();
}
}

View File

@ -62,4 +62,6 @@ public class ManageController {
managerService.batchDel(empIds); managerService.batchDel(empIds);
return Result.success(); return Result.success();
} }
// @PostMapping("/")
} }

View File

@ -1,6 +1,9 @@
package com.bwie.manage.controller; package com.bwie.manage.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bwie.common.domain.Merch; import com.bwie.common.domain.Merch;
import com.bwie.common.domain.Type;
import com.bwie.common.domain.request.MerchRequest; import com.bwie.common.domain.request.MerchRequest;
import com.bwie.common.domain.response.MerchResponse; import com.bwie.common.domain.response.MerchResponse;
import com.bwie.common.result.PageResult; import com.bwie.common.result.PageResult;
@ -9,6 +12,8 @@ import com.bwie.manage.service.MerchService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* @ProjectName: GG-market * @ProjectName: GG-market
* @PackageName: com.bwie.manage.controller * @PackageName: com.bwie.manage.controller
@ -58,4 +63,10 @@ public class MerchController {
merchService.batchDel(merchIds); merchService.batchDel(merchIds);
return Result.success(); return Result.success();
} }
@GetMapping("/findTypes")
public Result<List<Type>> findTypes(){
List<Type> types = merchService.findTypes();
return Result.success(types);
}
} }

View File

@ -0,0 +1,40 @@
package com.bwie.manage.controller;
import com.bwie.common.domain.Returns;
import com.bwie.common.domain.request.ReturnsRequest;
import com.bwie.common.domain.response.ReturnsResponse;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.manage.service.ReturnsService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.manage.controller
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/24
* @Version 1.0
*/
@RestController
@RequestMapping("/returns")
public class ReturnsController {
@Autowired
private ReturnsService returnsService;
@PostMapping("/listReturns")
public Result<PageResult<ReturnsResponse>> list(@RequestBody ReturnsRequest returnsRequest){
return returnsService.list(returnsRequest);
}
@PostMapping("/addReturns")
public Result add(@RequestBody Returns returns){
returnsService.add(returns);
return Result.success();
}
}

View File

@ -0,0 +1,66 @@
package com.bwie.manage.mapper;
import com.bwie.common.domain.Customer;
import com.bwie.common.domain.request.CustomerRequest;
import com.bwie.common.domain.response.CustomerResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.manage.mapper
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/20
* @Version 1.0
*/
@Mapper
public interface CustomerMapper {
/**
*
* @param customerRequest
* @return
*/
List<CustomerResponse> listClient(CustomerRequest customerRequest);
/**
*
* @param customerRequest
* @return
*/
List<CustomerResponse> listVip(CustomerRequest customerRequest);
/**
*
* @param customer
*/
void add(Customer customer);
/**
*
* @param customerId
* @return
*/
CustomerResponse findById(@Param("customerId") Integer customerId);
/**
*
* @param customer
*/
void update(Customer customer);
/**
*
* @param customerId
*/
void del(@Param("customerId") Integer customerId);
/**
*
* @param customerIds
*/
void batchDel(@Param("customerIds") Integer[] customerIds);
}

View File

@ -0,0 +1,32 @@
package com.bwie.manage.mapper;
import com.bwie.common.domain.Import;
import com.bwie.common.domain.request.ImportRequest;
import com.bwie.common.domain.response.ImportResponse;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.manage.mapper
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/24
* @Version 1.0
*/
@Mapper
public interface ImportMapper {
/**
*
* @param importRequest
* @return
*/
List<ImportResponse> list(ImportRequest importRequest);
/**
*
* @param imports
*/
void add(Import imports);
}

View File

@ -1,6 +1,7 @@
package com.bwie.manage.mapper; package com.bwie.manage.mapper;
import com.bwie.common.domain.Merch; import com.bwie.common.domain.Merch;
import com.bwie.common.domain.Type;
import com.bwie.common.domain.request.MerchRequest; import com.bwie.common.domain.request.MerchRequest;
import com.bwie.common.domain.response.MerchResponse; import com.bwie.common.domain.response.MerchResponse;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -55,4 +56,10 @@ public interface MerchMapper {
* @param merchIds * @param merchIds
*/ */
void batchDel(@Param("merchIds") Integer[] merchIds); void batchDel(@Param("merchIds") Integer[] merchIds);
/**
*
* @return
*/
List<Type> findTypes();
} }

View File

@ -0,0 +1,32 @@
package com.bwie.manage.mapper;
import com.bwie.common.domain.Returns;
import com.bwie.common.domain.request.ReturnsRequest;
import com.bwie.common.domain.response.ReturnsResponse;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.manage.mapper
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/26
* @Version 1.0
*/
@Mapper
public interface ReturnsMapper {
/**
* 退
* @param returnsRequest
* @return
*/
List<ReturnsResponse> list(ReturnsRequest returnsRequest);
/**
* 退
* @param returns
*/
void add(Returns returns);
}

View File

@ -0,0 +1,62 @@
package com.bwie.manage.service;
import com.bwie.common.domain.Customer;
import com.bwie.common.domain.request.CustomerRequest;
import com.bwie.common.domain.response.CustomerResponse;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.manage.service
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/20
* @Version 1.0
*/
public interface CustomerService {
/**
*
* @param customerRequest
* @return
*/
Result<PageResult<CustomerResponse>> listCustomer(CustomerRequest customerRequest);
/**
*
* @param customerRequest
* @return
*/
Result<PageResult<CustomerResponse>> listVip(CustomerRequest customerRequest);
/**
*
* @param customer
*/
void add(Customer customer);
/**
*
* @param customerId
* @return
*/
CustomerResponse findById(Integer customerId);
/**
*
* @param customer
*/
void update(Customer customer);
/**
*
* @param customerId
*/
void del(Integer customerId);
/**
*
* @param customerIds
*/
void batchDel(Integer[] customerIds);
}

View File

@ -0,0 +1,30 @@
package com.bwie.manage.service;
import com.bwie.common.domain.Import;
import com.bwie.common.domain.request.ImportRequest;
import com.bwie.common.domain.response.ImportResponse;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.manage.service
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/24
* @Version 1.0
*/
public interface ImportService {
/**
*
* @param importRequest
* @return
*/
Result<PageResult<ImportResponse>> list(ImportRequest importRequest);
/**
*
* @param imports
*/
void add(Import imports);
}

View File

@ -1,11 +1,14 @@
package com.bwie.manage.service; package com.bwie.manage.service;
import com.bwie.common.domain.Merch; import com.bwie.common.domain.Merch;
import com.bwie.common.domain.Type;
import com.bwie.common.domain.request.MerchRequest; import com.bwie.common.domain.request.MerchRequest;
import com.bwie.common.domain.response.MerchResponse; import com.bwie.common.domain.response.MerchResponse;
import com.bwie.common.result.PageResult; import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result; import com.bwie.common.result.Result;
import java.util.List;
/** /**
* @ProjectName: GG-market * @ProjectName: GG-market
* @PackageName: com.bwie.manage.service * @PackageName: com.bwie.manage.service
@ -52,4 +55,10 @@ public interface MerchService {
* @param merchIds * @param merchIds
*/ */
void batchDel(Integer[] merchIds); void batchDel(Integer[] merchIds);
/**
*
* @return
*/
List<Type> findTypes();
} }

View File

@ -0,0 +1,30 @@
package com.bwie.manage.service;
import com.bwie.common.domain.Returns;
import com.bwie.common.domain.request.ReturnsRequest;
import com.bwie.common.domain.response.ReturnsResponse;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.manage.service
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/26
* @Version 1.0
*/
public interface ReturnsService {
/**
* 退
* @param returnsRequest
* @return
*/
Result<PageResult<ReturnsResponse>> list(ReturnsRequest returnsRequest);
/**
* 退
* @param returns
*/
void add(Returns returns);
}

View File

@ -0,0 +1,72 @@
package com.bwie.manage.service.impl;
import com.bwie.common.domain.Customer;
import com.bwie.common.domain.request.CustomerRequest;
import com.bwie.common.domain.response.CustomerResponse;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.manage.mapper.CustomerMapper;
import com.bwie.manage.service.CustomerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.manage.service.impl
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/20
* @Version 1.0
*/
@Service
public class CustomerServiceImpl implements CustomerService {
@Autowired
private
CustomerMapper customerMapper;
@Override
public Result<PageResult<CustomerResponse>> listCustomer(CustomerRequest customerRequest) {
PageHelper.startPage(customerRequest.getPageNum(), customerRequest.getPageSize());
List<CustomerResponse> clients = customerMapper.listClient(customerRequest);
PageInfo<CustomerResponse> info = new PageInfo<>(clients);
return PageResult.toResult(info.getTotal(), clients);
}
@Override
public Result<PageResult<CustomerResponse>> listVip(CustomerRequest customerRequest) {
PageHelper.startPage(customerRequest.getPageNum(), customerRequest.getPageSize());
List<CustomerResponse> clients = customerMapper.listVip(customerRequest);
PageInfo<CustomerResponse> info = new PageInfo<>(clients);
return PageResult.toResult(info.getTotal(), clients);
}
@Override
public void add(Customer customer) {
customerMapper.add(customer);
}
@Override
public CustomerResponse findById(Integer customerId) {
return customerMapper.findById(customerId);
}
@Override
public void update(Customer customer) {
customerMapper.update(customer);
}
@Override
public void del(Integer customerId) {
customerMapper.del(customerId);
}
@Override
public void batchDel(Integer[] customerIds) {
customerMapper.batchDel(customerIds);
}
}

View File

@ -0,0 +1,45 @@
package com.bwie.manage.service.impl;
import com.bwie.common.domain.Import;
import com.bwie.common.domain.request.ImportRequest;
import com.bwie.common.domain.response.ImportResponse;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.manage.mapper.ImportMapper;
import com.bwie.manage.service.ImportService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.manage.service.impl
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/24
* @Version 1.0
*/
@Service
public class ImportServiceImpl implements ImportService {
@Autowired
private ImportMapper importMapper;
@Override
public Result<PageResult<ImportResponse>> list(ImportRequest importRequest) {
PageHelper.startPage(importRequest.getPageNum(), importRequest.getPageSize());
List<ImportResponse> list = importMapper.list(importRequest);
PageInfo<ImportResponse> info = new PageInfo<>(list);
return PageResult.toResult(info.getTotal(), list);
}
@Override
public void add(Import imports) {
imports.setImportDate(new Date());
importMapper.add(imports);
}
}

View File

@ -1,6 +1,8 @@
package com.bwie.manage.service.impl; package com.bwie.manage.service.impl;
import cn.hutool.core.util.NumberUtil;
import com.bwie.common.domain.Merch; import com.bwie.common.domain.Merch;
import com.bwie.common.domain.Type;
import com.bwie.common.domain.request.MerchRequest; import com.bwie.common.domain.request.MerchRequest;
import com.bwie.common.domain.response.MerchResponse; import com.bwie.common.domain.response.MerchResponse;
import com.bwie.common.result.PageResult; import com.bwie.common.result.PageResult;
@ -9,10 +11,18 @@ import com.bwie.manage.mapper.MerchMapper;
import com.bwie.manage.service.MerchService; import com.bwie.manage.service.MerchService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.tomcat.util.net.NioChannel;
import org.apache.tomcat.util.net.NioEndpoint;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/** /**
* @ProjectName: GG-market * @ProjectName: GG-market
@ -60,4 +70,42 @@ public class MerchServiceImpl implements MerchService {
public void batchDel(Integer[] merchIds) { public void batchDel(Integer[] merchIds) {
merchMapper.batchDel(merchIds); merchMapper.batchDel(merchIds);
} }
@Override
public List<Type> findTypes() {
// 获取所有分类
List<Type> types = merchMapper.findTypes();
// 使用stream流筛选和转化
return types.stream()
.filter(type -> type.getCategoryId().equals(NumberUtils.INTEGER_ZERO)) // 获取分类中第一级分类
// 将每个一级分类的子级放入children集合中
.map(first -> {
// 判断一级分类是否为空,不为空返回对象,为空返回空对象
first.setChildren(getChildren(first.getTypeId(), types).isEmpty() ? null : getChildren(first.getTypeId(), types));
return first;
})
// 转换类型为List
.collect(Collectors.toList());
}
// 递归调用,获取指定父分类的子分类
private List<Type> getChildren(Integer parentId, List<Type> types) {
// 过滤出categoryId等于parentId的子分类
List<Type> collect = types.stream()
.filter(type -> parentId.equals(type.getCategoryId()))
// 递归调用,获取子分类的子分类(二级分类)
.map(second -> {
// 判断二级分类是否为空,不为空返回对象,为空返回空对象
second.setChildren(getChildren(second.getTypeId(), types).isEmpty() ? null : getChildren(second.getTypeId(), types));
return second;
})
.collect(Collectors.toList());
return collect;
}
public static void main(String[] args) throws IOException {
int available = System.in.available();
System.out.printf("a" + available);
}
} }

View File

@ -0,0 +1,45 @@
package com.bwie.manage.service.impl;
import com.bwie.common.domain.Returns;
import com.bwie.common.domain.request.ReturnsRequest;
import com.bwie.common.domain.response.ReturnsResponse;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.manage.mapper.ReturnsMapper;
import com.bwie.manage.service.ReturnsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* @ProjectName: GG-market
* @PackageName: com.bwie.manage.service.impl
* @Description TODO
* @Author LiYonJie
* @Date 2023/11/24
* @Version 1.0
*/
@Service
public class ReturnsServiceImpl implements ReturnsService {
@Autowired
private ReturnsMapper returnsMapper;
@Override
public Result<PageResult<ReturnsResponse>> list(ReturnsRequest returnsRequest) {
PageHelper.startPage(returnsRequest.getPageNum(), returnsRequest.getPageSize());
List<ReturnsResponse> list = returnsMapper.list(returnsRequest);
PageInfo<ReturnsResponse> info = new PageInfo<>(list);
return PageResult.toResult(info.getTotal(), list);
}
@Override
public void add(Returns returns) {
returns.setReturnsDate(new Date());
returnsMapper.add(returns);
}
}

View File

@ -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">
<!-- mybatis数据层 namespace命名空间-->
<mapper namespace="com.bwie.manage.mapper.CustomerMapper">
<sql id="selectCustomerVo">
select customer_id, customer_name, customer_age, customer_gender, customer_address, customer_tel,vip_grade,reg_date from tb_customer
</sql>
<select id="listClient" resultType="com.bwie.common.domain.response.CustomerResponse">
<include refid="selectCustomerVo"/>
<where>
vip_grade = 0
<if test="null != customerId">
and customer_id = #{customerId}
</if>
<if test="null != customerName and '' !=customerName">
and customer_name like concat('%',#{customerName},'%')
</if>
</where>
</select>
<select id="listVip" resultType="com.bwie.common.domain.response.CustomerResponse">
<include refid="selectCustomerVo"/>
<where>
vip_grade != 0
<if test="null != customerId">
and customer_id = #{customerId}
</if>
<if test="null != customerName and '' !=customerName">
and customer_name like concat('%',#{customerName},'%')
</if>
</where>
</select>
<insert id="add">
insert into tb_customer
<trim prefix="(" suffix=")" >
<if test="null != customerName and '' != customerName">customer_name,</if>
<if test="null != customerAge">customer_age,</if>
<if test="null != customerGender">customer_gender,</if>
<if test="null != customerAddress and '' != customerAddress">customer_address,</if>
<if test="null != customerTel and '' != customerTel">customer_tel</if>
</trim>
values
<trim prefix="(" suffix=")">
<if test="null != customerName and '' != customerName">#{customerName},</if>
<if test="null != customerAge">#{customerAge},</if>
<if test="null != customerGender">#{customerGender},</if>
<if test="null != customerAddress and '' != customerAddress">#{customerAddress},</if>
<if test="null != customerTel and '' != customerTel">#{customerTel}</if>
</trim>
</insert>
<select id="findById" resultType="com.bwie.common.domain.response.CustomerResponse">
<include refid="selectCustomerVo"/> where customer_id = #{customerId}
</select>
<update id="update">
update tb_customer
<set>
<if test="null != customerName and '' != customerName">customer_name = #{customerName},</if>
<if test="null != customerAge">customer_age = #{customerAge},</if>
<if test="null != customerGender">customer_gender = #{customerGender},</if>
<if test="null != customerAddress and '' != customerAddress">customer_address = #{customerAddress},</if>
<if test="null != customerTel and '' != customerTel">customer_tel = #{customerTel},</if>
<if test="null != vipGrade">vip_grade = #{vipGrade},</if>
<if test="null != regDate">reg_date = #{regDate}</if>
</set>
where customer_id = #{customerId}
</update>
<delete id="del">
delete from tb_customer where customer_id = #{customerId}
</delete>
<delete id="batchDel">
delete from tb_customer where customer_id in
<foreach collection="customerIds" item="customerId" open="(" close=")" separator=",">
#{customerId}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,16 @@
<?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">
<!-- mybatis数据层 namespace命名空间-->
<mapper namespace="com.bwie.manage.mapper.ImportMapper">
<select id="list" resultType="com.bwie.common.domain.response.ImportResponse">
select list_id,merch_id, merch_name, type_ids, merch_price, plan_num, import_date, provide_id from tb_import
</select>
<insert id="add">
insert into tb_import (merch_id, merch_name, type_ids, merch_price, plan_num, import_date, provide_id)
values (#{merchId},#{merchName},#{typeIds},#{merchPrice},#{planNum},#{importDate},#{provideId})
</insert>
</mapper>

View File

@ -5,39 +5,59 @@
<!-- mybatis数据层 namespace命名空间--> <!-- mybatis数据层 namespace命名空间-->
<mapper namespace="com.bwie.manage.mapper.MerchMapper"> <mapper namespace="com.bwie.manage.mapper.MerchMapper">
<resultMap type="com.bwie.common.domain.Merch" id="MerchResult">
<id property="merchId" column="merch_id" />
<result property="merchName" column="merch_name" />
<result property="typeIds" column="type_ids" />
<result property="merchPrice" column="merch_price" />
<result property="barCode" column="bar_code" />
<result property="salesProPrice" column="sales_pro_price" />
<result property="factoryId" column="factory_id" />
<result property="provideId" column="provide_id" />
<result property="merchDeadTime" column="merch_dead_time" />
<result property="merchNum" column="merch_num" />
<result property="merchSta" column="merch_sta" />
</resultMap>
<sql id="selectMerchVo"> <sql id="selectMerchVo">
select select
m.merch_id, m.merch_name,m.merch_type, m.merch_id, m.merch_name,m.type_ids,
t.type_name, m.merch_price, t.type_name, m.merch_price,
m.bar_code, m.sales_pro_price, m.bar_code, m.sales_pro_price,
m.factory_id, m.provide_id, m.factory_id, m.provide_id,
m.merch_dead_time, m.merch_num, m.merch_dead_time, m.merch_num,
m.merch_sta m.merch_sta
from tb_merch m from tb_merch m
left join tb_type t on m.merch_type = t.type_id left join tb_type t on SUBSTRING_INDEX(m.type_ids, ',', -1) = t.type_id
</sql> </sql>
<select id="list" resultType="com.bwie.common.domain.response.MerchResponse"> <select id="list" resultType="com.bwie.common.domain.response.MerchResponse" resultMap="MerchResult">
<include refid="selectMerchVo"/> <include refid="selectMerchVo"/>
<where> <where>
<if test="null != merchId"> <if test="null != merchId">
and m.merch_id = #{merchId} and m.merch_id = #{merchId}
</if> </if>
<if test="null != merchType"> <if test="null != typeIds and '' != typeIds">
and m.merch_type = #{merchType} and t.type_id = #{typeIds}
</if> </if>
<if test="null != merchName and '' != merchName"> <if test="null != merchName and '' != merchName">
and m.merch_name like concat('%',#{merchName},'%') and m.merch_name like concat('%',#{merchName},'%')
</if> </if>
<if test="null != startNum">
and <![CDATA[ m.merch_num >= #{startNum} ]]>
</if>
<if test="null != endNum">
and <![CDATA[ m.merch_num <= #{endNum} ]]>
</if>
</where> </where>
</select> </select>
<insert id="add"> <insert id="add" useGeneratedKeys="true" keyProperty="merchId">
insert into tb_merch (merch_name, merch_type, merch_price, bar_code, sales_pro_price, factory_id, provide_id, merch_dead_time, merch_num, merch_sta) insert into tb_merch (merch_name, type_ids, merch_price, bar_code, sales_pro_price, factory_id, provide_id, merch_dead_time, merch_num, merch_sta)
values (#{merchName},#{merchType},#{merchPrice},#{barCode},#{salesProPrice},#{factoryId},#{provideId},#{merchDeadTime},#{merchNum},#{merchSta}) values (#{merchName},#{typeIds},#{merchPrice},#{barCode},#{salesProPrice},#{factoryId},#{provideId},#{merchDeadTime},#{merchNum},#{merchSta})
</insert> </insert>
<select id="findById" resultType="com.bwie.common.domain.Merch"> <select id="findById" resultType="com.bwie.common.domain.Merch" resultMap="MerchResult">
<include refid="selectMerchVo"/> where m.merch_id = #{merchId} <include refid="selectMerchVo"/> where m.merch_id = #{merchId}
</select> </select>
@ -45,7 +65,7 @@
update tb_merch update tb_merch
<set> <set>
merch_name = #{merchName}, merch_name = #{merchName},
merch_type = #{merchType}, type_ids = #{typeIds},
merch_price = #{merchPrice}, merch_price = #{merchPrice},
bar_code = #{barCode}, bar_code = #{barCode},
sales_pro_price = #{salesProPrice}, sales_pro_price = #{salesProPrice},
@ -68,4 +88,8 @@
#{merchId} #{merchId}
</foreach> </foreach>
</delete> </delete>
<select id="findTypes" resultType="com.bwie.common.domain.Type">
select type_id, type_name, category_id from tb_type
</select>
</mapper> </mapper>

View File

@ -0,0 +1,16 @@
<?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">
<!-- mybatis数据层 namespace命名空间-->
<mapper namespace="com.bwie.manage.mapper.ReturnsMapper">
<select id="list" resultType="com.bwie.common.domain.response.ReturnsResponse">
select list_id,merch_id, merch_name, type_ids, merch_price, plan_num, returns_date, provide_id from tb_returns
</select>
<insert id="add">
insert into tb_returns (merch_id, merch_name, type_ids, merch_price, plan_num, returns_date, provide_id)
values (#{merchId},#{merchName},#{typeIds},#{merchPrice},#{planNum},#{returnsDate},#{provideId})
</insert>
</mapper>