Merge branch 'feature' of https://gitee.com/liuyingfang/cashier-admin into feature
# Conflicts: # eladmin-common/src/main/java/cn/ysk/cashier/config/RedisConfig.java # eladmin-system/src/main/java/cn/ysk/cashier/controller/order/TbOrderInfoController.java # eladmin-system/src/main/java/cn/ysk/cashier/dto/order/TbOrderInfoDto.java
This commit is contained in:
@@ -21,7 +21,6 @@ import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
||||
@@ -37,8 +36,6 @@ import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.listener.PatternTopic;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import reactor.util.annotation.Nullable;
|
||||
@@ -60,9 +57,6 @@ import java.util.Map;
|
||||
@EnableConfigurationProperties(RedisProperties.class)
|
||||
public class RedisConfig extends CachingConfigurerSupport {
|
||||
|
||||
@Autowired
|
||||
private RedisKeyExpirationListener redisKeyExpirationListener;
|
||||
|
||||
/**
|
||||
* 设置 redis 数据默认过期时间,默认2小时
|
||||
* 设置@cacheable 序列化方式
|
||||
@@ -89,10 +83,16 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
// fastjson 升级到 1.2.83 后需要指定序列化白名单
|
||||
ParserConfig.getGlobalInstance().addAccept("cn.ysk.cashier.pojo");
|
||||
ParserConfig.getGlobalInstance().addAccept("cn.ysk.cashier.service");
|
||||
// 模块内的实体类
|
||||
// ParserConfig.getGlobalInstance().addAccept("cn.ysk.cashier.mnt.domain");
|
||||
// ParserConfig.getGlobalInstance().addAccept("cn.ysk.cashier.quartz.domain");
|
||||
// ParserConfig.getGlobalInstance().addAccept("cn.ysk.cashier.system.domain");
|
||||
// 模块内的 Dto
|
||||
ParserConfig.getGlobalInstance().addAccept("cn.ysk.cashier.mnt");
|
||||
ParserConfig.getGlobalInstance().addAccept("cn.ysk.cashier.system");
|
||||
ParserConfig.getGlobalInstance().addAccept("cn.ysk.cashier.quartz");
|
||||
ParserConfig.getGlobalInstance().addAccept("cn.ysk.cashier.config");
|
||||
// ParserConfig.getGlobalInstance().addAccept("cn.ysk.cashier.system.service.dto");
|
||||
// key的序列化采用StringRedisSerializer
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setHashKeySerializer(new StringRedisSerializer());
|
||||
@@ -100,17 +100,6 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
return template;
|
||||
}
|
||||
|
||||
//redis key失效监听
|
||||
@Bean
|
||||
public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory connectionFactory) {
|
||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
container.setConnectionFactory(connectionFactory);
|
||||
System.out.println(111);
|
||||
// 监听特定键的过期事件
|
||||
container.addMessageListener(redisKeyExpirationListener, new PatternTopic("__keyevent@0__:expired"));
|
||||
return container;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义缓存key生成策略,默认将使用该策略
|
||||
*/
|
||||
|
||||
@@ -25,34 +25,39 @@ public interface CacheKey {
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
String USER_ID = "user::id:";
|
||||
String USER_ID = "user:id:";
|
||||
|
||||
/**
|
||||
* 激活码
|
||||
*/
|
||||
String ACT_CODE = "act_code:";
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
String DATA_USER = "data::user:";
|
||||
String DATA_USER = "data:user:";
|
||||
/**
|
||||
* 菜单
|
||||
*/
|
||||
String MENU_ID = "menu::id:";
|
||||
String MENU_USER = "menu::user:";
|
||||
String MENU_ID = "menu:id:";
|
||||
String MENU_USER = "menu:user:";
|
||||
/**
|
||||
* 角色授权
|
||||
*/
|
||||
String ROLE_AUTH = "role::auth:";
|
||||
String ROLE_AUTH = "role:auth:";
|
||||
/**
|
||||
* 角色信息
|
||||
*/
|
||||
String ROLE_ID = "role::id:";
|
||||
String ROLE_ID = "role:id:";
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
String DEPT_ID = "dept::id:";
|
||||
String DEPT_ID = "dept:id:";
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
String JOB_ID = "job::id:";
|
||||
String JOB_ID = "job:id:";
|
||||
/**
|
||||
* 数据字典
|
||||
*/
|
||||
String DICT_NAME = "dict::name:";
|
||||
String DICT_NAME = "dict:name:";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package cn.ysk.cashier.config;
|
||||
|
||||
import cn.ysk.cashier.service.shop.TbShopInfoService;
|
||||
import cn.ysk.cashier.system.service.UserService;
|
||||
import cn.ysk.cashier.utils.CacheKey;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.connection.MessageListener;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.listener.PatternTopic;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class RedisKeyExpirationListener implements MessageListener {
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private TbShopInfoService shopInfoService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private UserService userServiceu;
|
||||
|
||||
//redis key失效监听
|
||||
@Bean
|
||||
public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory connectionFactory) {
|
||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
container.setConnectionFactory(connectionFactory);
|
||||
// 监听特定键的过期事件
|
||||
container.addMessageListener(this, new PatternTopic("__keyevent@0__:expired"));
|
||||
return container;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
String expiredKey = new String(message.getBody());
|
||||
|
||||
// 检查过期的键是否以特定前缀开头
|
||||
if(expiredKey.startsWith(CacheKey.ACT_CODE)) {
|
||||
String account = expiredKey.substring("act_code:".length());
|
||||
log.info("商户到期 账户名为:{}",account);
|
||||
shopInfoService.update(account);
|
||||
userServiceu.upEnableByusername(account);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,30 +50,30 @@ public class TbCashierCartController {
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询/cashierCart")
|
||||
@ApiOperation("查询/cashierCart")
|
||||
@Log("查询购物车")
|
||||
@ApiOperation("查询购物车")
|
||||
public ResponseEntity<Object> queryTbCashierCart(TbCashierCartQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbCashierCartService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增/cashierCart")
|
||||
@ApiOperation("新增/cashierCart")
|
||||
@Log("新增购物车")
|
||||
@ApiOperation("新增购物车")
|
||||
public ResponseEntity<Object> createTbCashierCart(@Validated @RequestBody TbCashierCart resources){
|
||||
return new ResponseEntity<>(tbCashierCartService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改/cashierCart")
|
||||
@ApiOperation("修改/cashierCart")
|
||||
@Log("修改购物车")
|
||||
@ApiOperation("修改购物车")
|
||||
public ResponseEntity<Object> updateTbCashierCart(@Validated @RequestBody TbCashierCart resources){
|
||||
tbCashierCartService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除/cashierCart")
|
||||
@ApiOperation("删除/cashierCart")
|
||||
@Log("删除购物车")
|
||||
@ApiOperation("删除购物车")
|
||||
public ResponseEntity<Object> deleteTbCashierCart(@RequestBody Integer[] ids) {
|
||||
tbCashierCartService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
@@ -36,7 +36,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "/orderDetail管理")
|
||||
@Api(tags = "订单详情")
|
||||
@RequestMapping("/api/tbOrderDetail")
|
||||
public class TbOrderDetailController {
|
||||
|
||||
@@ -50,30 +50,30 @@ public class TbOrderDetailController {
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询/orderDetail")
|
||||
@ApiOperation("查询/orderDetail")
|
||||
@Log("查询订单详情")
|
||||
@ApiOperation("查询订单详情")
|
||||
public ResponseEntity<Object> queryTbOrderDetail(TbOrderDetailQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbOrderDetailService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增/orderDetail")
|
||||
@ApiOperation("新增/orderDetail")
|
||||
@Log("新增订单详情")
|
||||
@ApiOperation("新增订单详情")
|
||||
public ResponseEntity<Object> createTbOrderDetail(@Validated @RequestBody TbOrderDetail resources){
|
||||
return new ResponseEntity<>(tbOrderDetailService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改/orderDetail")
|
||||
@ApiOperation("修改/orderDetail")
|
||||
@Log("修改订单详情")
|
||||
@ApiOperation("修改订单详情")
|
||||
public ResponseEntity<Object> updateTbOrderDetail(@Validated @RequestBody TbOrderDetail resources){
|
||||
tbOrderDetailService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除/orderDetail")
|
||||
@ApiOperation("删除/orderDetail")
|
||||
@Log("删除订单详情")
|
||||
@ApiOperation("删除订单详情")
|
||||
public ResponseEntity<Object> deleteTbOrderDetail(@RequestBody Integer[] ids) {
|
||||
tbOrderDetailService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package cn.ysk.cashier.controller.order;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoDto;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.service.order.TbOrderInfoService;
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria;
|
||||
@@ -59,7 +60,7 @@ public class TbOrderInfoController {
|
||||
@GetMapping("/{id}")
|
||||
@Log("通过Id查询订单")
|
||||
@ApiOperation("通过Id查询订单")
|
||||
public Object queryTbOrderInfo(@PathVariable("id") Integer id){
|
||||
public TbOrderInfoDto queryTbOrderInfo(@PathVariable("id") Integer id){
|
||||
return tbOrderInfoService.findById(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package cn.ysk.cashier.dto.order;
|
||||
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -34,6 +35,7 @@ public class TbOrderInfoDto implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
/** 订单编号 */
|
||||
@ApiModelProperty(value = "订单编号")
|
||||
private String orderNo;
|
||||
|
||||
/** 商户结算金额 */
|
||||
|
||||
@@ -43,7 +43,7 @@ public class TbOrderDetail implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`order_id`")
|
||||
@ApiModelProperty(value = "orderId")
|
||||
@ApiModelProperty(value = "订单id")
|
||||
private Integer orderId;
|
||||
|
||||
@Column(name = "`shop_id`")
|
||||
|
||||
@@ -18,10 +18,6 @@ package cn.ysk.cashier.repository.order;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
|
||||
@@ -1,35 +1,39 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.repository.shop;
|
||||
|
||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2023-11-07
|
||||
**/
|
||||
* @author lyf
|
||||
* @website https://eladmin.vip
|
||||
* @date 2023-11-07
|
||||
**/
|
||||
public interface TbShopInfoRepository extends JpaRepository<TbShopInfo, Integer>, JpaSpecificationExecutor<TbShopInfo> {
|
||||
|
||||
@Query("select info from TbShopInfo info where info.account = :account")
|
||||
TbShopInfo findByAccount(@Param("account") String account);
|
||||
|
||||
@Modifying
|
||||
@Query("update TbShopInfo info set info.status=0 where info.account = :account")
|
||||
void updateByAcc(@Param("account") String account);
|
||||
|
||||
}
|
||||
@@ -209,6 +209,12 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
||||
tbShopInfoRepository.save(tbShopInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(String account) {
|
||||
tbShopInfoRepository.updateByAcc(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
|
||||
@@ -69,6 +69,8 @@ public interface TbShopInfoService {
|
||||
*/
|
||||
void update(TbShopInfo resources);
|
||||
|
||||
void update(String account);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
|
||||
@@ -61,6 +61,10 @@ public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificat
|
||||
@Query(value = "update sys_user set password = ?2 , pwd_reset_time = ?3 where username = ?1",nativeQuery = true)
|
||||
void updatePass(String username, String pass, Date lastPasswordResetTime);
|
||||
|
||||
@Modifying
|
||||
@Query(value = "update sys_user set enabled = 0 where username = ?1",nativeQuery = true)
|
||||
void upEnableByusername(String username);
|
||||
|
||||
/**
|
||||
* 修改邮箱
|
||||
* @param username 用户名
|
||||
|
||||
@@ -80,6 +80,8 @@ public interface UserService {
|
||||
*/
|
||||
void updatePass(String username, String encryptPassword);
|
||||
|
||||
void upEnableByusername(String username);
|
||||
|
||||
/**
|
||||
* 修改头像
|
||||
* @param file 文件
|
||||
|
||||
@@ -192,6 +192,13 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void upEnableByusername(String username) {
|
||||
userRepository.upEnableByusername(username);
|
||||
flushCache(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updatePass(String username, String pass) {
|
||||
|
||||
Reference in New Issue
Block a user