收银后台跟进
This commit is contained in:
@@ -86,6 +86,18 @@
|
|||||||
<artifactId>oshi-core</artifactId>
|
<artifactId>oshi-core</artifactId>
|
||||||
<version>6.1.4</version>
|
<version>6.1.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>2.1.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-extension</artifactId>
|
||||||
|
<version>3.3.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<!-- 打包 -->
|
<!-- 打包 -->
|
||||||
|
|||||||
@@ -16,9 +16,13 @@
|
|||||||
package me.zhengjie.modules.productGroup.rest;
|
package me.zhengjie.modules.productGroup.rest;
|
||||||
|
|
||||||
import me.zhengjie.annotation.Log;
|
import me.zhengjie.annotation.Log;
|
||||||
|
import me.zhengjie.modules.product.domain.TbProduct;
|
||||||
|
import me.zhengjie.modules.product.service.TbProductService;
|
||||||
|
import me.zhengjie.modules.product.service.dto.TbProductQueryCriteria;
|
||||||
import me.zhengjie.modules.productGroup.domain.TbProductGroup;
|
import me.zhengjie.modules.productGroup.domain.TbProductGroup;
|
||||||
import me.zhengjie.modules.productGroup.service.TbProductGroupService;
|
import me.zhengjie.modules.productGroup.service.TbProductGroupService;
|
||||||
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupQueryCriteria;
|
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupQueryCriteria;
|
||||||
|
import me.zhengjie.modules.productGroup.service.vo.AddProduct;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@@ -28,6 +32,8 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,6 +49,9 @@ public class TbProductGroupController {
|
|||||||
|
|
||||||
private final TbProductGroupService tbProductGroupService;
|
private final TbProductGroupService tbProductGroupService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TbProductService tbProductService;
|
||||||
|
|
||||||
@Log("导出数据")
|
@Log("导出数据")
|
||||||
@ApiOperation("导出数据")
|
@ApiOperation("导出数据")
|
||||||
@GetMapping(value = "/download")
|
@GetMapping(value = "/download")
|
||||||
@@ -84,4 +93,20 @@ public class TbProductGroupController {
|
|||||||
tbProductGroupService.deleteAll(ids);
|
tbProductGroupService.deleteAll(ids);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*添加商品(商品列表)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/addProduct")
|
||||||
|
public ResponseEntity<Object> ProductList(TbProductQueryCriteria criteria, Pageable pageable){
|
||||||
|
return new ResponseEntity<>(tbProductService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/addProductInfo")
|
||||||
|
public ResponseEntity<Object> addProductInfo(@RequestBody AddProduct addProduct){
|
||||||
|
|
||||||
|
|
||||||
|
tbProductGroupService.updateProductIds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,10 @@ package me.zhengjie.modules.productGroup.service;
|
|||||||
import me.zhengjie.modules.productGroup.domain.TbProductGroup;
|
import me.zhengjie.modules.productGroup.domain.TbProductGroup;
|
||||||
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupDto;
|
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupDto;
|
||||||
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupQueryCriteria;
|
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupQueryCriteria;
|
||||||
|
import me.zhengjie.modules.productGroup.service.vo.AddProduct;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -80,4 +83,6 @@ public interface TbProductGroupService {
|
|||||||
* @throws IOException /
|
* @throws IOException /
|
||||||
*/
|
*/
|
||||||
void download(List<TbProductGroupDto> all, HttpServletResponse response) throws IOException;
|
void download(List<TbProductGroupDto> all, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
|
ResponseEntity<Object> updateProductIds(AddProduct addProduct);
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
package me.zhengjie.modules.productGroup.service.impl;
|
package me.zhengjie.modules.productGroup.service.impl;
|
||||||
|
|
||||||
import me.zhengjie.modules.productGroup.domain.TbProductGroup;
|
import me.zhengjie.modules.productGroup.domain.TbProductGroup;
|
||||||
|
import me.zhengjie.modules.productGroup.service.vo.AddProduct;
|
||||||
import me.zhengjie.utils.ValidationUtil;
|
import me.zhengjie.utils.ValidationUtil;
|
||||||
import me.zhengjie.utils.FileUtil;
|
import me.zhengjie.utils.FileUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -24,6 +25,8 @@ import me.zhengjie.modules.productGroup.service.TbProductGroupService;
|
|||||||
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupDto;
|
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupDto;
|
||||||
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupQueryCriteria;
|
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupQueryCriteria;
|
||||||
import me.zhengjie.modules.productGroup.service.mapstruct.TbProductGroupMapper;
|
import me.zhengjie.modules.productGroup.service.mapstruct.TbProductGroupMapper;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -90,7 +93,6 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
|||||||
tbProductGroupRepository.deleteById(id);
|
tbProductGroupRepository.deleteById(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void download(List<TbProductGroupDto> all, HttpServletResponse response) throws IOException {
|
public void download(List<TbProductGroupDto> all, HttpServletResponse response) throws IOException {
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
@@ -111,4 +113,31 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
|||||||
}
|
}
|
||||||
FileUtil.downloadExcel(list, response);
|
FileUtil.downloadExcel(list, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Object> updateProductIds(AddProduct addProduct) {
|
||||||
|
if (addProduct.getIds().size()<1){
|
||||||
|
return new ResponseEntity<>("错误", HttpStatus.NOT_ACCEPTABLE);
|
||||||
|
}
|
||||||
|
TbProductGroup productGroup = tbProductGroupMapper.queryById(addProduct.getProductId());
|
||||||
|
|
||||||
|
if (productGroup == null){
|
||||||
|
return new ResponseEntity<>("没有找到改分类", HttpStatus.NOT_ACCEPTABLE);
|
||||||
|
}
|
||||||
|
TbProductGroup tbProductGroup = new TbProductGroup();
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (productGroup.getProductIds() == null) {
|
||||||
|
for (String s : addProduct.getIds()) {
|
||||||
|
sb.append(s);
|
||||||
|
sb.append(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
tbProductGroup.setProductIds(sb.toString());
|
||||||
|
tbProductGroup.setId(addProduct.getProductId());
|
||||||
|
tbProductGroupMapper.update(tbProductGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -29,4 +29,7 @@ import org.mapstruct.ReportingPolicy;
|
|||||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||||
public interface TbProductGroupMapper extends BaseMapper<TbProductGroupDto, TbProductGroup> {
|
public interface TbProductGroupMapper extends BaseMapper<TbProductGroupDto, TbProductGroup> {
|
||||||
|
|
||||||
|
int update(TbProductGroup tbProductGroup);
|
||||||
|
|
||||||
|
TbProductGroup queryById(Integer id);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,199 @@
|
|||||||
|
<?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="me.zhengjie.modules.productGroup.service.mapstruct.TbProductGroupMapper">
|
||||||
|
|
||||||
|
<resultMap type="me.zhengjie.modules.productGroup.domain.TbProductGroup" id="TbProductGroupMap">
|
||||||
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||||
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||||
|
<result property="merchantId" column="merchant_id" jdbcType="VARCHAR"/>
|
||||||
|
<result property="shopId" column="shop_id" jdbcType="VARCHAR"/>
|
||||||
|
<result property="pic" column="pic" jdbcType="VARCHAR"/>
|
||||||
|
<result property="isShow" column="is_show" jdbcType="INTEGER"/>
|
||||||
|
<result property="detail" column="detail" jdbcType="VARCHAR"/>
|
||||||
|
<result property="style" column="style" jdbcType="VARCHAR"/>
|
||||||
|
<result property="sort" column="sort" jdbcType="INTEGER"/>
|
||||||
|
<result property="productIds" column="product_ids" jdbcType="VARCHAR"/>
|
||||||
|
<result property="createdAt" column="created_at" jdbcType="INTEGER"/>
|
||||||
|
<result property="updatedAt" column="updated_at" jdbcType="INTEGER"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!--查询单个-->
|
||||||
|
<select id="queryById" resultMap="TbProductGroupMap">
|
||||||
|
select
|
||||||
|
id, name, merchant_id, shop_id, pic, is_show, detail, style, sort, product_ids, created_at, updated_at
|
||||||
|
from tb_product_group
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!--查询指定行数据-->
|
||||||
|
<select id="queryAllByLimit" resultMap="TbProductGroupMap">
|
||||||
|
select
|
||||||
|
id, name, merchant_id, shop_id, pic, is_show, detail, style, sort, product_ids, created_at, updated_at
|
||||||
|
from tb_product_group
|
||||||
|
<where>
|
||||||
|
<if test="id != null">
|
||||||
|
and id = #{id}
|
||||||
|
</if>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
and name = #{name}
|
||||||
|
</if>
|
||||||
|
<if test="merchantId != null and merchantId != ''">
|
||||||
|
and merchant_id = #{merchantId}
|
||||||
|
</if>
|
||||||
|
<if test="shopId != null and shopId != ''">
|
||||||
|
and shop_id = #{shopId}
|
||||||
|
</if>
|
||||||
|
<if test="pic != null and pic != ''">
|
||||||
|
and pic = #{pic}
|
||||||
|
</if>
|
||||||
|
<if test="isShow != null">
|
||||||
|
and is_show = #{isShow}
|
||||||
|
</if>
|
||||||
|
<if test="detail != null and detail != ''">
|
||||||
|
and detail = #{detail}
|
||||||
|
</if>
|
||||||
|
<if test="style != null and style != ''">
|
||||||
|
and style = #{style}
|
||||||
|
</if>
|
||||||
|
<if test="sort != null">
|
||||||
|
and sort = #{sort}
|
||||||
|
</if>
|
||||||
|
<if test="productIds != null and productIds != ''">
|
||||||
|
and product_ids = #{productIds}
|
||||||
|
</if>
|
||||||
|
<if test="createdAt != null">
|
||||||
|
and created_at = #{createdAt}
|
||||||
|
</if>
|
||||||
|
<if test="updatedAt != null">
|
||||||
|
and updated_at = #{updatedAt}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
limit #{pageable.offset}, #{pageable.pageSize}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!--统计总行数-->
|
||||||
|
<select id="count" resultType="java.lang.Long">
|
||||||
|
select count(1)
|
||||||
|
from tb_product_group
|
||||||
|
<where>
|
||||||
|
<if test="id != null">
|
||||||
|
and id = #{id}
|
||||||
|
</if>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
and name = #{name}
|
||||||
|
</if>
|
||||||
|
<if test="merchantId != null and merchantId != ''">
|
||||||
|
and merchant_id = #{merchantId}
|
||||||
|
</if>
|
||||||
|
<if test="shopId != null and shopId != ''">
|
||||||
|
and shop_id = #{shopId}
|
||||||
|
</if>
|
||||||
|
<if test="pic != null and pic != ''">
|
||||||
|
and pic = #{pic}
|
||||||
|
</if>
|
||||||
|
<if test="isShow != null">
|
||||||
|
and is_show = #{isShow}
|
||||||
|
</if>
|
||||||
|
<if test="detail != null and detail != ''">
|
||||||
|
and detail = #{detail}
|
||||||
|
</if>
|
||||||
|
<if test="style != null and style != ''">
|
||||||
|
and style = #{style}
|
||||||
|
</if>
|
||||||
|
<if test="sort != null">
|
||||||
|
and sort = #{sort}
|
||||||
|
</if>
|
||||||
|
<if test="productIds != null and productIds != ''">
|
||||||
|
and product_ids = #{productIds}
|
||||||
|
</if>
|
||||||
|
<if test="createdAt != null">
|
||||||
|
and created_at = #{createdAt}
|
||||||
|
</if>
|
||||||
|
<if test="updatedAt != null">
|
||||||
|
and updated_at = #{updatedAt}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!--新增所有列-->
|
||||||
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||||
|
insert into tb_product_group(name, merchant_id, shop_id, pic, is_show, detail, style, sort, product_ids, created_at, updated_at)
|
||||||
|
values (#{name}, #{merchantId}, #{shopId}, #{pic}, #{isShow}, #{detail}, #{style}, #{sort}, #{productIds}, #{createdAt}, #{updatedAt})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||||
|
insert into tb_product_group(name, merchant_id, shop_id, pic, is_show, detail, style, sort, product_ids, created_at, updated_at)
|
||||||
|
values
|
||||||
|
<foreach collection="entities" item="entity" separator=",">
|
||||||
|
(#{entity.name}, #{entity.merchantId}, #{entity.shopId}, #{entity.pic}, #{entity.isShow}, #{entity.detail}, #{entity.style}, #{entity.sort}, #{entity.productIds}, #{entity.createdAt}, #{entity.updatedAt})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
||||||
|
insert into tb_product_group(name, merchant_id, shop_id, pic, is_show, detail, style, sort, product_ids, created_at, updated_at)
|
||||||
|
values
|
||||||
|
<foreach collection="entities" item="entity" separator=",">
|
||||||
|
(#{entity.name}, #{entity.merchantId}, #{entity.shopId}, #{entity.pic}, #{entity.isShow}, #{entity.detail}, #{entity.style}, #{entity.sort}, #{entity.productIds}, #{entity.createdAt}, #{entity.updatedAt})
|
||||||
|
</foreach>
|
||||||
|
on duplicate key update
|
||||||
|
name = values(name),
|
||||||
|
merchant_id = values(merchant_id),
|
||||||
|
shop_id = values(shop_id),
|
||||||
|
pic = values(pic),
|
||||||
|
is_show = values(is_show),
|
||||||
|
detail = values(detail),
|
||||||
|
style = values(style),
|
||||||
|
sort = values(sort),
|
||||||
|
product_ids = values(product_ids),
|
||||||
|
created_at = values(created_at),
|
||||||
|
updated_at = values(updated_at)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!--通过主键修改数据-->
|
||||||
|
<update id="update">
|
||||||
|
update tb_product_group
|
||||||
|
<set>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
name = #{name},
|
||||||
|
</if>
|
||||||
|
<if test="merchantId != null and merchantId != ''">
|
||||||
|
merchant_id = #{merchantId},
|
||||||
|
</if>
|
||||||
|
<if test="shopId != null and shopId != ''">
|
||||||
|
shop_id = #{shopId},
|
||||||
|
</if>
|
||||||
|
<if test="pic != null and pic != ''">
|
||||||
|
pic = #{pic},
|
||||||
|
</if>
|
||||||
|
<if test="isShow != null">
|
||||||
|
is_show = #{isShow},
|
||||||
|
</if>
|
||||||
|
<if test="detail != null and detail != ''">
|
||||||
|
detail = #{detail},
|
||||||
|
</if>
|
||||||
|
<if test="style != null and style != ''">
|
||||||
|
style = #{style},
|
||||||
|
</if>
|
||||||
|
<if test="sort != null">
|
||||||
|
sort = #{sort},
|
||||||
|
</if>
|
||||||
|
<if test="productIds != null and productIds != ''">
|
||||||
|
product_ids = #{productIds},
|
||||||
|
</if>
|
||||||
|
<if test="createdAt != null">
|
||||||
|
created_at = #{createdAt},
|
||||||
|
</if>
|
||||||
|
<if test="updatedAt != null">
|
||||||
|
updated_at = #{updatedAt},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!--通过主键删除-->
|
||||||
|
<delete id="deleteById">
|
||||||
|
delete from tb_product_group where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package me.zhengjie.modules.productGroup.service.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lyf
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AddProduct {
|
||||||
|
List<String> ids;
|
||||||
|
|
||||||
|
Integer productId;
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user