Authored by caoyan

Merge branch 'test6.9.8' of http://git.yoho.cn/ufo/ufo-platform into test6.9.8

... ... @@ -106,4 +106,12 @@ public interface UfoSizeMapper {
List<Size> selectBySizeName(@Param("sizeName") String sizeName);
List<Size> selectBySizeNameList(@Param("sizeNameList")List<String> sizeNameList);
/**
* 根据尺码名称查询尺码对象
* @param id 排除当前的尺码id,如果有的话
* @param sizeName
* @return
*/
List<Size> selectBySizeNameEx(@Param("sizeName") String sizeName, @Param("id")Integer id);
}
... ...
... ... @@ -206,5 +206,11 @@
#{item}
</foreach>
</select>
<select id="selectBySizeNameEx" resultMap="sizeMap">
select id, size_name from size where size_name = #{sizeName}
<if test="id != null">
AND id != #{id}
</if>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -32,8 +32,9 @@ public class SizeController {
public ApiResponse<Object> saveOrUpdateSize(SizeRequestBo sizeRequestBo) {
LOGGER.info("saveOrUpdateSize param = {}", sizeRequestBo);
OvalValidationUtils.validate(sizeRequestBo);
sizeService.saveOrUpdateSize(sizeRequestBo);
return new ApiResponse<>();
int num = sizeService.saveOrUpdateSize(sizeRequestBo);
return num > 0 ? new ApiResponse<>(200, "") : new ApiResponse<>(400, "尺码已存在");
}
... ...
... ... @@ -63,7 +63,13 @@ public class SizeServiceImpl implements ISizeService {
LOGGER.info("saveOrUpdateSize param = {}", sizeRequestBo);
Size size = OrikaUtils.map(sizeRequestBo, Size.class);
if (size.getId() == null || size.getId() == 0) {
size.setCreateTime(DateUtil.currentTimeSeconds());
List<Size> sizes = ufoSizeMapper.selectBySizeNameEx(size.getSizeName(), null);
if (CollectionUtils.isNotEmpty(sizes)) {
return 0;
}
size.setCreateTime(DateUtil.currentTimeSeconds());
size.setDel(0);
size.setUpdateTime(0);
if (size.getOrderBy() == null) {
... ... @@ -72,6 +78,11 @@ public class SizeServiceImpl implements ISizeService {
// 新增
return ufoSizeMapper.insertSize(size);
} else {
List<Size> sizes = ufoSizeMapper.selectBySizeNameEx(size.getSizeName(), size.getId());
if (CollectionUtils.isNotEmpty(sizes)) {
return 0;
}
// 更新
size.setUpdateTime(DateUtil.currentTimeSeconds());
return ufoSizeMapper.updateSize(size);
... ...