diff --git a/austin-support/src/main/java/com/java3y/austin/support/dao/ChannelAccountDao.java b/austin-support/src/main/java/com/java3y/austin/support/dao/ChannelAccountDao.java index 442201a..d149aea 100644 --- a/austin-support/src/main/java/com/java3y/austin/support/dao/ChannelAccountDao.java +++ b/austin-support/src/main/java/com/java3y/austin/support/dao/ChannelAccountDao.java @@ -5,6 +5,7 @@ import com.java3y.austin.support.domain.ChannelAccount; import com.java3y.austin.support.domain.MessageTemplate; import com.java3y.austin.support.domain.SmsRecord; import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.repository.CrudRepository; import java.util.List; @@ -14,7 +15,7 @@ import java.util.List; * * @author 3y */ -public interface ChannelAccountDao extends CrudRepository { +public interface ChannelAccountDao extends JpaRepository { /** diff --git a/austin-web/src/main/java/com/java3y/austin/web/controller/ChannelAccountController.java b/austin-web/src/main/java/com/java3y/austin/web/controller/ChannelAccountController.java index 36ae4f0..308beb6 100644 --- a/austin-web/src/main/java/com/java3y/austin/web/controller/ChannelAccountController.java +++ b/austin-web/src/main/java/com/java3y/austin/web/controller/ChannelAccountController.java @@ -1,11 +1,9 @@ package com.java3y.austin.web.controller; -import com.java3y.austin.common.constant.AustinConstant; +import cn.hutool.core.util.StrUtil; import com.java3y.austin.common.vo.BasicResultVO; -import com.java3y.austin.support.dao.ChannelAccountDao; import com.java3y.austin.support.domain.ChannelAccount; -import com.java3y.austin.support.domain.MessageTemplate; import com.java3y.austin.web.service.ChannelAccountService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -13,6 +11,10 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + /** * 渠道账号管理接口 * @@ -21,7 +23,7 @@ import org.springframework.web.bind.annotation.*; @Slf4j @RestController @RequestMapping("/account") -@Api("素材管理接口") +@Api("渠道账号管理接口") @CrossOrigin(origins = "http://localhost:3000", allowCredentials = "true", allowedHeaders = "*") public class ChannelAccountController { @@ -42,10 +44,34 @@ public class ChannelAccountController { /** * 根据渠道标识查询渠道账号相关的信息 */ - @GetMapping("/query") - @ApiOperation("/保存数据") + @GetMapping("/queryByChannelType") + @ApiOperation("/根据渠道标识查询相关的记录") public BasicResultVO query(Integer channelType) { return BasicResultVO.success(channelAccountService.queryByChannelType(channelType)); } + /** + * 所有的渠道账号信息 + */ + @GetMapping("/list") + @ApiOperation("/渠道账号列表信息") + public BasicResultVO list() { + return BasicResultVO.success(channelAccountService.list()); + } + + /** + * 根据Id删除 + * id多个用逗号分隔开 + */ + @DeleteMapping("delete/{id}") + @ApiOperation("/根据Ids删除") + public BasicResultVO deleteByIds(@PathVariable("id") String id) { + if (StrUtil.isNotBlank(id)) { + List idList = Arrays.stream(id.split(StrUtil.COMMA)).map(s -> Long.valueOf(s)).collect(Collectors.toList()); + channelAccountService.deleteByIds(idList); + return BasicResultVO.success(); + } + return BasicResultVO.fail(); + } + } diff --git a/austin-web/src/main/java/com/java3y/austin/web/service/ChannelAccountService.java b/austin-web/src/main/java/com/java3y/austin/web/service/ChannelAccountService.java index 616e729..7e9300a 100644 --- a/austin-web/src/main/java/com/java3y/austin/web/service/ChannelAccountService.java +++ b/austin-web/src/main/java/com/java3y/austin/web/service/ChannelAccountService.java @@ -1,9 +1,7 @@ package com.java3y.austin.web.service; -import com.java3y.austin.common.vo.BasicResultVO; import com.java3y.austin.support.domain.ChannelAccount; -import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -31,4 +29,19 @@ public interface ChannelAccountService { */ List queryByChannelType(Integer channelType); + + /** + * 列表信息 无条件 + * + * @return + */ + List list(); + + /** + * 软删除(deleted=1) + * + * @param ids + */ + void deleteByIds(List ids); + } diff --git a/austin-web/src/main/java/com/java3y/austin/web/service/impl/ChannelAccountServiceImpl.java b/austin-web/src/main/java/com/java3y/austin/web/service/impl/ChannelAccountServiceImpl.java index 20f5d90..94b01e7 100644 --- a/austin-web/src/main/java/com/java3y/austin/web/service/impl/ChannelAccountServiceImpl.java +++ b/austin-web/src/main/java/com/java3y/austin/web/service/impl/ChannelAccountServiceImpl.java @@ -32,4 +32,14 @@ public class ChannelAccountServiceImpl implements ChannelAccountService { public List queryByChannelType(Integer channelType) { return channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(AustinConstant.FALSE, channelType); } + + @Override + public List list() { + return channelAccountDao.findAll(); + } + + @Override + public void deleteByIds(List ids) { + channelAccountDao.deleteAllById(ids); + } }