|
@@ -3,6 +3,7 @@ package cn.efunbox.audio.controller;
|
|
|
import cn.efunbox.audio.entity.Channel;
|
|
|
import cn.efunbox.audio.service.ChannelService;
|
|
|
import cn.efunbox.audio.utils.ApiCode;
|
|
|
+import cn.efunbox.audio.utils.Common;
|
|
|
import cn.efunbox.audio.utils.HttpUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -83,15 +84,23 @@ public class ChannelController {
|
|
|
|
|
|
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
|
|
public void Update(HttpServletRequest request, HttpServletResponse response, @RequestBody Channel channel){
|
|
|
- List<Channel> list = channelService.SearchByName(channel.getName());
|
|
|
- if(list!=null && list.size()>0){
|
|
|
- HttpUtil.responseApiCode(request, response, ApiCode.RECORD_EXIST);
|
|
|
+ Channel channelOld = channelService.GetOne(channel.getId());
|
|
|
+ if(channelOld==null){
|
|
|
+ HttpUtil.responseApiCode(request, response, ApiCode.PARAMETER_ERROR);
|
|
|
return;
|
|
|
}
|
|
|
- channel.setCreated(new Timestamp(new Date().getTime()));
|
|
|
+ channel = (Channel) Common.CopyValue(channel, channelOld);
|
|
|
channel = channelService.Insert(channel);
|
|
|
HttpUtil.responseOutWithJson(request, response, channel);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/delete", method = RequestMethod.POST)
|
|
|
+ public void Delete(HttpServletRequest request, HttpServletResponse response){
|
|
|
+ String idChannel = request.getParameter("idChannel");
|
|
|
+ channelService.Delete(Long.valueOf(idChannel));
|
|
|
+ HttpUtil.responseOk(request, response);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
}
|