提交新功能 分销商 积分 会员体系
This commit is contained in:
@ -92,4 +92,18 @@ public class DictDataController {
|
||||
ExcelUtils.write(response, "字典数据.xls", "数据列表", DictDataExcelVO.class, data);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get-distributor-config")
|
||||
@Operation(summary = "/查询分销商配置")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
||||
public CommonResult<List<DictDataRespVO>> getDistributorConfig() {
|
||||
return success(dictDataService.getDistributorConfig());
|
||||
}
|
||||
|
||||
@PostMapping("/update-distributor-config")
|
||||
@Operation(summary = "更新分销商配置")
|
||||
public CommonResult<Boolean> updateDistributorConfig(@Valid @RequestBody List<DictDataUpdateReqVO> reqVO) {
|
||||
dictDataService.updateDistributorConfig(reqVO);
|
||||
return success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class NoticeController {
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获取通知公告列表")
|
||||
@PreAuthorize("@ss.hasPermission('system:notice:query')")
|
||||
// @PreAuthorize("@ss.hasPermission('system:notice:query')")
|
||||
public CommonResult<PageResult<NoticeRespVO>> getNoticePage(@Validated NoticePageReqVO reqVO) {
|
||||
return success(NoticeConvert.INSTANCE.convertPage(noticeService.getNoticePage(reqVO)));
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package co.yixiang.yshop.module.system.controller.app.dict;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.CommonResult;
|
||||
import co.yixiang.yshop.framework.dict.core.util.DictFrameworkUtils;
|
||||
import co.yixiang.yshop.module.system.controller.admin.dict.vo.data.DictDataRespVO;
|
||||
import co.yixiang.yshop.module.system.enums.DistributorDictEnum;
|
||||
import co.yixiang.yshop.module.system.service.dict.DictDataService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.annotation.security.PermitAll;
|
||||
@ -17,6 +17,8 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;
|
||||
|
||||
|
||||
@Tag(name = "用户 APP - 数据字典")
|
||||
@RestController
|
||||
@ -28,7 +30,7 @@ public class AppDictDataController {
|
||||
private DictDataService dictDataService;
|
||||
|
||||
@GetMapping("/agreement/{type}")
|
||||
@Operation(summary = "获得协议", description = "包括用户协议和隐私协议")
|
||||
@Operation(summary = "获得协议", description = "包括用户协议和隐私协议 弃用")
|
||||
// 无需添加权限认证,因为前端全局都需要
|
||||
@PermitAll
|
||||
public void getAgreement(@PathVariable Integer type, HttpServletResponse response) throws IOException {
|
||||
@ -39,4 +41,25 @@ public class AppDictDataController {
|
||||
writer.flush();
|
||||
// return success(dictDataService.getAgreement(type));
|
||||
}
|
||||
|
||||
@GetMapping("/get-stream")
|
||||
@Operation(summary = "获取字典流", description = "包括用户协议和隐私协议")
|
||||
// 无需添加权限认证,因为前端全局都需要
|
||||
@PermitAll
|
||||
public void getStream(@RequestParam("dictType") String dictType, @RequestParam("label") String label, HttpServletResponse response) throws IOException {
|
||||
response.setHeader("Content-Type","text/html;charset=UTF-8");
|
||||
String value = DictFrameworkUtils.parseDictDataValue(dictType, label);
|
||||
PrintWriter writer = response.getWriter();
|
||||
writer.write(value);
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
@GetMapping("/get-value")
|
||||
@Operation(summary = "获取字典")
|
||||
// 无需添加权限认证,因为前端全局都需要
|
||||
@PermitAll
|
||||
public CommonResult<String> getValue(@RequestParam("dictType") String dictType, @RequestParam("label") String label, HttpServletResponse response) throws IOException {
|
||||
String value = DictFrameworkUtils.parseDictDataValue(dictType, label);
|
||||
return success(value);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import co.yixiang.yshop.module.system.controller.admin.dict.vo.data.DictDataPage
|
||||
import co.yixiang.yshop.module.system.dal.dataobject.dict.DictDataDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -48,4 +50,6 @@ public interface DictDataMapper extends BaseMapperX<DictDataDO> {
|
||||
.eqIfPresent(DictDataDO::getStatus, reqVO.getStatus()));
|
||||
}
|
||||
|
||||
@Update("update system_dict_data set value = #{value} where label = #{label}")
|
||||
void updateDictByLabel(@Param("label") String label,@Param("value") String value);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import co.yixiang.yshop.module.system.dal.mysql.backuprecord.BackupRecordMapper;
|
||||
import co.yixiang.yshop.module.system.service.user.AdminUserService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -26,7 +27,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static co.yixiang.yshop.module.system.enums.ErrorCodeConstants.BACKUP_MANY;
|
||||
import static co.yixiang.yshop.module.system.enums.ErrorCodeConstants.BACKUP_NO_BACKUP;
|
||||
|
||||
/**
|
||||
* 品牌 Service 实现类
|
||||
@ -34,6 +34,7 @@ import static co.yixiang.yshop.module.system.enums.ErrorCodeConstants.BACKUP_NO_
|
||||
* @author yshop
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Validated
|
||||
public class BackupRecordServiceImpl extends ServiceImpl<BackupRecordMapper, BackupRecordDO> implements BackupRecordService {
|
||||
|
||||
@ -79,7 +80,7 @@ public class BackupRecordServiceImpl extends ServiceImpl<BackupRecordMapper, Bac
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void backup() {
|
||||
BackupRecordDO last = backupRecordMapper.selectOne(new LambdaQueryWrapper<BackupRecordDO>().orderByDesc(
|
||||
@ -90,10 +91,17 @@ public class BackupRecordServiceImpl extends ServiceImpl<BackupRecordMapper, Bac
|
||||
throw exception(BACKUP_MANY);
|
||||
}
|
||||
}
|
||||
//druid空闲连接池关闭之后 第一次执行失败 第二次成功
|
||||
try {
|
||||
this.baseMapper.backup();
|
||||
} catch (Exception e) {
|
||||
log.info("第一次备份异常,重试中。。。");
|
||||
}
|
||||
this.baseMapper.backup();
|
||||
BackupRecordDO backupRecordDO = new BackupRecordDO();
|
||||
backupRecordDO.setCreateTime(LocalDateTime.now());
|
||||
this.baseMapper.insert(backupRecordDO);
|
||||
log.info("======备份成功=====");
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ -102,13 +110,19 @@ public class BackupRecordServiceImpl extends ServiceImpl<BackupRecordMapper, Bac
|
||||
BackupRecordDO backupRecordDO = backupRecordMapper.selectOne(new LambdaQueryWrapper<BackupRecordDO>().orderByDesc(
|
||||
BackupRecordDO::getId
|
||||
).last("limit 1"));
|
||||
|
||||
Long count = backupRecordMapper.selectCount();
|
||||
if (backupRecordDO == null) throw exception(BACKUP_NO_BACKUP);
|
||||
if (backupRecordDO.getUpdateTime().plusMinutes(5).isAfter(LocalDateTime.now()) && count > 1) {
|
||||
throw exception(BACKUP_MANY);
|
||||
if (backupRecordDO != null) {
|
||||
if (backupRecordDO.getUpdateTime().plusMinutes(5).isAfter(LocalDateTime.now()) &&
|
||||
!backupRecordDO.getCreateTime().isEqual(backupRecordDO.getUpdateTime())) {
|
||||
throw exception(BACKUP_MANY);
|
||||
}
|
||||
}
|
||||
try {
|
||||
this.baseMapper.revertBackup();
|
||||
} catch (Exception e) {
|
||||
log.info("第一次还原备份异常,重试中。。。");
|
||||
}
|
||||
this.baseMapper.revertBackup();
|
||||
assert backupRecordDO != null;
|
||||
backupRecordDO.setUpdateTime(LocalDateTime.now());
|
||||
this.baseMapper.updateById(backupRecordDO);
|
||||
//清除redis信息
|
||||
@ -118,5 +132,6 @@ public class BackupRecordServiceImpl extends ServiceImpl<BackupRecordMapper, Bac
|
||||
stringRedisTemplate.delete(orderCountKeys);
|
||||
assert orderAdminCountKeys != null;
|
||||
stringRedisTemplate.delete(orderAdminCountKeys);
|
||||
log.info("======还原备份成功=====");
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package co.yixiang.yshop.module.system.service.dict;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.module.system.controller.admin.dict.vo.data.*;
|
||||
import co.yixiang.yshop.module.system.controller.admin.dict.vo.type.DictTypeSimpleRespVO;
|
||||
import co.yixiang.yshop.module.system.dal.dataobject.dict.DictDataDO;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -117,4 +116,29 @@ public interface DictDataService {
|
||||
* @return
|
||||
*/
|
||||
DictDataRespVO getDefaultHead();
|
||||
|
||||
/**
|
||||
* 解析获得指定的字典数据,从缓存中
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param label 字典数据标签
|
||||
* @return 字典数据
|
||||
*/
|
||||
String getDictDataStr(String dictType, String label);
|
||||
|
||||
/**
|
||||
* 解析获得指定的字典数据,从缓存中
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param label 字典数据标签
|
||||
* @return 字典数据
|
||||
*/
|
||||
Integer getDictDataInt(String dictType, String label);
|
||||
|
||||
|
||||
List<DictDataRespVO> getDistributorConfig();
|
||||
|
||||
void updateDistributorConfig(List<DictDataUpdateReqVO> reqVO);
|
||||
|
||||
void updateDictByLabel(String label, String value);
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import co.yixiang.yshop.framework.common.enums.CommonStatusEnum;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.framework.common.util.collection.CollectionUtils;
|
||||
import co.yixiang.yshop.module.system.controller.admin.dict.vo.data.*;
|
||||
import co.yixiang.yshop.module.system.controller.admin.dict.vo.type.DictTypeSimpleRespVO;
|
||||
import co.yixiang.yshop.module.system.convert.dict.DictDataConvert;
|
||||
import co.yixiang.yshop.module.system.dal.dataobject.dict.DictDataDO;
|
||||
import co.yixiang.yshop.module.system.dal.dataobject.dict.DictTypeDO;
|
||||
import co.yixiang.yshop.module.system.dal.mysql.dict.DictDataMapper;
|
||||
import co.yixiang.yshop.module.system.enums.DistributorDictEnum;
|
||||
import co.yixiang.yshop.module.system.enums.agreement.AgreementTypeEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
@ -17,15 +17,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static co.yixiang.yshop.module.system.enums.DictTypeConstants.PRIVACY_AGREEMENT;
|
||||
import static co.yixiang.yshop.module.system.enums.DictTypeConstants.USER_AGREEMENT;
|
||||
import static co.yixiang.yshop.module.system.enums.DictTypeConstants.DEFAULT_HEAD;
|
||||
import static co.yixiang.yshop.module.system.enums.DictTypeConstants.*;
|
||||
import static co.yixiang.yshop.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
@ -203,4 +198,40 @@ public class DictDataServiceImpl implements DictDataService {
|
||||
DictDataDO dictDataDO = dictDataMapper.selectOne(qw.eq(DictDataDO::getLabel,DEFAULT_HEAD));
|
||||
return DictDataConvert.INSTANCE.convert(dictDataDO);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDictDataStr(String dictType, String label) {
|
||||
DictDataDO dictDataDO = dictDataMapper.selectByDictTypeAndLabel(dictType, label);
|
||||
return dictDataDO.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getDictDataInt(String dictType, String label) {
|
||||
DictDataDO dictDataDO = dictDataMapper.selectByDictTypeAndLabel(dictType, label);
|
||||
return Integer.valueOf(dictDataDO.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictDataRespVO> getDistributorConfig() {
|
||||
List<DictDataRespVO> dictDataRespVOS = new ArrayList<>();
|
||||
DistributorDictEnum[] enums = DistributorDictEnum.values();
|
||||
for (DistributorDictEnum dictEnum : enums) {
|
||||
DictDataDO dictDataDO = dictDataMapper.selectByDictTypeAndLabel(dictEnum.getDictType(), dictEnum.getLabel());
|
||||
DictDataRespVO dictDataRespVO = DictDataConvert.INSTANCE.convert(dictDataDO);
|
||||
dictDataRespVOS.add(dictDataRespVO);
|
||||
}
|
||||
return dictDataRespVOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDistributorConfig(List<DictDataUpdateReqVO> reqVO) {
|
||||
for (DictDataUpdateReqVO req : reqVO) {
|
||||
this.updateDictData(req);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDictByLabel(String label, String value) {
|
||||
dictDataMapper.updateDictByLabel(label,value);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,6 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
* 角色编号与菜单编号的缓存映射
|
||||
* key:角色编号
|
||||
* value:菜单编号的数组
|
||||
*
|
||||
* 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向
|
||||
*/
|
||||
@Getter
|
||||
@ -66,7 +65,6 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
* 菜单编号与角色编号的缓存映射
|
||||
* key:菜单编号
|
||||
* value:角色编号的数组
|
||||
*
|
||||
* 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向
|
||||
*/
|
||||
@Getter
|
||||
@ -77,7 +75,6 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
* 用户编号与角色编号的缓存映射
|
||||
* key:用户编号
|
||||
* value:角色编号的数组
|
||||
*
|
||||
* 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向
|
||||
*/
|
||||
@Getter
|
||||
|
Reference in New Issue
Block a user