Commit 03bd7f3e authored by wcy's avatar wcy
Browse files

.

parent e65076f9
......@@ -2,7 +2,6 @@ package com.admin.mybatis.controller.product;
import com.admin.mybatis.common.base.BaseController;
import com.admin.mybatis.entity.product.Sales;
import com.admin.mybatis.entity.product.Sell;
import com.admin.mybatis.service.product.SalesService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......
package com.admin.mybatis.controller.product;
import com.admin.mybatis.common.base.BaseController;
import com.admin.mybatis.entity.product.SellTable;
import com.admin.mybatis.service.product.SellTableService;
import com.admin.mybatis.entity.product.SalesTable;
import com.admin.mybatis.service.product.SalesTableService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.basic.common.base.Constants;
......@@ -23,24 +23,24 @@ import java.util.List;
@Api(description = "销售表")
@RestController
@Transactional(rollbackFor = Exception.class)
@RequestMapping(value = "/api/sellTable", produces = {Constants.CONTENT_TYPE_JSON})
public class SellTableController extends BaseController {
@RequestMapping(value = "/api/salesTable", produces = {Constants.CONTENT_TYPE_JSON})
public class SalesTableController extends BaseController {
@Autowired
private SellTableService service;
private SalesTableService service;
@ApiOperation(value ="销售表分页查询")
@GetMapping(value ="page")
@Permission("sellTable:page")
public String queryLis(Page<SellTable> page, SellTable entity){
@Permission("salesTable:page")
public String queryLis(Page<SalesTable> page, SalesTable entity){
QueryWrapper<SellTable> wrapper = new QueryWrapper<SellTable>();
QueryWrapper<SalesTable> wrapper = new QueryWrapper<SalesTable>();
wrapper
.eq(StringUtil.isNotEmpty(entity.getSellTableId()), "a.sell_table_id", entity.getSellTableId())
.eq(StringUtil.isNotEmpty(entity.getSalesTableId()), "a.sales_table_id", entity.getSalesTableId())
.eq(StringUtil.isNotEmpty(entity.getProductId()), "a.product_id", entity.getProductId())
.eq(StringUtil.isNotEmpty(entity.getSellId()), "a.sell_id", entity.getSellId())
.eq(StringUtil.isNotEmpty(entity.getSellNum()), "a.sell_num", entity.getSellNum())
.eq(StringUtil.isNotEmpty(entity.getSellUnit()), "a.sell_unit", entity.getSellUnit())
.eq(StringUtil.isNotEmpty(entity.getSalesId()), "a.sales_id", entity.getSalesId())
.eq(StringUtil.isNotEmpty(entity.getSalesNum()), "a.sales_num", entity.getSalesNum())
.eq(StringUtil.isNotEmpty(entity.getSalesUnit()), "a.sales_unit", entity.getSalesUnit())
.orderByAsc(StringUtil.isNotEmpty(page.ascs()), page.ascs())
.orderByDesc(StringUtil.isNotEmpty(page.descs()), page.descs());
return ValueUtil.toJson(service.selectPage(page,wrapper));
......@@ -48,15 +48,15 @@ public class SellTableController extends BaseController {
@ApiOperation(value = "销售表查询所有")
@GetMapping(value = "all")
@Permission("sellTable:all")
public String queryAllList(Page<SellTable> page, SellTable entity) {
QueryWrapper<SellTable> wrapper = new QueryWrapper<SellTable>();
@Permission("salesTable:all")
public String queryAllList(Page<SalesTable> page, SalesTable entity) {
QueryWrapper<SalesTable> wrapper = new QueryWrapper<SalesTable>();
wrapper
.eq(StringUtil.isNotEmpty(entity.getSellTableId()), "a.sell_table_id", entity.getSellTableId())
.eq(StringUtil.isNotEmpty(entity.getSalesTableId()), "a.sales_table_id", entity.getSalesTableId())
.eq(StringUtil.isNotEmpty(entity.getProductId()), "a.product_id", entity.getProductId())
.eq(StringUtil.isNotEmpty(entity.getSellId()), "a.sell_id", entity.getSellId())
.eq(StringUtil.isNotEmpty(entity.getSellNum()), "a.sell_num", entity.getSellNum())
.eq(StringUtil.isNotEmpty(entity.getSellUnit()), "a.sell_unit", entity.getSellUnit())
.eq(StringUtil.isNotEmpty(entity.getSalesId()), "a.sales_id", entity.getSalesId())
.eq(StringUtil.isNotEmpty(entity.getSalesNum()), "a.sales_num", entity.getSalesNum())
.eq(StringUtil.isNotEmpty(entity.getSalesUnit()), "a.sales_unit", entity.getSalesUnit())
.orderByAsc(StringUtil.isNotEmpty(page.ascs()), page.ascs())
.orderByDesc(StringUtil.isNotEmpty(page.descs()), page.descs());
return ValueUtil.toJson(service.selectList(wrapper));
......@@ -64,7 +64,7 @@ public class SellTableController extends BaseController {
@ApiOperation(value = "销售表根据Id查询")
@GetMapping(value = "get/{id}")
@Permission("sellTable:detail")
@Permission("salesTable:detail")
public String queryById(@PathVariable("id") String id) {
return ValueUtil.toJson(service.queryById(id));
......@@ -73,24 +73,24 @@ public class SellTableController extends BaseController {
@ApiOperation(value = "销售表新增")
@PostMapping(value = "add")
@Permission("sellTable:add")
public String add(@RequestBody SellTable entity) {
SellTable insert = service.insert(entity);
@Permission("salesTable:add")
public String add(@RequestBody SalesTable entity) {
SalesTable insert = service.insert(entity);
return ValueUtil.toJson(insert);
}
@ApiOperation(value = "销售表更新")
@PutMapping(value = "put/{id}")
@Permission("sellTable:update")
public String update(@PathVariable("id") String id, @RequestBody SellTable entity) {
@Permission("salesTable:update")
public String update(@PathVariable("id") String id, @RequestBody SalesTable entity) {
SellTable update = service.update(id, entity);
SalesTable update = service.update(id, entity);
return ValueUtil.toJson(update);
}
@ApiOperation(value = "销售表根据Id批量删除")
@DeleteMapping(value = "deletes")
@Permission("sellTable:deletes")
@Permission("salesTable:deletes")
public String deletes(@RequestBody List<String> ids) {
return ValueUtil.toJson(service.removeByIds(ids));
......
package com.admin.mybatis.controller.product;
import com.admin.mybatis.common.base.BaseController;
import com.admin.mybatis.entity.product.Sell;
import com.admin.mybatis.service.product.SellService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.basic.common.base.Constants;
import com.basic.common.util.basic.StringUtil;
import com.basic.common.util.basic.ValueUtil;
import com.basic.permission.common.annotation.Permission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
@Slf4j
@Api(description = "销售信息")
@RestController
@Transactional(rollbackFor = Exception.class)
@RequestMapping(value = "/api/sell", produces = {Constants.CONTENT_TYPE_JSON})
public class SellController extends BaseController {
@Autowired
private SellService service;
@ApiOperation(value ="销售信息分页查询")
@GetMapping(value ="page")
@Permission("sell:page")
public String queryList(Page<Sell> page, Sell entity){
QueryWrapper<Sell> wrapper = new QueryWrapper<Sell>();
wrapper
.eq("a.is_delete",Constants.DELETE_N)
.eq(StringUtil.isNotEmpty(entity.getSellId()), "a.sell_id", entity.getSellId())
.eq(StringUtil.isNotEmpty(entity.getSellDate()), "a.sell_date", entity.getSellDate())
.eq(StringUtil.isNotEmpty(entity.getCustomerName()), "a.customer_name", entity.getCustomerName())
.eq(StringUtil.isNotEmpty(entity.getCustomerPhone()), "a.customer_phone", entity.getCustomerPhone())
.eq(StringUtil.isNotEmpty(entity.getCustomerAddress()), "a.customer_address", entity.getCustomerAddress())
.eq(StringUtil.isNotEmpty(entity.getCreateBy()), "a.create_by", entity.getCreateBy())
.eq(StringUtil.isNotEmpty(entity.getCreateTime()), "a.create_time", entity.getCreateTime())
.eq(StringUtil.isNotEmpty(entity.getUpdateBy()), "a.update_by", entity.getUpdateBy())
.eq(StringUtil.isNotEmpty(entity.getUpdateTime()), "a.update_time", entity.getUpdateTime())
.eq(StringUtil.isNotEmpty(entity.getIsDelete()), "a.is_delete", entity.getIsDelete())
.eq(StringUtil.isNotEmpty(entity.getUserId()), "a.user_id", entity.getUserId())
.orderByAsc(StringUtil.isNotEmpty(page.ascs()), page.ascs())
.orderByDesc(StringUtil.isNotEmpty(page.descs()), page.descs());
return ValueUtil.toJson(service.selectPage(page,wrapper));
}
@ApiOperation(value = "销售信息查询所有")
@GetMapping(value = "all")
@Permission("sell:all")
public String queryAllList(Page<Sell> page, Sell entity) {
QueryWrapper<Sell> wrapper = new QueryWrapper<Sell>();
wrapper
.eq("a.is_delete",Constants.DELETE_N)
.eq(StringUtil.isNotEmpty(entity.getSellId()), "a.sell_id", entity.getSellId())
.eq(StringUtil.isNotEmpty(entity.getSellDate()), "a.sell_date", entity.getSellDate())
.eq(StringUtil.isNotEmpty(entity.getCustomerName()), "a.customer_name", entity.getCustomerName())
.eq(StringUtil.isNotEmpty(entity.getCustomerPhone()), "a.customer_phone", entity.getCustomerPhone())
.eq(StringUtil.isNotEmpty(entity.getCustomerAddress()), "a.customer_address", entity.getCustomerAddress())
.eq(StringUtil.isNotEmpty(entity.getCreateBy()), "a.create_by", entity.getCreateBy())
.eq(StringUtil.isNotEmpty(entity.getCreateTime()), "a.create_time", entity.getCreateTime())
.eq(StringUtil.isNotEmpty(entity.getUpdateBy()), "a.update_by", entity.getUpdateBy())
.eq(StringUtil.isNotEmpty(entity.getUpdateTime()), "a.update_time", entity.getUpdateTime())
.eq(StringUtil.isNotEmpty(entity.getIsDelete()), "a.is_delete", entity.getIsDelete())
.eq(StringUtil.isNotEmpty(entity.getUserId()), "a.user_id", entity.getUserId())
.orderByAsc(StringUtil.isNotEmpty(page.ascs()), page.ascs())
.orderByDesc(StringUtil.isNotEmpty(page.descs()), page.descs());
return ValueUtil.toJson(service.selectList(wrapper));
}
@ApiOperation(value = "销售信息根据Id查询")
@GetMapping(value = "get/{id}")
@Permission("sell:detail")
public String queryById(@PathVariable("id") String id) {
return ValueUtil.toJson(service.queryById(id));
}
@ApiOperation(value = "销售信息新增")
@PostMapping(value = "add")
@Permission("sell:add")
public String add(@RequestBody Sell entity) {
entity.setCreateBy(getTokenUserId());
entity.setUpdateBy(getTokenUserId());
entity.setUserId(getTokenUserId());
entity.setCreateTime(new Date());
entity.setUpdateTime(new Date());
entity.setIsDelete(Constants.DELETE_N);
Sell insert = service.insert(entity);
return ValueUtil.toJson(insert);
}
@ApiOperation(value = "销售信息更新")
@PutMapping(value = "put/{id}")
@Permission("sell:update")
public String update(@PathVariable("id") String id, @RequestBody Sell entity) {
entity.setUpdateBy(getTokenUserId());
entity.setUpdateTime(new Date());
Sell update = service.update(id, entity);
return ValueUtil.toJson(update);
}
@ApiOperation(value = "销售信息根据Id批量删除")
@DeleteMapping(value = "deletes")
@Permission("sell:deletes")
public String deletes(@RequestBody List<String> ids) {
return ValueUtil.toJson(service.removeByIds(ids));
}
}
......@@ -68,6 +68,6 @@ public class Sales extends BaseEntity<Sales> {
@ApiModelProperty("销售信息详细")
@TableField(exist = false)
private List<SellTable> records;
private List<SalesTable> records;
}
......@@ -3,26 +3,25 @@ package com.admin.mybatis.entity.product;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.basic.mybatis.common.base.BaseEntity;
import com.basic.mybatis.common.base.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel(value="sell_table表",description="销售表")
@ApiModel(value="sales_table表",description="销售表")
@Data
@TableName("sell_table")
public class SellTable extends Entity<SellTable> {
@TableName("sales_table")
public class SalesTable extends Entity<SalesTable> {
private static final Long serialVersionUID = 1L;
@ApiModelProperty("销售表Id")
@TableId
private String sellTableId;
private String salesTableId;
@ApiModelProperty("销售id")
private String sellId;
private String salesId;
@ApiModelProperty("产品id")
private String productId;
......@@ -40,10 +39,10 @@ public class SellTable extends Entity<SellTable> {
private String brandName;
@ApiModelProperty("销售数量")
private Integer sellNum;
private Integer salesNum;
@ApiModelProperty("销售单位")
private String sellUnit;
private String salesUnit;
......
package com.admin.mybatis.entity.product;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.basic.mybatis.common.base.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
@ApiModel(value="sell表",description="销售信息")
@Data
@TableName("sell")
public class Sell extends BaseEntity<Sell> {
private static final Long serialVersionUID = 1L;
@ApiModelProperty("销售Id")
@TableId
private String sellId;
@ApiModelProperty("销售日期")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
private Date sellDate;
@ApiModelProperty("客户名称")
private String customerName;
@ApiModelProperty("商品名称")
@TableField(exist = false)
private String productNames;
@ApiModelProperty("客户电话")
private String customerPhone;
@ApiModelProperty("客户地址")
private String customerAddress;
@ApiModelProperty("所属")
private String userId;
@ApiModelProperty("销售信息详细")
@TableField(exist = false)
private List<SellTable> records;
}
package com.admin.mybatis.mapper.product;
import com.admin.mybatis.entity.product.Sell;
import com.admin.mybatis.entity.product.SellTable;
import com.admin.mybatis.entity.product.SalesTable;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -9,11 +8,11 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface SellTableMapper extends BaseMapper<SellTable> {
List<SellTable> selectPage(Page<SellTable> page, @Param("ew") QueryWrapper<SellTable> wrapper);
public interface SalesTableMapper extends BaseMapper<SalesTable> {
List<SalesTable> selectPage(Page<SalesTable> page, @Param("ew") QueryWrapper<SalesTable> wrapper);
List<SellTable> selectList(@Param("ew") QueryWrapper<SellTable> wrapper);
List<SalesTable> selectList(@Param("ew") QueryWrapper<SalesTable> wrapper);
SellTable selectId(String id);
SalesTable selectId(String id);
}
package com.admin.mybatis.mapper.product;
import com.admin.mybatis.entity.product.Sell;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.basic.mybatis.common.base.SuperMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface SellMapper extends SuperMapper<Sell> {
List<Sell> selectPage(Page<Sell> page,@Param("ew") QueryWrapper<Sell> wrapper);
List<Sell> selectList(@Param("ew") QueryWrapper<Sell> wrapper);
Sell selectId(String id);
}
package com.admin.mybatis.service.product;
import com.admin.mybatis.entity.product.SellTable;
import com.admin.mybatis.entity.product.SalesTable;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
public interface SellTableService extends IService<SellTable> {
Page selectPage(Page<SellTable> page, QueryWrapper<SellTable> wrapper);
public interface SalesTableService extends IService<SalesTable> {
Page selectPage(Page<SalesTable> page, QueryWrapper<SalesTable> wrapper);
List selectList(QueryWrapper<SellTable> wrapper);
List selectList(QueryWrapper<SalesTable> wrapper);
SellTable queryById(String id);
SalesTable queryById(String id);
SellTable insert(SellTable entity);
SalesTable insert(SalesTable entity);
SellTable update(String id, SellTable entity);
SalesTable update(String id, SalesTable entity);
int removeByIds(List<String> ids);
......
package com.admin.mybatis.service.product;
import com.admin.mybatis.entity.product.Sell;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
public interface SellService {
Page selectPage(Page<Sell> page, QueryWrapper<Sell> wrapper);
List selectList(QueryWrapper<Sell> wrapper);
Sell queryById(String id);
Sell insert(Sell entity);
Sell update(String id, Sell entity);
int removeByIds(List<String> ids);
}
......@@ -2,10 +2,10 @@ package com.admin.mybatis.service.product.impl;
import com.admin.mybatis.common.util.StringUtil;
import com.admin.mybatis.entity.product.Sales;
import com.admin.mybatis.entity.product.SellTable;
import com.admin.mybatis.entity.product.SalesTable;
import com.admin.mybatis.mapper.product.SalesMapper;
import com.admin.mybatis.service.product.SalesService;
import com.admin.mybatis.service.product.SellTableService;
import com.admin.mybatis.service.product.SalesTableService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.basic.mybatis.common.base.SuperServiceImpl;
......@@ -21,7 +21,7 @@ import java.util.List;
//这个注解是用来修饰变量的,写在变量上面,并且由系统底层代理创建这个变量的实例,并注入到这个类中,就不用自己手动去创建对象了
public class SalesServiceImpl extends SuperServiceImpl<SalesMapper, Sales> implements SalesService {
@Autowired
private SellTableService recordsService;
private SalesTableService recordsService;
@Override//@Override注解是伪代码,用于表示被标注的方法是一个重写方法。
public Page selectPage(Page<Sales> page, QueryWrapper<Sales> wrapper) {
page.setRecords(baseMapper.selectPage(page,wrapper));
......@@ -43,10 +43,10 @@ public class SalesServiceImpl extends SuperServiceImpl<SalesMapper, Sales> imple
@Override
public Sales insert(Sales entity) {
int rows = baseMapper.insert(entity);
List<SellTable> records = entity.getRecords();
List<SalesTable> records = entity.getRecords();
if (StringUtil.isNotEmpty(records)){
records.stream().forEach(item -> {
item.setSellId(entity.getSalesId());
item.setSalesId(entity.getSalesId());
});
recordsService.saveBatch(records);
}
......@@ -59,15 +59,15 @@ public class SalesServiceImpl extends SuperServiceImpl<SalesMapper, Sales> imple
int rows =baseMapper.updateById(entity);
//先删除详细信息
List<SellTable> records = entity.getRecords();
QueryWrapper<SellTable> wrapper = new QueryWrapper<SellTable>();
wrapper .eq(StringUtil.isNotEmpty(entity.getSalesId()), "sell_id", entity.getSalesId());
List<SalesTable> records = entity.getRecords();
QueryWrapper<SalesTable> wrapper = new QueryWrapper<SalesTable>();
wrapper .eq(StringUtil.isNotEmpty(entity.getSalesId()), "sales_id", entity.getSalesId());
recordsService.remove(wrapper);
//再新增
if (StringUtil.isNotEmpty(records)){
records.stream().forEach(item -> {
item.setSellTableId(null);
item.setSellId(entity.getSalesId());
item.setSalesTableId(null);
item.setSalesId(entity.getSalesId());
});
recordsService.saveBatch(records);
}
......
package com.admin.mybatis.service.product.impl;
import com.admin.mybatis.entity.product.SellTable;
import com.admin.mybatis.mapper.product.SellTableMapper;
import com.admin.mybatis.entity.product.SalesTable;
import com.admin.mybatis.mapper.product.SalesTableMapper;
import com.admin.mybatis.service.product.SellTableService;
import com.admin.mybatis.service.product.SalesTableService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class SellTableServiceImpl extends SuperServiceImpl<SellTableMapper, SellTable> implements SellTableService {
public class SalesTableServiceImpl extends SuperServiceImpl<SalesTableMapper, SalesTable> implements SalesTableService {
/**
* 方法作用: 分页查询
* @param page
......@@ -20,7 +20,7 @@ public class SellTableServiceImpl extends SuperServiceImpl<SellTableMapper, Sell
* @return
*/
@Override
public Page selectPage(Page<SellTable> page, QueryWrapper<SellTable> wrapper) {
public Page selectPage(Page<SalesTable> page, QueryWrapper<SalesTable> wrapper) {
page.setRecords(baseMapper.selectPage(page,wrapper));
return page;
}
......@@ -31,8 +31,8 @@ public class SellTableServiceImpl extends SuperServiceImpl<SellTableMapper, Sell
* @return
*/
@Override
public List selectList(QueryWrapper<SellTable> wrapper) {
List<SellTable> list = baseMapper.selectList(wrapper);
public List selectList(QueryWrapper<SalesTable> wrapper) {
List<SalesTable> list = baseMapper.selectList(wrapper);
return list;
}
......@@ -42,8 +42,8 @@ public class SellTableServiceImpl extends SuperServiceImpl<SellTableMapper, Sell
* @return
*/
@Override
public SellTable queryById(String id) {
SellTable entity = baseMapper.selectId(id);
public SalesTable queryById(String id) {
SalesTable entity = baseMapper.selectId(id);
return entity;
}
......@@ -53,7 +53,7 @@ public class SellTableServiceImpl extends SuperServiceImpl<SellTableMapper, Sell
* @return
*/
@Override
public SellTable insert(SellTable entity) {
public SalesTable insert(SalesTable entity) {
baseMapper.insert(entity);
return entity;
}
......@@ -65,8 +65,8 @@ public class SellTableServiceImpl extends SuperServiceImpl<SellTableMapper, Sell
* @return
*/
@Override
public SellTable update(String id, SellTable entity) {
entity.setSellTableId(id);
public SalesTable update(String id, SalesTable entity) {
entity.setSalesTableId(id);
baseMapper.updateById(entity);
return entity;
}
......
package com.admin.mybatis.service.product.impl;
import com.admin.mybatis.common.util.StringUtil;
import com.admin.mybatis.entity.product.Sell;
import com.admin.mybatis.entity.product.SellTable;
import com.admin.mybatis.mapper.product.SellMapper;
import com.admin.mybatis.service.product.SellService;
import com.admin.mybatis.service.product.SellTableService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.basic.mybatis.common.base.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class SellServiceImpl extends SuperServiceImpl<SellMapper, Sell> implements SellService {
@Autowired
private SellTableService recordsService;
/**
* 方法作用: 分页查询
* @param page
* @param wrapper
* @return
*/
@Override
public Page selectPage(Page<Sell> page, QueryWrapper<Sell> wrapper) {
page.setRecords(baseMapper.selectPage(page,wrapper));
return page;
}
/**
* 方法作用: 查询所有
* @param wrapper
* @return
*/
@Override
public List selectList(QueryWrapper<Sell> wrapper) {
List<Sell> list = baseMapper.selectList(wrapper);
return list;
}
/**
* 方法作用: 根据Id查询
* @param id
* @return
*/
@Override
public Sell queryById(String id) {
Sell entity = baseMapper.selectId(id);
return entity;
}
/**
* 方法作用: 新增
* @param entity
* @return
*/
@Override
public Sell insert(Sell entity) {
int rows = baseMapper.insert(entity);
List<SellTable> records = entity.getRecords();
if (StringUtil.isNotEmpty(records)){
records.stream().forEach(item -> {
item.setSellId(entity.getSellId());
});
recordsService.saveBatch(records);
}
return entity;
}
/**
* 方法作用: 根据Id更新
* @param id
* @param entity
* @return
*/
@Override
public Sell update(String id, Sell entity) {
entity.setSellId(id);
int rows =baseMapper.updateById(entity);
//先删除详细信息
List<SellTable> records = entity.getRecords();
QueryWrapper<SellTable> wrapper = new QueryWrapper<SellTable>();
wrapper .eq(StringUtil.isNotEmpty(entity.getSellId()), "sell_id", entity.getSellId());
recordsService.remove(wrapper);
//再新增
if (StringUtil.isNotEmpty(records)){
records.stream().forEach(item -> {
item.setSellTableId(null);
item.setSellId(entity.getSellId());
});
recordsService.saveBatch(records);
}
return entity;
}
@Override
public int removeByIds(List<String> ids) {
int rows=baseMapper.deleteBatchIds(ids);
return rows;
}
}
spring:
datasource:
url: jdbc:mysql://101.133.145.61:44170/example?allowMultiQueries=true&serverTimezone=Asia/Shanghai
url: jdbc:mysql://localhost:3306/example?allowMultiQueries=true&serverTimezone=Asia/Shanghai
username: root
password: rkoddtlxf
password: rkoddt
#redis config
redis:
database: 1
host: 101.133.145.61
port: 5268
password: randyorton
host: 127.0.0.1
port: 6379
data:
mongodb:
#主机ip
host: 101.133.145.61
host: 127.0.0.1
#端口号
port: 38128
port: 27017
#选择数据库
database: good
username: molisen
password: miznba
database: test
#配置rabbitMq 服务器
rabbitmq:
host: 101.133.145.61
port: 6183
username: chris
password: jericho
host: 127.0.0.1
port: 5672
username: guest
password: guest
......
......@@ -6,7 +6,7 @@
a.sales_id,
a.sales_date,
a.customer_name,
(select GROUP_CONCAT(g.product_name) from sell_table f inner join product_information g on g.product_id=f.product_id where f.sell_id = a.sell_id ) productNames,
(select GROUP_CONCAT(g.product_name) from sales_table f inner join product_information g on g.product_id=f.product_id where f.sales_id = a.sales_id ) productNames,
a.customer_phone,
a.customer_address,
a.create_by,
......@@ -28,7 +28,7 @@
a.sales_id,
a.sales_date,
a.customer_name,
(select GROUP_CONCAT(g.product_name) from sell_table f inner join product_information g on g.product_id=f.product_id where f.sell_id = a.sell_id ) productNames,
(select GROUP_CONCAT(g.product_name) from sales_table f inner join product_information g on g.product_id=f.product_id where f.sales_id = a.sales_id ) productNames,
a.customer_phone,
a.customer_address,
a.create_by,
......@@ -66,27 +66,27 @@
where a.sales_id = #{id}
</select>
<resultMap type="Sell" id="SellMap">
<id property="sellId" column="sell_id"/>
<collection property="records" javaType="ArrayList" column="{sell_id = sell_id}" ofType="SellTable"
<resultMap type="Sales" id="SalesMap">
<id property="salesId" column="sales_id"/>
<collection property="records" javaType="ArrayList" column="{sales_id = sales_id}" ofType="SalesTable"
select="selectRecords"/>
</resultMap>
<!-- 查询全部 -->
<select id="selectRecords" resultType="SellTable">
<select id="selectRecords" resultType="SalesTable">
select
a.sell_table_id,
a.sales_table_id,
a.product_id,
(select brand_name from product_information where product_id=a.product_id )brandName,
(select product_name from product_information where product_id=a.product_id )productName,
a.sell_id,
a.sell_num,
a.sell_unit
a.sales_id,
a.sales_num,
a.sales_unit
from
sell_table a
sales_table a
<where>
a.sales_id=#{sell_id}
a.sales_id=#{sales_id}
</where>
</select>
......
<?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.admin.mybatis.mapper.product.SellTableMapper">
<mapper namespace="com.admin.mybatis.mapper.product.SalesTableMapper">
<select id="selectPage" resultType="SellTable">
<select id="selectPage" resultType="SalesTable">
select
a.sell_table_id,
a.sales_table_id,
a.product_id,
a.sell_id,
a.sales_id,
(select brand_name from product_information where product_id=a.product_id )brandName,
(select product_name from product_information where product_id=a.product_id )productName,
a.sell_num,
a.sell_unit
a.sales_num,
a.sales_unit
from
sell_table a
sales_table a
<where>
${ew.sqlSegment}
</where>
</select>
<!-- 查询全部 -->
<select id="selectList" resultType="SellTable">
<select id="selectList" resultType="SalesTable">
select
a.sell_table_id,
a.sales_table_id,
a.product_id,
a.sell_id,
a.sales_id,
(select brand_name from product_information where product_id=a.product_id )brandName,
(select product_name from product_information where product_id=a.product_id )productName,
a.sell_num,
a.sell_unit
a.sales_num,
a.sales_unit
from
sell_table a
sales_table a
<where>
${ew.sqlSegment}
</where>
</select>
<!-- 查询详情 -->
<select id="selectId" parameterType="String" resultType="SellTable">
<select id="selectId" parameterType="String" resultType="SalesTable">
select
a.sell_table_id,
a.sales_table_id,
a.product_id,
a.sell_id,
a.sales_id,
(select brand_name from product_information where product_id=a.product_id )brandName,
(select product_name from product_information where product_id=a.product_id )productName,
a.sell_num,
a.sell_unit
a.sales_num,
a.sales_unit
from
sell_table a
where a.sell_table_id = #{id}
sales_table a
where a.sales_table_id = #{id}
</select>
......
<?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.admin.mybatis.mapper.product.SellMapper">
<select id="selectPage" resultType="Sell">
select
a.sell_id,
a.sell_date,
a.customer_name,
(select GROUP_CONCAT(g.product_name) from sell_table f inner join product_information g on g.product_id=f.product_id where f.sell_id = a.sell_id ) productNames,
a.customer_phone,
a.customer_address,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
(select full_name from sys_user where user_id =a.update_by) updateName,
a.is_delete,
a.user_id
from
sell a
<where>
${ew.sqlSegment}
</where>
</select>
<!-- 查询全部 -->
<select id="selectList" resultType="Sell">
select
a.sell_id,
a.sell_date,
a.customer_name,
(select GROUP_CONCAT(g.product_name) from sell_table f inner join product_information g on g.product_id=f.product_id where f.sell_id = a.sell_id ) productNames,
a.customer_phone,
a.customer_address,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
(select full_name from sys_user where user_id =a.update_by) updateName,
a.is_delete,
a.user_id
from
sell a
<where>
${ew.sqlSegment}
</where>
</select>
<!-- 查询详情 -->
<select id="selectId" parameterType="String" resultMap="SellMap">
select
a.sell_id,
a.sell_date,
a.customer_name,
(select GROUP_CONCAT(g.product_name) from sell_table f inner join product_information g on g.product_id=f.product_id where f.sell_id = a.sell_id ) productNames,
a.customer_phone,
a.customer_address,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
(select full_name from sys_user where user_id =a.update_by) updateName,
a.is_delete,
a.user_id
from
sell a
where a.sell_id = #{id}
</select>
<resultMap type="Sell" id="SellMap">
<id property="sellId" column="sell_id"/>
<collection property="records" javaType="ArrayList" column="{sell_id = sell_id}" ofType="SellTable"
select="selectRecords"/>
</resultMap>
<!-- 查询全部 -->
<select id="selectRecords" resultType="SellTable">
select
a.sell_table_id,
a.product_id,
(select brand_name from product_information where product_id=a.product_id )brandName,
(select product_name from product_information where product_id=a.product_id )productName,
a.sell_id,
a.sell_num,
a.sell_unit
from
sell_table a
<where>
a.sell_id=#{sell_id}
</where>
</select>
</mapper>
\ No newline at end of file
......@@ -110,11 +110,9 @@ const customer = `${config.http_url}/api/customer`;
//销售信息管理
const sales = `${config.http_url}/api/sales`;
//销售信息管理
const sell = `${config.http_url}/api/sell`;
//销售表管理
const sellTable = `${config.http_url}/api/sellTable`;
const salesTable = `${config.http_url}/api/salesTable`;
//品种信息
const breed = `${config.http_url}/api/breed`;
......@@ -166,9 +164,8 @@ export default {
client,
productInformation,
customer,
sell,
sales,
sellTable,
salesTable,
breed,
cultivationEnterprise,
publicService,
......
......@@ -9,12 +9,12 @@ import teamApi from './personnel/team';
import clientApi from './personnel/client';
import productInformationApi from './product/productInformation';
import customerApi from './product/customer';
import sellApi from './product/sell';
import sellTableApi from './product/sellTable';
import salesApi from './product/sales';
import salesTableApi from './product/salesTable';
import breedApi from './product/breed';
import cultivationEnterpriseApi from './system/user/cultivationEnterprise';
import publicServiceApi from './system/publicService';
import salesApi from './product/sales';
export default {
......@@ -29,11 +29,10 @@ export default {
clientApi,
productInformationApi,
customerApi,
sellApi,
sellTableApi,
salesApi,
salesTableApi,
breedApi,
cultivationEnterpriseApi,
publicServiceApi,
salesApi,
}
......@@ -4,44 +4,44 @@ import ajax from '@/common/api/api-util.js';
const myProcessApi = {
//销售信息列表
sellList(params) {
salesList(params) {
return ajax.ajax({
type: 'get',
url: jsonUrl.sell + "/page",
url: jsonUrl.sales + "/page",
params: params,
});
},
//销售信息详情
sellInfo(params,id) {
salesInfo(params,id) {
return ajax.ajax({
type: 'get',
url: `${jsonUrl.sell}/get/${id}`,
url: `${jsonUrl.sales}/get/${id}`,
params:params,
id:id
});
},
//销售信息保存
sellSave(params) {
salesSave(params) {
return ajax.ajax({
type: 'post',
url: jsonUrl.sell + "/add",
url: jsonUrl.sales + "/add",
params: params
});
},
//销售信息修改
sellUpdate(params, id) {
salesUpdate(params, id) {
return ajax.ajax({
type: 'put',
url: `${jsonUrl.sell}/put/${id}`,
url: `${jsonUrl.sales}/put/${id}`,
params: params,
id: id
});
},
//销售信息删除
sellDelete(params) {
salesDelete(params) {
return ajax.ajax({
type: 'DELETE',
url: jsonUrl.sell + "/deletes",
url: jsonUrl.sales + "/deletes",
params: params,
});
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment