Commit 1490ee43 by tyfanchz

功能修复

1 parent 7b330ab9
......@@ -3,7 +3,6 @@ package com.glsx.smart.dao.mapper;
import java.util.List;
import com.glsx.smart.dao.entity.SmartProduct;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* <p>Description:
......@@ -15,18 +14,9 @@ import org.apache.ibatis.annotations.Param;
@Mapper
public interface SmartProductMapper extends tk.mybatis.mapper.common.Mapper<SmartProduct> {
List<SmartProduct> getList(SmartProduct req);
List<SmartProduct> getList(SmartProduct product);
int countByProductName(String productName);
int insertOrUpdate(SmartProduct record);
int insertOrUpdateSelective(SmartProduct record);
SmartProduct getById(Long id);
int updateBatch(List<SmartProduct> list);
int updateBatchSelective(List<SmartProduct> list);
int batchInsert(@Param("list") List<SmartProduct> list);
int countByProductName(String productName);
}
......@@ -14,7 +14,9 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SmartProductTypeMapper extends tk.mybatis.mapper.common.Mapper<SmartProductType> {
List<SmartProductType> getList(SmartProductType req);
List<SmartProductType> getList(SmartProductType productType);
SmartProductType getById(Long id);
int countByProductTypeName(String typeName);
......
......@@ -14,7 +14,7 @@ import com.glsx.smart.dao.entity.SmartProduct;
*/
public interface SmartProductService {
PageInfo<SmartProduct> getList(SmartProduct req);
PageInfo<SmartProduct> getList(SmartProduct product);
SmartProduct getById(Long id);
......
......@@ -14,7 +14,7 @@ import com.glsx.smart.dao.entity.SmartProductType;
*/
public interface SmartProductTypeService {
PageInfo<SmartProductType> getList(SmartProductType req);
PageInfo<SmartProductType> getList(SmartProductType productType);
SmartProductType getById(Long id);
......
......@@ -37,13 +37,13 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
/**
* 获取产品列表。
*
* @param req 请求体
* @param product 请求体
* @return 结果
*/
@Override
public PageInfo<SmartProduct> getList(SmartProduct req) {
super.startPagination(req);
List<SmartProduct> productList = productMapper.getList(req);
public PageInfo<SmartProduct> getList(SmartProduct product) {
super.startPagination(product);
List<SmartProduct> productList = productMapper.getList(product);
PageInfo<SmartProduct> pageInfo = PageInfo.of(productList);
return pageInfo;
}
......@@ -56,7 +56,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
*/
@Override
public SmartProduct getById(Long id) {
SmartProduct product = productMapper.selectByPrimaryKey(id);
SmartProduct product = productMapper.getById(id);
if (product == null) {
throw new BusinessException(ResultEnum.PRODUCT_NOT_FOUND);
}
......@@ -73,6 +73,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
public void save(SmartProduct product) {
Date now = new Date();
product.setUpdateTime(now);
product.setUpdateBy(0L);
if (product.getId() == null) {
int nameCount = productMapper.countByProductName(product.getProductName());
......@@ -80,6 +81,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
throw new BusinessException(ResultEnum.PRODUCT_NAME_DUPLICATE);
}
product.setCreateTime(now);
product.setCreateBy(0L);
productMapper.insertSelective(product);
} else {
SmartProduct record = productMapper.selectByPrimaryKey(product.getId());
......
......@@ -36,13 +36,13 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
/**
* 获取产品类型列表。
*
* @param req 请求
* @param productType 请求
* @return 结果
*/
@Override
public PageInfo<SmartProductType> getList(SmartProductType req) {
super.startPagination(req);
List<SmartProductType> productTypeList = productTypeMapper.getList(req);
public PageInfo<SmartProductType> getList(SmartProductType productType) {
super.startPagination(productType);
List<SmartProductType> productTypeList = productTypeMapper.getList(productType);
PageInfo<SmartProductType> pageInfo = PageInfo.of(productTypeList);
return pageInfo;
}
......@@ -55,7 +55,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
*/
@Override
public SmartProductType getById(Long id) {
SmartProductType productType = productTypeMapper.selectByPrimaryKey(id);
SmartProductType productType = productTypeMapper.getById(id);
if (productType == null) {
throw new BusinessException(ResultEnum.PRODUCT_TYPE_NOT_FOUND);
}
......@@ -113,6 +113,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
public void save(SmartProductType productType) {
Date now = new Date();
productType.setUpdateTime(now);
productType.setUpdateBy(0L);
if (productType.getId() == null) {
int nameCount = productTypeMapper.countByProductTypeName(productType.getTypeName());
......@@ -120,6 +121,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
throw new BusinessException(ResultEnum.PRODUCT_TYPE_NAME_DUPLICATE);
}
productType.setCreateTime(now);
productType.setCreateBy(0L);
productTypeMapper.insertSelective(productType);
} else {
SmartProductType record = productTypeMapper.selectByPrimaryKey(productType.getId());
......
......@@ -43,6 +43,18 @@
order by sp.create_time desc
</select>
<select id="getById" resultMap="BaseResultMap">
select sp.id, sp.product_name, sp.icon, sp.type_id, sp.shop_product_id, sp.platform_key,
sp.platform_product_id, sp.network_key, sp.status, sp.remark, sp.create_time,
sp.create_by, sp.update_time, sp.update_by,
ssf.url iconUrl,
spt.type_name typeName
from smart_product sp
left join smart_sys_file ssf on ssf.id = sp.icon
left join smart_product_type spt on spt.id = sp.type_id
where sp.id = #{id,jdbcType=BIGINT}
</select>
<select id="countByProductName" resultType="integer">
select count(0)
from smart_product
......
......@@ -33,6 +33,13 @@
order by spt.create_time desc
</select>
<select id="getById" resultMap="BaseResultMap">
select spt.id, spt.type_name, spt.category_key, spt.shop_tag, spt.remark, spt.create_time,
spt.create_by, spt.update_time, spt.update_by
from smart_product_type spt
where spt.id = #{id,jdbcType=BIGINT}
</select>
<select id="countByProductTypeName" resultType="int">
select count(0)
from smart_product_type
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!