Skip to content

Commit

Permalink
2017/12/01
Browse files Browse the repository at this point in the history
  • Loading branch information
jomalonejia committed Dec 1, 2017
1 parent 6c8e882 commit baff6f3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cz-api/src/main/java/com/cz/api/service/IItemService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Created by jomalone_jia on 2017/6/20.
*/
public interface IItemService extends IService<Item>{
String saveOrUpdateItemContent(ItemContent itemContent);
void saveOrUpdateItemContent(ItemContent itemContent);
PageInfo<Item> listItems(int pageNum,int pageSize);
PageInfo<Item> listItemsByCategory(int categoryId,int pageNum);
Integer updateImageById(String itemId, String imageUrl);
Expand Down
2 changes: 1 addition & 1 deletion cz-dao/src/main/java/com/cz/mapper/xml/ItemMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
</delete>

<update id="deleteItemContentById">
update sys_item SET content = '' WHERE id = #{itemId}
update sys_item SET content = NULL WHERE id = #{itemId}
</update>

</mapper>
12 changes: 7 additions & 5 deletions cz-service/src/main/java/com/cz/service/service/ItemService.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public class ItemService extends BaseServiceImpl<ItemMapper, Item> implements II

@Override
@Transactional
public String saveOrUpdateItemContent(ItemContent itemContent) {
String content = itemMapper.getItemContentById(itemContent.getItemId());
public void saveOrUpdateItemContent(ItemContent itemContent) {
/*String content = itemMapper.getItemContentById(itemContent.getItemId());
if(StringUtils.isNotEmpty(content)){
Pattern deletePattern = Pattern.compile("<img src=\"http://otlht2gvo.bkt.clouddn.com/(.*?)\">");
Matcher matcher = deletePattern.matcher(content);
Expand All @@ -65,9 +65,11 @@ public String saveOrUpdateItemContent(ItemContent itemContent) {
String imageTag = "<img src=\"" + imageUrl + "\">";
m.appendReplacement(sb, imageTag);
}
m.appendTail(sb);
itemMapper.updateContentById(new ItemContent(itemContent.getItemId(),sb.toString()));
return sb.toString();
m.appendTail(sb);*/
//itemMapper.updateContentById(new ItemContent(itemContent.getItemId(),sb.toString()));
Item item = itemMapper.selectById(itemContent.getItemId());
item.setContent(itemContent.getContent());
itemMapper.updateById(item);
}

@Override
Expand Down
8 changes: 8 additions & 0 deletions cz-service/src/test/java/TestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.cz.api.service.*;
import com.cz.common.util.qiniu.PictureUtil;
import com.cz.dto.item.ItemContent;
import com.cz.mapper.ItemMapper;
import com.cz.model.category.Category;
import com.cz.model.item.Item;
import com.cz.model.order.Order;
Expand Down Expand Up @@ -41,6 +42,8 @@ public class TestConfig {
private IParamService paramService;
@Autowired
private IOrderService orderService;
@Autowired
private ItemMapper itemMapper;

@Test
public void test1() {
Expand Down Expand Up @@ -329,5 +332,10 @@ public void test31(){
}
PictureUtil.getInstance().bucketDelete(deleteArray.toArray(new String[0]));
}

@Test
public void test32(){
itemMapper.deleteItemContentById("60e054fdd0c74824bbbac46bf7d08603");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ public Object updateImages(@PathVariable("itemId") String itemId,@PathVariable("
@ApiOperation(value = "item content update")
public ResponseEntity<?> addContent(@RequestBody ItemContent itemContent) throws IOException, NoSuchAlgorithmException {
try {
_log.info(itemContent.toString());
itemService.saveOrUpdateItemContent(itemContent);
return ResponseEntity.ok().body("update content success");
} catch (Exception e) {
Expand Down

0 comments on commit baff6f3

Please sign in to comment.