微信菜单修改
This commit is contained in:
64
shell/jar-run2.sh
Normal file
64
shell/jar-run2.sh
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#cription: 启动重启server服务
|
||||||
|
#端口号,根据此端口号确定PID
|
||||||
|
PORT=767
|
||||||
|
#启动命令所在目录
|
||||||
|
HOME='/home/sszn/task-agc'
|
||||||
|
|
||||||
|
#查询出监听了test.jar端口TCP协议的程序
|
||||||
|
pid=$(ps -ef | grep gdw-agc-task-1.0.0.0.jar | grep -v grep | awk '{print $2}')
|
||||||
|
|
||||||
|
start(){
|
||||||
|
echo "start running cloud-core ............... "
|
||||||
|
if [ -n "$pid" ]; then
|
||||||
|
echo "server already start,pid:$pid"
|
||||||
|
echo "pid:$pid agc-job port:$PORT 服务已经在运行了,请停止后再 执行 sh run.sh start "
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
#进入命令所在目录
|
||||||
|
cd $HOME
|
||||||
|
# 启动服务控制台日志输出到nohup.out文件中
|
||||||
|
nohup java -jar gdw-agc-task-1.0.0.0.jar >> /home/sszn/task-agc/log/agc-$(date +%Y-%m-%d).log 2>&1 &
|
||||||
|
echo "running success agc-job port:$PORT"
|
||||||
|
echo "agc-job port:$PORT 服务启动成功 ..... "
|
||||||
|
}
|
||||||
|
|
||||||
|
stop(){
|
||||||
|
echo "stopping running cloud-core ............... "
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
echo "not find program on port:$PORT"
|
||||||
|
echo "agc-job port:$PORT 服务已经被关闭了请执行 sh run.sh start "
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
#结束程序,使用讯号2,如果不行可以尝试讯号9强制结束
|
||||||
|
kill -9 $pid
|
||||||
|
rm -rf $pid
|
||||||
|
echo "kill program use signal 2,pid:$pid"
|
||||||
|
}
|
||||||
|
|
||||||
|
status(){
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
echo "not find program on port:$PORT"
|
||||||
|
else
|
||||||
|
echo "program is running,pid:$pid"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
$0 stop
|
||||||
|
sleep 2
|
||||||
|
$0 start
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
status
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $"Usage: $0 {start|stop|status}"
|
||||||
|
exit 0
|
||||||
|
esac
|
@ -1256,10 +1256,10 @@ INSERT INTO `yx_article` VALUES (5, '', '444', '4444', 'http://localhost:8000/fi
|
|||||||
INSERT INTO `yx_article` VALUES (6, '', '555', '555', 'http://localhost:8000/file/pic/秒杀-2020031104371672.png', '555', '<p>555</p>', '', '', '5', NULL, '', NULL, '2020-03-13 14:55', NULL, NULL, NULL, NULL, NULL, NULL);
|
INSERT INTO `yx_article` VALUES (6, '', '555', '555', 'http://localhost:8000/file/pic/秒杀-2020031104371672.png', '555', '<p>555</p>', '', '', '5', NULL, '', NULL, '2020-03-13 14:55', NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for yx_cache
|
-- Table structure for yx_wechat_menu
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
DROP TABLE IF EXISTS `yx_cache`;
|
DROP TABLE IF EXISTS `yx_wechat_menu`;
|
||||||
CREATE TABLE `yx_cache` (
|
CREATE TABLE `yx_wechat_menu` (
|
||||||
`key` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
`key` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||||
`result` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '缓存数据',
|
`result` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '缓存数据',
|
||||||
`add_time` int(10) NULL DEFAULT NULL COMMENT '缓存时间',
|
`add_time` int(10) NULL DEFAULT NULL COMMENT '缓存时间',
|
||||||
@ -1267,9 +1267,9 @@ CREATE TABLE `yx_cache` (
|
|||||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '微信缓存表' ROW_FORMAT = Dynamic;
|
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '微信缓存表' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of yx_cache
|
-- Records of yx_wechat_menu
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `yx_cache` VALUES ('wechat_menus', '[{\"subButtons\":[{\"name\":\"公众号演示\",\"type\":\"view\",\"url\":\"https://h5.dayouqiantu.cn\"}],\"name\":\"Yshop商城3\",\"type\":\"click\",\"key\":\"yshop\"},{\"subButtons\":[{\"appId\":\"wxa82b5b7fcb0ec161\",\"name\":\"小程序演示\",\"pagePath\":\"pages/index\",\"type\":\"miniprogram\",\"url\":\"pages/index\"}],\"name\":\"供货商城\",\"type\":\"click\",\"key\":\"supply\"},{\"subButtons\":[],\"name\":\"3333\",\"type\":\"click\",\"key\":\"2222\"}]', 1570435277);
|
INSERT INTO `yx_wechat_menu` VALUES ('wechat_menus', '[{\"subButtons\":[{\"name\":\"公众号演示\",\"type\":\"view\",\"url\":\"https://h5.dayouqiantu.cn\"}],\"name\":\"Yshop商城3\",\"type\":\"click\",\"key\":\"yshop\"},{\"subButtons\":[{\"appId\":\"wxa82b5b7fcb0ec161\",\"name\":\"小程序演示\",\"pagePath\":\"pages/index\",\"type\":\"miniprogram\",\"url\":\"pages/index\"}],\"name\":\"供货商城\",\"type\":\"click\",\"key\":\"supply\"},{\"subButtons\":[],\"name\":\"3333\",\"type\":\"click\",\"key\":\"2222\"}]', 1570435277);
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for yx_express
|
-- Table structure for yx_express
|
||||||
|
@ -4,8 +4,8 @@ package co.yixiang.mp.controller;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import co.yixiang.exception.BadRequestException;
|
import co.yixiang.exception.BadRequestException;
|
||||||
import co.yixiang.mp.config.WxMpConfiguration;
|
import co.yixiang.mp.config.WxMpConfiguration;
|
||||||
import co.yixiang.mp.domain.YxCache;
|
import co.yixiang.mp.domain.YxWechatMenu;
|
||||||
import co.yixiang.mp.service.YxCacheService;
|
import co.yixiang.mp.service.YxWechatMenuService;
|
||||||
import co.yixiang.utils.OrderUtil;
|
import co.yixiang.utils.OrderUtil;
|
||||||
import co.yixiang.utils.RedisUtil;
|
import co.yixiang.utils.RedisUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
@ -31,41 +31,41 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class WechatMenuController {
|
public class WechatMenuController {
|
||||||
|
|
||||||
private final YxCacheService yxCacheService;
|
private final YxWechatMenuService YxWechatMenuService;
|
||||||
|
|
||||||
public WechatMenuController(YxCacheService yxCacheService) {
|
public WechatMenuController(YxWechatMenuService YxWechatMenuService) {
|
||||||
this.yxCacheService = yxCacheService;
|
this.YxWechatMenuService = YxWechatMenuService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "查询菜单")
|
@ApiOperation(value = "查询菜单")
|
||||||
@GetMapping(value = "/yxCache")
|
@GetMapping(value = "/YxWechatMenu")
|
||||||
@PreAuthorize("@el.check('admin','YXCACHE_ALL','YXCACHE_SELECT')")
|
@PreAuthorize("@el.check('admin','YxWechatMenu_ALL','YxWechatMenu_SELECT')")
|
||||||
public ResponseEntity getYxCaches(){
|
public ResponseEntity getYxWechatMenus(){
|
||||||
return new ResponseEntity(yxCacheService.findById("wechat_menus"),HttpStatus.OK);
|
return new ResponseEntity(YxWechatMenuService.findById("wechat_menus"),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "创建菜单")
|
@ApiOperation(value = "创建菜单")
|
||||||
@PostMapping(value = "/yxCache")
|
@PostMapping(value = "/YxWechatMenu")
|
||||||
@PreAuthorize("@el.check('admin','YXCACHE_ALL','YXCACHE_CREATE')")
|
@PreAuthorize("@el.check('admin','YxWechatMenu_ALL','YxWechatMenu_CREATE')")
|
||||||
public ResponseEntity create( @RequestBody String jsonStr){
|
public ResponseEntity create( @RequestBody String jsonStr){
|
||||||
//if(StrUtil.isNotEmpty("22")) throw new BadRequestException("演示环境禁止操作");
|
//if(StrUtil.isNotEmpty("22")) throw new BadRequestException("演示环境禁止操作");
|
||||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||||
String jsonButton = jsonObject.get("buttons").toString();
|
String jsonButton = jsonObject.get("buttons").toString();
|
||||||
YxCache yxCache = new YxCache();
|
YxWechatMenu YxWechatMenu = new YxWechatMenu();
|
||||||
Boolean isExist = yxCacheService.isExist("wechat_menus");
|
Boolean isExist = YxWechatMenuService.isExist("wechat_menus");
|
||||||
WxMenu menu = JSONObject.parseObject(jsonStr,WxMenu.class);
|
WxMenu menu = JSONObject.parseObject(jsonStr,WxMenu.class);
|
||||||
|
|
||||||
WxMpService wxService = WxMpConfiguration.getWxMpService();
|
WxMpService wxService = WxMpConfiguration.getWxMpService();
|
||||||
if(isExist){
|
if(isExist){
|
||||||
yxCache.setKey("wechat_menus");
|
YxWechatMenu.setKey("wechat_menus");
|
||||||
yxCache.setResult(jsonButton);
|
YxWechatMenu.setResult(jsonButton);
|
||||||
yxCacheService.update(yxCache);
|
YxWechatMenuService.update(YxWechatMenu);
|
||||||
}else {
|
}else {
|
||||||
yxCache.setKey("wechat_menus");
|
YxWechatMenu.setKey("wechat_menus");
|
||||||
yxCache.setResult(jsonButton);
|
YxWechatMenu.setResult(jsonButton);
|
||||||
yxCache.setAddTime(OrderUtil.getSecondTimestampTwo());
|
YxWechatMenu.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||||
yxCacheService.create(yxCache);
|
YxWechatMenuService.create(YxWechatMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ import java.io.Serializable;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Data
|
@Data
|
||||||
@Table(name="yx_cache")
|
@Table(name="yx_wechat_menu")
|
||||||
public class YxCache implements Serializable {
|
public class YxWechatMenu implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ -32,7 +32,7 @@ public class YxCache implements Serializable {
|
|||||||
@Column(name = "add_time")
|
@Column(name = "add_time")
|
||||||
private Integer addTime;
|
private Integer addTime;
|
||||||
|
|
||||||
public void copy(YxCache source){
|
public void copy(YxWechatMenu source){
|
||||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package co.yixiang.mp.repository;
|
package co.yixiang.mp.repository;
|
||||||
|
|
||||||
|
|
||||||
import co.yixiang.mp.domain.YxCache;
|
import co.yixiang.mp.domain.YxWechatMenu;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
@ -9,5 +9,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||||||
* @author hupeng
|
* @author hupeng
|
||||||
* @date 2019-10-06
|
* @date 2019-10-06
|
||||||
*/
|
*/
|
||||||
public interface YxCacheRepository extends JpaRepository<YxCache, String>, JpaSpecificationExecutor {
|
public interface YxWechatMenuRepository extends JpaRepository<YxWechatMenu, String>, JpaSpecificationExecutor {
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
package co.yixiang.mp.service;
|
package co.yixiang.mp.service;
|
||||||
|
|
||||||
|
|
||||||
import co.yixiang.mp.domain.YxCache;
|
import co.yixiang.mp.domain.YxWechatMenu;
|
||||||
import co.yixiang.mp.service.dto.YxCacheDTO;
|
import co.yixiang.mp.service.dto.YxWechatMenuDTO;
|
||||||
import co.yixiang.mp.service.dto.YxCacheQueryCriteria;
|
import co.yixiang.mp.service.dto.YxWechatMenuQueryCriteria;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -13,8 +13,8 @@ import java.util.Map;
|
|||||||
* @author hupeng
|
* @author hupeng
|
||||||
* @date 2019-10-06
|
* @date 2019-10-06
|
||||||
*/
|
*/
|
||||||
//@CacheConfig(cacheNames = "yxCache")
|
//@CacheConfig(cacheNames = "YxWechatMenu")
|
||||||
public interface YxCacheService {
|
public interface YxWechatMenuService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据分页
|
* 查询数据分页
|
||||||
@ -23,7 +23,7 @@ public interface YxCacheService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
//@Cacheable
|
//@Cacheable
|
||||||
Map<String,Object> queryAll(YxCacheQueryCriteria criteria, Pageable pageable);
|
Map<String,Object> queryAll(YxWechatMenuQueryCriteria criteria, Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有数据不分页
|
* 查询所有数据不分页
|
||||||
@ -31,7 +31,7 @@ public interface YxCacheService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
//@Cacheable
|
//@Cacheable
|
||||||
List<YxCacheDTO> queryAll(YxCacheQueryCriteria criteria);
|
List<YxWechatMenuDTO> queryAll(YxWechatMenuQueryCriteria criteria);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID查询
|
* 根据ID查询
|
||||||
@ -39,7 +39,7 @@ public interface YxCacheService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
//@Cacheable(key = "#p0")
|
//@Cacheable(key = "#p0")
|
||||||
YxCacheDTO findById(String key);
|
YxWechatMenuDTO findById(String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建
|
* 创建
|
||||||
@ -47,14 +47,14 @@ public interface YxCacheService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
//@CacheEvict(allEntries = true)
|
//@CacheEvict(allEntries = true)
|
||||||
YxCacheDTO create(YxCache resources);
|
YxWechatMenuDTO create(YxWechatMenu resources);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
* @param resources
|
* @param resources
|
||||||
*/
|
*/
|
||||||
//@CacheEvict(allEntries = true)
|
//@CacheEvict(allEntries = true)
|
||||||
void update(YxCache resources);
|
void update(YxWechatMenu resources);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
@ -10,7 +10,7 @@ import java.io.Serializable;
|
|||||||
* @date 2019-10-06
|
* @date 2019-10-06
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class YxCacheDTO implements Serializable {
|
public class YxWechatMenuDTO implements Serializable {
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
|
|
@ -7,5 +7,5 @@ import lombok.Data;
|
|||||||
* @date 2019-10-06
|
* @date 2019-10-06
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class YxCacheQueryCriteria{
|
public class YxWechatMenuQueryCriteria{
|
||||||
}
|
}
|
@ -1,89 +0,0 @@
|
|||||||
package co.yixiang.mp.service.impl;
|
|
||||||
|
|
||||||
|
|
||||||
import co.yixiang.mp.domain.YxCache;
|
|
||||||
import co.yixiang.mp.repository.YxCacheRepository;
|
|
||||||
import co.yixiang.mp.service.YxCacheService;
|
|
||||||
import co.yixiang.mp.service.dto.YxCacheDTO;
|
|
||||||
import co.yixiang.mp.service.dto.YxCacheQueryCriteria;
|
|
||||||
import co.yixiang.mp.service.mapper.YxCacheMapper;
|
|
||||||
import co.yixiang.utils.PageUtil;
|
|
||||||
import co.yixiang.utils.QueryHelp;
|
|
||||||
import co.yixiang.utils.ValidationUtil;
|
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author hupeng
|
|
||||||
* @date 2019-10-06
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
|
||||||
public class YxCacheServiceImpl implements YxCacheService {
|
|
||||||
|
|
||||||
private final YxCacheRepository yxCacheRepository;
|
|
||||||
|
|
||||||
private final YxCacheMapper yxCacheMapper;
|
|
||||||
|
|
||||||
public YxCacheServiceImpl(YxCacheRepository yxCacheRepository, YxCacheMapper yxCacheMapper) {
|
|
||||||
this.yxCacheRepository = yxCacheRepository;
|
|
||||||
this.yxCacheMapper = yxCacheMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String,Object> queryAll(YxCacheQueryCriteria criteria, Pageable pageable){
|
|
||||||
Page<YxCache> page = yxCacheRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
|
||||||
return PageUtil.toPage(page.map(yxCacheMapper::toDto));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<YxCacheDTO> queryAll(YxCacheQueryCriteria criteria){
|
|
||||||
return yxCacheMapper.toDto(yxCacheRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public YxCacheDTO findById(String key) {
|
|
||||||
Optional<YxCache> yxCache = yxCacheRepository.findById(key);
|
|
||||||
ValidationUtil.isNull(yxCache,"YxCache","key",key);
|
|
||||||
return yxCacheMapper.toDto(yxCache.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isExist(String key) {
|
|
||||||
Optional<YxCache> yxCache = yxCacheRepository.findById(key);
|
|
||||||
if(!yxCache.isPresent()){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public YxCacheDTO create(YxCache resources) {
|
|
||||||
//resources.setKey(IdUtil.simpleUUID());
|
|
||||||
return yxCacheMapper.toDto(yxCacheRepository.save(resources));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void update(YxCache resources) {
|
|
||||||
Optional<YxCache> optionalYxCache = yxCacheRepository.findById(resources.getKey());
|
|
||||||
ValidationUtil.isNull( optionalYxCache,"YxCache","id",resources.getKey());
|
|
||||||
YxCache yxCache = optionalYxCache.get();
|
|
||||||
yxCache.copy(resources);
|
|
||||||
yxCacheRepository.save(yxCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void delete(String key) {
|
|
||||||
yxCacheRepository.deleteById(key);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,89 @@
|
|||||||
|
package co.yixiang.mp.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import co.yixiang.mp.domain.YxWechatMenu;
|
||||||
|
import co.yixiang.mp.repository.YxWechatMenuRepository;
|
||||||
|
import co.yixiang.mp.service.YxWechatMenuService;
|
||||||
|
import co.yixiang.mp.service.dto.YxWechatMenuDTO;
|
||||||
|
import co.yixiang.mp.service.dto.YxWechatMenuQueryCriteria;
|
||||||
|
import co.yixiang.mp.service.mapper.YxWechatMenuMapper;
|
||||||
|
import co.yixiang.utils.PageUtil;
|
||||||
|
import co.yixiang.utils.QueryHelp;
|
||||||
|
import co.yixiang.utils.ValidationUtil;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hupeng
|
||||||
|
* @date 2019-10-06
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||||
|
public class YxWechatMenuServiceImpl implements YxWechatMenuService {
|
||||||
|
|
||||||
|
private final YxWechatMenuRepository YxWechatMenuRepository;
|
||||||
|
|
||||||
|
private final YxWechatMenuMapper YxWechatMenuMapper;
|
||||||
|
|
||||||
|
public YxWechatMenuServiceImpl(YxWechatMenuRepository YxWechatMenuRepository, YxWechatMenuMapper YxWechatMenuMapper) {
|
||||||
|
this.YxWechatMenuRepository = YxWechatMenuRepository;
|
||||||
|
this.YxWechatMenuMapper = YxWechatMenuMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String,Object> queryAll(YxWechatMenuQueryCriteria criteria, Pageable pageable){
|
||||||
|
Page<YxWechatMenu> page = YxWechatMenuRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||||
|
return PageUtil.toPage(page.map(YxWechatMenuMapper::toDto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<YxWechatMenuDTO> queryAll(YxWechatMenuQueryCriteria criteria){
|
||||||
|
return YxWechatMenuMapper.toDto(YxWechatMenuRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public YxWechatMenuDTO findById(String key) {
|
||||||
|
Optional<YxWechatMenu> YxWechatMenu = YxWechatMenuRepository.findById(key);
|
||||||
|
ValidationUtil.isNull(YxWechatMenu,"YxWechatMenu","key",key);
|
||||||
|
return YxWechatMenuMapper.toDto(YxWechatMenu.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isExist(String key) {
|
||||||
|
Optional<YxWechatMenu> YxWechatMenu = YxWechatMenuRepository.findById(key);
|
||||||
|
if(!YxWechatMenu.isPresent()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public YxWechatMenuDTO create(YxWechatMenu resources) {
|
||||||
|
//resources.setKey(IdUtil.simpleUUID());
|
||||||
|
return YxWechatMenuMapper.toDto(YxWechatMenuRepository.save(resources));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void update(YxWechatMenu resources) {
|
||||||
|
Optional<YxWechatMenu> optionalYxWechatMenu = YxWechatMenuRepository.findById(resources.getKey());
|
||||||
|
ValidationUtil.isNull( optionalYxWechatMenu,"YxWechatMenu","id",resources.getKey());
|
||||||
|
YxWechatMenu YxWechatMenu = optionalYxWechatMenu.get();
|
||||||
|
YxWechatMenu.copy(resources);
|
||||||
|
YxWechatMenuRepository.save(YxWechatMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void delete(String key) {
|
||||||
|
YxWechatMenuRepository.deleteById(key);
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package co.yixiang.mp.service.mapper;
|
package co.yixiang.mp.service.mapper;
|
||||||
|
|
||||||
import co.yixiang.mapper.EntityMapper;
|
import co.yixiang.mapper.EntityMapper;
|
||||||
import co.yixiang.mp.domain.YxCache;
|
import co.yixiang.mp.domain.YxWechatMenu;
|
||||||
import co.yixiang.mp.service.dto.YxCacheDTO;
|
import co.yixiang.mp.service.dto.YxWechatMenuDTO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.ReportingPolicy;
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
|
||||||
@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
|
|||||||
* @date 2019-10-06
|
* @date 2019-10-06
|
||||||
*/
|
*/
|
||||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||||
public interface YxCacheMapper extends EntityMapper<YxCacheDTO, YxCache> {
|
public interface YxWechatMenuMapper extends EntityMapper<YxWechatMenuDTO, YxWechatMenu> {
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user