Commit 1490ee43 by tyfanchz

功能修复

1 parent 7b330ab9
...@@ -3,7 +3,6 @@ package com.glsx.smart.dao.mapper; ...@@ -3,7 +3,6 @@ package com.glsx.smart.dao.mapper;
import java.util.List; import java.util.List;
import com.glsx.smart.dao.entity.SmartProduct; import com.glsx.smart.dao.entity.SmartProduct;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* <p>Description: * <p>Description:
...@@ -15,18 +14,9 @@ import org.apache.ibatis.annotations.Param; ...@@ -15,18 +14,9 @@ import org.apache.ibatis.annotations.Param;
@Mapper @Mapper
public interface SmartProductMapper extends tk.mybatis.mapper.common.Mapper<SmartProduct> { public interface SmartProductMapper extends tk.mybatis.mapper.common.Mapper<SmartProduct> {
List<SmartProduct> getList(SmartProduct req); List<SmartProduct> getList(SmartProduct product);
int countByProductName(String productName); SmartProduct getById(Long id);
int insertOrUpdate(SmartProduct record);
int insertOrUpdateSelective(SmartProduct record);
int updateBatch(List<SmartProduct> list); int countByProductName(String productName);
int updateBatchSelective(List<SmartProduct> list);
int batchInsert(@Param("list") List<SmartProduct> list);
} }
...@@ -14,7 +14,9 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -14,7 +14,9 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface SmartProductTypeMapper extends tk.mybatis.mapper.common.Mapper<SmartProductType> { 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); int countByProductTypeName(String typeName);
......
...@@ -14,7 +14,7 @@ import com.glsx.smart.dao.entity.SmartProduct; ...@@ -14,7 +14,7 @@ import com.glsx.smart.dao.entity.SmartProduct;
*/ */
public interface SmartProductService { public interface SmartProductService {
PageInfo<SmartProduct> getList(SmartProduct req); PageInfo<SmartProduct> getList(SmartProduct product);
SmartProduct getById(Long id); SmartProduct getById(Long id);
......
...@@ -14,7 +14,7 @@ import com.glsx.smart.dao.entity.SmartProductType; ...@@ -14,7 +14,7 @@ import com.glsx.smart.dao.entity.SmartProductType;
*/ */
public interface SmartProductTypeService { public interface SmartProductTypeService {
PageInfo<SmartProductType> getList(SmartProductType req); PageInfo<SmartProductType> getList(SmartProductType productType);
SmartProductType getById(Long id); SmartProductType getById(Long id);
......
...@@ -37,13 +37,13 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct ...@@ -37,13 +37,13 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
/** /**
* 获取产品列表。 * 获取产品列表。
* *
* @param req 请求体 * @param product 请求体
* @return 结果 * @return 结果
*/ */
@Override @Override
public PageInfo<SmartProduct> getList(SmartProduct req) { public PageInfo<SmartProduct> getList(SmartProduct product) {
super.startPagination(req); super.startPagination(product);
List<SmartProduct> productList = productMapper.getList(req); List<SmartProduct> productList = productMapper.getList(product);
PageInfo<SmartProduct> pageInfo = PageInfo.of(productList); PageInfo<SmartProduct> pageInfo = PageInfo.of(productList);
return pageInfo; return pageInfo;
} }
...@@ -56,7 +56,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct ...@@ -56,7 +56,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
*/ */
@Override @Override
public SmartProduct getById(Long id) { public SmartProduct getById(Long id) {
SmartProduct product = productMapper.selectByPrimaryKey(id); SmartProduct product = productMapper.getById(id);
if (product == null) { if (product == null) {
throw new BusinessException(ResultEnum.PRODUCT_NOT_FOUND); throw new BusinessException(ResultEnum.PRODUCT_NOT_FOUND);
} }
...@@ -73,6 +73,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct ...@@ -73,6 +73,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
public void save(SmartProduct product) { public void save(SmartProduct product) {
Date now = new Date(); Date now = new Date();
product.setUpdateTime(now); product.setUpdateTime(now);
product.setUpdateBy(0L);
if (product.getId() == null) { if (product.getId() == null) {
int nameCount = productMapper.countByProductName(product.getProductName()); int nameCount = productMapper.countByProductName(product.getProductName());
...@@ -80,6 +81,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct ...@@ -80,6 +81,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
throw new BusinessException(ResultEnum.PRODUCT_NAME_DUPLICATE); throw new BusinessException(ResultEnum.PRODUCT_NAME_DUPLICATE);
} }
product.setCreateTime(now); product.setCreateTime(now);
product.setCreateBy(0L);
productMapper.insertSelective(product); productMapper.insertSelective(product);
} else { } else {
SmartProduct record = productMapper.selectByPrimaryKey(product.getId()); SmartProduct record = productMapper.selectByPrimaryKey(product.getId());
......
...@@ -36,13 +36,13 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro ...@@ -36,13 +36,13 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
/** /**
* 获取产品类型列表。 * 获取产品类型列表。
* *
* @param req 请求 * @param productType 请求
* @return 结果 * @return 结果
*/ */
@Override @Override
public PageInfo<SmartProductType> getList(SmartProductType req) { public PageInfo<SmartProductType> getList(SmartProductType productType) {
super.startPagination(req); super.startPagination(productType);
List<SmartProductType> productTypeList = productTypeMapper.getList(req); List<SmartProductType> productTypeList = productTypeMapper.getList(productType);
PageInfo<SmartProductType> pageInfo = PageInfo.of(productTypeList); PageInfo<SmartProductType> pageInfo = PageInfo.of(productTypeList);
return pageInfo; return pageInfo;
} }
...@@ -55,7 +55,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro ...@@ -55,7 +55,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
*/ */
@Override @Override
public SmartProductType getById(Long id) { public SmartProductType getById(Long id) {
SmartProductType productType = productTypeMapper.selectByPrimaryKey(id); SmartProductType productType = productTypeMapper.getById(id);
if (productType == null) { if (productType == null) {
throw new BusinessException(ResultEnum.PRODUCT_TYPE_NOT_FOUND); throw new BusinessException(ResultEnum.PRODUCT_TYPE_NOT_FOUND);
} }
...@@ -113,6 +113,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro ...@@ -113,6 +113,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
public void save(SmartProductType productType) { public void save(SmartProductType productType) {
Date now = new Date(); Date now = new Date();
productType.setUpdateTime(now); productType.setUpdateTime(now);
productType.setUpdateBy(0L);
if (productType.getId() == null) { if (productType.getId() == null) {
int nameCount = productTypeMapper.countByProductTypeName(productType.getTypeName()); int nameCount = productTypeMapper.countByProductTypeName(productType.getTypeName());
...@@ -120,6 +121,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro ...@@ -120,6 +121,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
throw new BusinessException(ResultEnum.PRODUCT_TYPE_NAME_DUPLICATE); throw new BusinessException(ResultEnum.PRODUCT_TYPE_NAME_DUPLICATE);
} }
productType.setCreateTime(now); productType.setCreateTime(now);
productType.setCreateBy(0L);
productTypeMapper.insertSelective(productType); productTypeMapper.insertSelective(productType);
} else { } else {
SmartProductType record = productTypeMapper.selectByPrimaryKey(productType.getId()); SmartProductType record = productTypeMapper.selectByPrimaryKey(productType.getId());
......
...@@ -43,6 +43,18 @@ ...@@ -43,6 +43,18 @@
order by sp.create_time desc order by sp.create_time desc
</select> </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 id="countByProductName" resultType="integer">
select count(0) select count(0)
from smart_product from smart_product
......
...@@ -33,6 +33,13 @@ ...@@ -33,6 +33,13 @@
order by spt.create_time desc order by spt.create_time desc
</select> </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 id="countByProductTypeName" resultType="int">
select count(0) select count(0)
from smart_product_type 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!