@@ -68,7 +68,6 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||
} | |||
try{ | |||
logger.info("请求body{}--"+body); | |||
// JSONObject parameterMap = JSON.parseObject(body); | |||
Map<String, Object> parameterMap = JSONObject.parseObject(body, Map.class); | |||
if(parameterMap.isEmpty()){ | |||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"参数格式不正确"); | |||
@@ -149,8 +149,8 @@ public class ShiroConfig { | |||
//配置退出 过滤器,其中的具体的退出代码Shiro已经替我们实现了 | |||
filterChainDefinitionMap.put("/logout", "authc"); | |||
// filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||
filterChainDefinitionMap.put("/**", "anon"); | |||
filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||
// filterChainDefinitionMap.put("/**", "anon"); | |||
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); | |||
@@ -0,0 +1,49 @@ | |||
package com.iformall.controller.sm; | |||
import com.iformall.common.ResultData; | |||
import com.iformall.controller.base.BaseController; | |||
import com.iformall.domain.dto.neuver.SaveServiceInfoDTO; | |||
import com.iformall.domain.dto.neuver.UpdateServiceInfoDTO; | |||
import com.iformall.domain.dto.neuver.UpdateServiceInfoStatusDTO; | |||
import com.iformall.domain.po.sm.ServiceInfo; | |||
import com.iformall.service.sm.ServiceInfoService; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
@RestController | |||
@RequestMapping("/serviceInfo") | |||
@Api(tags = "合作商接口") | |||
public class ServiceInfoController extends BaseController { | |||
@Autowired | |||
private ServiceInfoService serviceInfoService; | |||
@ApiOperation("分页查询合作商") | |||
@GetMapping("/page") | |||
public ResultData pageServiceInfo(ServiceInfo serviceInfo, Integer pageNum, Integer pageSize) { | |||
return new ResultData(serviceInfoService.pageServiceInfo(serviceInfo, pageNum, pageSize)); | |||
} | |||
@ApiOperation("新增合作商") | |||
@PostMapping("/save") | |||
public ResultData saveServiceInfo(@RequestBody SaveServiceInfoDTO dto) { | |||
serviceInfoService.saveServiceInfo(dto); | |||
return new ResultData(); | |||
} | |||
@ApiOperation("修改合作商") | |||
@PostMapping("/update") | |||
public ResultData updateServiceInfo(@RequestBody UpdateServiceInfoDTO dto) { | |||
serviceInfoService.updateServiceInfo(dto); | |||
return new ResultData(); | |||
} | |||
@ApiOperation("修改合作商状态") | |||
@PostMapping("/updateStatus") | |||
public ResultData updateServiceInfoStatus(@RequestBody UpdateServiceInfoStatusDTO dto) { | |||
serviceInfoService.updateServiceInfoStatus(dto); | |||
return new ResultData(); | |||
} | |||
} |
@@ -0,0 +1,32 @@ | |||
package com.iformall.controller.sm; | |||
import com.iformall.common.ResultData; | |||
import com.iformall.domain.dto.neuver.UpdateThirdPartyApiStatusDTO; | |||
import com.iformall.domain.po.WxThirdPartyApi; | |||
import com.iformall.service.WxThirdPartyApiService; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
@RestController | |||
@RequestMapping("/thirdPartyApi") | |||
@Api(tags = "秘钥接口") | |||
public class ThirdPartyApiController { | |||
@Autowired | |||
private WxThirdPartyApiService thirdPartyApiService; | |||
@ApiOperation("分页查询秘钥") | |||
@GetMapping("/page") | |||
public ResultData pageThirdPartyApi(WxThirdPartyApi thirdPartyApi, Integer pageNum, Integer pageSize) { | |||
return new ResultData(thirdPartyApiService.pageThirdPartyApi(thirdPartyApi, pageNum, pageSize)); | |||
} | |||
@ApiOperation("修改秘钥状态") | |||
@PostMapping("/updateStatus") | |||
public ResultData updateThirdPartyApiStatus(@RequestBody UpdateThirdPartyApiStatusDTO dto) { | |||
thirdPartyApiService.updateThirdPartyApiStatus(dto); | |||
return new ResultData(); | |||
} | |||
} |
@@ -110,7 +110,6 @@ public class HomeController extends BaseController { | |||
} | |||
if (StringUtils.isBlank(user.getUsername()) || StringUtils.isBlank(user.getPassword())) { | |||
// throw new SystemException(ErrorCode.LOGIN_USER_OR_PWD_ERROR); | |||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
} | |||
// check user | |||
@@ -45,11 +45,9 @@ public class MallRoleController extends BaseController { | |||
@ApiOperation("角色列表") | |||
@GetMapping("list") | |||
//@RequiresPermissions("sys:role:list") | |||
@ApiImplicitParams({ | |||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
@SystemControllerLog(description = "用户管理-role列表") | |||
public ResultData list(MallRole sysRole, Integer pageNum, Integer pageSize) { | |||
logger.debug("[" + getIpAddr() + "] MallRoleController::list"); | |||
sysRole.updateTenantInfo(getTenantInfo()); | |||
@@ -46,11 +46,6 @@ public class MyShiroRealm extends AuthorizingRealm { | |||
if(user == null) { | |||
throw new UnknownAccountException(ErrorCode.USER_IS_EMPTY.getMessage()); | |||
} | |||
// 租户1为预留系统管理端 | |||
// if(user.getTenantId().equals("1")) { | |||
// // 只支持租户为1的用户 | |||
// throw new UnknownAccountException("租户不支持"); | |||
// } | |||
if(user.getStatus()==null || | |||
!EnumMallUserStatus.VALID.getCode().equals(user.getStatus())) {//用户被禁用 | |||
@@ -67,16 +62,6 @@ public class MyShiroRealm extends AuthorizingRealm { | |||
session.setAttribute(UserSession.userInfo, user); | |||
session.setAttribute(UserSession.userId, user.getId()); | |||
session.setAttribute(UserSession.tenantId, user.getTenantId()); | |||
if (StringUtils.isNotBlank(user.getParentTenantId())) { | |||
session.setAttribute(UserSession.parentTenantId, user.getParentTenantId()); | |||
}else{ | |||
session.setAttribute(UserSession.parentTenantId, null); | |||
// String parentTenantId = (String)session.getAttribute(UserSession.parentTenantId); | |||
// if(StringUtils.isNotBlank(parentTenantId)){ | |||
// session.removeAttribute(UserSession.parentTenantId); | |||
// } | |||
} | |||
return authenticationInfo; | |||
} | |||
@@ -200,4 +200,12 @@ ueditor: | |||
logging: | |||
level: | |||
com.iformall: debug | |||
path: ./logs/admin | |||
path: ./logs/admin | |||
suimang: | |||
oral_broadcasting: xxx | |||
photo_speak: xxx | |||
photo_speak_hy: xxx | |||
digital_avatar: xxx | |||
digital_avatar_hy: xxx | |||
callbackUrl: xxx |
@@ -156,4 +156,12 @@ ueditor: | |||
logging: | |||
level: | |||
com.iformall.mapper: debug | |||
path: ./logs/admin | |||
path: ./logs/admin | |||
suimang: | |||
oral_broadcasting: xxx | |||
photo_speak: xxx | |||
photo_speak_hy: xxx | |||
digital_avatar: xxx | |||
digital_avatar_hy: xxx | |||
callbackUrl: xxx |
@@ -678,6 +678,9 @@ public enum ErrorCode{ | |||
ORDER_CREAT_OVERRUN(64000, "重复生成次数超限"), | |||
CODE_ALREADY_EXISTS(71000, "该code已存在"), | |||
SECRET_NOT_EXISTS(71001, "该秘钥不存在"), | |||
SERVICE_LOCKED(71002, "合作商被锁定,无法修改"), | |||
; | |||
private int code; | |||
@@ -16,7 +16,7 @@ public class SaveServiceInfoDTO { | |||
private String name; | |||
@ApiModelProperty("所在地址") | |||
private String address; | |||
@ApiModelProperty("客户唯一凭证,api接入需提供") | |||
@ApiModelProperty("客户唯一凭证") | |||
private String code; | |||
@ApiModelProperty("接入方式(1:api接入,2:私有化接入)") | |||
private Integer type; | |||
@@ -4,14 +4,18 @@ import com.iformall.common.IdWorker; | |||
import com.iformall.domain.po.sm.ServiceVideoRecord; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.util.Date; | |||
@ApiModel(value = "新增生成视频时长记录") | |||
@Data | |||
@Builder | |||
@NoArgsConstructor | |||
@AllArgsConstructor | |||
public class SaveServiceVideoRecordDTO { | |||
@ApiModelProperty("接入商标识") | |||
private Long serviceId; | |||
@@ -0,0 +1,22 @@ | |||
package com.iformall.domain.dto.neuver; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
@ApiModel(value = "新增开放接口秘钥") | |||
@Data | |||
@Builder | |||
@NoArgsConstructor | |||
@AllArgsConstructor | |||
public class SaveThirdPartyApiDTO { | |||
@ApiModelProperty("第三方类型(1:API接入,2:私有化接入)") | |||
private Integer type; | |||
@ApiModelProperty("名称") | |||
private String name; | |||
@ApiModelProperty("接入商id") | |||
private Long serviceId; | |||
} |
@@ -0,0 +1,29 @@ | |||
package com.iformall.domain.dto.neuver; | |||
import com.iformall.common.CommonConstants; | |||
import com.iformall.domain.po.sm.ServiceInfo; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import java.util.Date; | |||
@ApiModel(value = "修改接入商") | |||
@Data | |||
public class UpdateServiceInfoDTO { | |||
@ApiModelProperty("id") | |||
private Long id; | |||
@ApiModelProperty("客户名称") | |||
private String name; | |||
@ApiModelProperty("所在地址") | |||
private String address; | |||
public static ServiceInfo mapping(UpdateServiceInfoDTO dto) { | |||
ServiceInfo serviceInfo = new ServiceInfo(); | |||
serviceInfo.setId(dto.getId()); | |||
serviceInfo.setUpdateTime(new Date()); | |||
serviceInfo.setName(dto.getName()); | |||
serviceInfo.setAddress(dto.getAddress()); | |||
return serviceInfo; | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
package com.iformall.domain.dto.neuver; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
@ApiModel(value = "更新接入商状态") | |||
@Data | |||
public class UpdateServiceInfoStatusDTO { | |||
@ApiModelProperty("接入商id") | |||
private Long id; | |||
@ApiModelProperty("状态(0:正常,1:失效)") | |||
private Integer status; | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.iformall.domain.dto.neuver; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
@ApiModel(value = "更新开放接口秘钥状态") | |||
@Data | |||
public class UpdateThirdPartyApiStatusDTO { | |||
@ApiModelProperty("开放接口秘钥id") | |||
private Long id; | |||
@ApiModelProperty("状态(0:正常,1:失效)") | |||
private Integer status; | |||
} |
@@ -44,7 +44,7 @@ public class ServiceInfo { | |||
@TableField("address") | |||
private String address; | |||
/** | |||
* 客户唯一凭证,api接入需提供 | |||
* 客户唯一凭证 | |||
*/ | |||
@TableField("code") | |||
private String code; | |||
@@ -0,0 +1,31 @@ | |||
package com.iformall.enums.sm; | |||
public enum EnumThirdPartyType { | |||
API_JOIN(1, "API接入"), | |||
PRIVATE_JOIN(2, "私有化接入"); | |||
public static EnumThirdPartyType getEnum(Integer code) { | |||
for (EnumThirdPartyType value : values()) { | |||
if (value.getCode().equals(code)) { | |||
return value; | |||
} | |||
} | |||
return null; | |||
} | |||
private Integer code; | |||
private String message; | |||
EnumThirdPartyType(Integer code, String message) { | |||
this.code = code; | |||
this.message = message; | |||
} | |||
public Integer getCode() { | |||
return code; | |||
} | |||
public String getMessage() { | |||
return message; | |||
} | |||
} |
@@ -3,5 +3,21 @@ package com.iformall.mapper; | |||
import com.iformall.common.CommonMapper; | |||
import com.iformall.domain.po.sm.ServiceInfo; | |||
import java.util.List; | |||
/** | |||
* 合作商service | |||
* | |||
* @author xmzhao71 | |||
* @date 2023-10-24 | |||
*/ | |||
public interface ServiceInfoMapper extends CommonMapper<ServiceInfo, Long> { | |||
/** | |||
* 全查询合作商 | |||
* | |||
* @param serviceInfo | |||
* @return {@link List}<{@link ServiceInfo}> | |||
*/ | |||
List<ServiceInfo> listServiceInfo(ServiceInfo serviceInfo); | |||
} |
@@ -9,4 +9,11 @@ public interface WxThirdPartyApiMapper extends CommonMapper<WxThirdPartyApi, Lon | |||
List<WxThirdPartyApi> findList(WxThirdPartyApi apiConfig); | |||
/** | |||
* 全查询秘钥 | |||
* | |||
* @param thirdPartyApi | |||
* @return {@link List}<{@link WxThirdPartyApi}> | |||
*/ | |||
List<WxThirdPartyApi> listThirdPartyApi(WxThirdPartyApi thirdPartyApi); | |||
} |
@@ -1,5 +1,8 @@ | |||
package com.iformall.service; | |||
import com.github.pagehelper.PageInfo; | |||
import com.iformall.domain.dto.neuver.SaveThirdPartyApiDTO; | |||
import com.iformall.domain.dto.neuver.UpdateThirdPartyApiStatusDTO; | |||
import com.iformall.domain.po.WxThirdPartyApi; | |||
import java.util.List; | |||
@@ -18,4 +21,27 @@ public interface WxThirdPartyApiService { | |||
WxThirdPartyApi findByApp(String appId, String appKey); | |||
/** | |||
* 分页查询秘钥 | |||
* | |||
* @param thirdPartyApi | |||
* @param pageNum | |||
* @param pageSize | |||
* @return {@link PageInfo}<{@link WxThirdPartyApi}> | |||
*/ | |||
PageInfo<WxThirdPartyApi> pageThirdPartyApi(WxThirdPartyApi thirdPartyApi, Integer pageNum, Integer pageSize); | |||
/** | |||
* 新增秘钥 | |||
* | |||
* @param dto | |||
*/ | |||
void saveThirdPartyApi(SaveThirdPartyApiDTO dto); | |||
/** | |||
* 修改秘钥状态 | |||
* | |||
* @param dto | |||
*/ | |||
void updateThirdPartyApiStatus(UpdateThirdPartyApiStatusDTO dto); | |||
} |
@@ -1,12 +1,24 @@ | |||
package com.iformall.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.iformall.domain.po.WxAppinfo; | |||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||
import com.github.pagehelper.PageHelper; | |||
import com.github.pagehelper.PageInfo; | |||
import com.iformall.common.CommonConstants; | |||
import com.iformall.common.ErrorCode; | |||
import com.iformall.common.IdWorker; | |||
import com.iformall.domain.dto.neuver.SaveThirdPartyApiDTO; | |||
import com.iformall.domain.dto.neuver.UpdateThirdPartyApiStatusDTO; | |||
import com.iformall.domain.po.WxThirdPartyApi; | |||
import com.iformall.domain.po.sm.ServiceInfo; | |||
import com.iformall.exception.BizException; | |||
import com.iformall.mapper.ServiceInfoMapper; | |||
import com.iformall.mapper.WxThirdPartyApiMapper; | |||
import com.iformall.service.WxThirdPartyApiService; | |||
import com.iformall.utils.Constant; | |||
import com.iformall.utils.RedisCacheUtils; | |||
import com.iformall.utils.sign.AppUtils; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
@@ -25,6 +37,8 @@ public class WxThirdPartyApiServiceImpl implements WxThirdPartyApiService { | |||
@Autowired | |||
WxThirdPartyApiMapper wxThirdPartyApiMapper; | |||
@Autowired | |||
private ServiceInfoMapper serviceInfoMapper; | |||
@Autowired | |||
@Qualifier("objectCommonRedisTemplate") | |||
@@ -48,8 +62,57 @@ public class WxThirdPartyApiServiceImpl implements WxThirdPartyApiService { | |||
WxThirdPartyApi apiQ = new WxThirdPartyApi(); | |||
apiQ.setAppId(appId); | |||
apiQ.setAppKey(appKey); | |||
apiQ.setStatus(CommonConstants.STATUS_NORMAL); | |||
apiConfig = wxThirdPartyApiMapper.selectOne(new QueryWrapper<>(apiQ)); | |||
RedisCacheUtils.cache(redisTemplate, Constant.publicApi + appId, apiConfig,0l); | |||
return apiConfig; | |||
} | |||
@Override | |||
public PageInfo<WxThirdPartyApi> pageThirdPartyApi(WxThirdPartyApi thirdPartyApi, Integer pageNum, Integer pageSize) { | |||
return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxThirdPartyApiMapper.listThirdPartyApi(thirdPartyApi)); | |||
} | |||
@Override | |||
public void saveThirdPartyApi(SaveThirdPartyApiDTO dto) { | |||
WxThirdPartyApi thirdPartyApi = buildThirdPartyApi(dto); | |||
wxThirdPartyApiMapper.insert(thirdPartyApi); | |||
} | |||
@Override | |||
public void updateThirdPartyApiStatus(UpdateThirdPartyApiStatusDTO dto) { | |||
WxThirdPartyApi thirdPartyApi = wxThirdPartyApiMapper.selectOne(new LambdaQueryWrapper<WxThirdPartyApi>().eq(WxThirdPartyApi::getId, dto.getId())); | |||
if (thirdPartyApi == null) { | |||
throw new BizException(ErrorCode.SECRET_NOT_EXISTS); | |||
} | |||
ServiceInfo serviceInfo = serviceInfoMapper.selectOne(new LambdaQueryWrapper<ServiceInfo>().eq(ServiceInfo::getId, thirdPartyApi.getServiceId())); | |||
if (serviceInfo == null || CommonConstants.STATUS_ABNORMAL.equals(serviceInfo.getStatus())) { | |||
throw new BizException(ErrorCode.SERVICE_LOCKED); | |||
} | |||
wxThirdPartyApiMapper.update(null, new LambdaUpdateWrapper<WxThirdPartyApi>() | |||
.set(WxThirdPartyApi::getStatus, dto.getStatus()) | |||
.eq(WxThirdPartyApi::getId, dto.getId())); | |||
} | |||
/** | |||
* 构建秘钥实体 | |||
* | |||
* @param dto | |||
* @return {@link WxThirdPartyApi} | |||
*/ | |||
private WxThirdPartyApi buildThirdPartyApi(SaveThirdPartyApiDTO dto) { | |||
WxThirdPartyApi thirdPartyApi = new WxThirdPartyApi(); | |||
thirdPartyApi.setId(IdWorker.get().nextId()); | |||
thirdPartyApi.setType(dto.getType()); | |||
thirdPartyApi.setName(dto.getName()); | |||
thirdPartyApi.setServiceId(dto.getServiceId()); | |||
String appId = AppUtils.getAppId(); | |||
String appKey = AppUtils.getAppKey(appId); | |||
String signKey = AppUtils.getSignKey(appId, appKey); | |||
thirdPartyApi.setAppId(appId); | |||
thirdPartyApi.setAppKey(appKey); | |||
thirdPartyApi.setSignKey(signKey); | |||
thirdPartyApi.setStatus(CommonConstants.STATUS_NORMAL); | |||
return thirdPartyApi; | |||
} | |||
} |
@@ -2,6 +2,9 @@ package com.iformall.service.sm; | |||
import com.github.pagehelper.PageInfo; | |||
import com.iformall.domain.dto.neuver.SaveServiceInfoDTO; | |||
import com.iformall.domain.dto.neuver.UpdateServiceInfoDTO; | |||
import com.iformall.domain.dto.neuver.UpdateServiceInfoStatusDTO; | |||
import com.iformall.domain.po.sm.ServiceInfo; | |||
import com.iformall.domain.vo.neuver.PageServiceInfoVO; | |||
/** | |||
@@ -26,5 +29,19 @@ public interface ServiceInfoService { | |||
* @param pageSize | |||
* @return {@link PageInfo}<{@link PageServiceInfoVO}> | |||
*/ | |||
PageInfo<PageServiceInfoVO> pageServiceInfo(Integer pageNum, Integer pageSize); | |||
PageInfo<ServiceInfo> pageServiceInfo(ServiceInfo serviceInfo, Integer pageNum, Integer pageSize); | |||
/** | |||
* 修改接入商 | |||
* | |||
* @param dto | |||
*/ | |||
void updateServiceInfo(UpdateServiceInfoDTO dto); | |||
/** | |||
* 修改接入商状态 | |||
* | |||
* @param dto | |||
*/ | |||
void updateServiceInfoStatus(UpdateServiceInfoStatusDTO dto); | |||
} |
@@ -1,18 +1,22 @@ | |||
package com.iformall.service.sm.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||
import com.github.pagehelper.PageHelper; | |||
import com.github.pagehelper.PageInfo; | |||
import com.iformall.common.CommonConstants; | |||
import com.iformall.common.ErrorCode; | |||
import com.iformall.domain.dto.neuver.SaveServiceInfoDTO; | |||
import com.iformall.domain.dto.neuver.*; | |||
import com.iformall.domain.po.WxThirdPartyApi; | |||
import com.iformall.domain.po.sm.ServiceInfo; | |||
import com.iformall.domain.vo.neuver.PageServiceInfoVO; | |||
import com.iformall.exception.BizException; | |||
import com.iformall.mapper.ServiceInfoMapper; | |||
import com.iformall.mapper.WxThirdPartyApiMapper; | |||
import com.iformall.service.WxThirdPartyApiService; | |||
import com.iformall.service.sm.ServiceInfoService; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.util.Optional; | |||
@@ -21,20 +25,57 @@ public class ServiceInfoServiceImpl implements ServiceInfoService { | |||
@Autowired | |||
private ServiceInfoMapper serviceInfoMapper; | |||
@Autowired | |||
private WxThirdPartyApiService thirdPartyApiService; | |||
@Autowired | |||
private WxThirdPartyApiMapper wxThirdPartyApiMapper; | |||
@Transactional(rollbackFor = Exception.class) | |||
@Override | |||
public void saveServiceInfo(SaveServiceInfoDTO dto) { | |||
// 校验 | |||
ServiceInfo serviceInfo = serviceInfoMapper.selectOne(new LambdaQueryWrapper<ServiceInfo>() | |||
.eq(ServiceInfo::getDelFlag, CommonConstants.DEL_FLAG_NORMAL) | |||
.eq(ServiceInfo::getCode, dto.getCode())); | |||
Optional.ofNullable(serviceInfo).orElseThrow(() -> new BizException(ErrorCode.CODE_ALREADY_EXISTS)); | |||
if (serviceInfo != null) { | |||
throw new BizException(ErrorCode.CODE_ALREADY_EXISTS); | |||
} | |||
ServiceInfo mapping = SaveServiceInfoDTO.mapping(dto); | |||
serviceInfoMapper.insert(mapping); | |||
// 生成秘钥 | |||
SaveThirdPartyApiDTO thirdPartyApi = SaveThirdPartyApiDTO.builder() | |||
.type(mapping.getType()) | |||
.name(mapping.getName()) | |||
.serviceId(mapping.getId()) | |||
.build(); | |||
thirdPartyApiService.saveThirdPartyApi(thirdPartyApi); | |||
} | |||
serviceInfoMapper.insert(SaveServiceInfoDTO.mapping(dto)); | |||
@Override | |||
public PageInfo<ServiceInfo> pageServiceInfo(ServiceInfo serviceInfo, Integer pageNum, Integer pageSize) { | |||
return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> serviceInfoMapper.listServiceInfo(serviceInfo)); | |||
} | |||
@Override | |||
public PageInfo<PageServiceInfoVO> pageServiceInfo(Integer pageNum, Integer pageSize) { | |||
return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> serviceInfoMapper.selectList(null)); | |||
public void updateServiceInfo(UpdateServiceInfoDTO dto) { | |||
serviceInfoMapper.updateById(UpdateServiceInfoDTO.mapping(dto)); | |||
} | |||
@Transactional(rollbackFor = Exception.class) | |||
@Override | |||
public void updateServiceInfoStatus(UpdateServiceInfoStatusDTO dto) { | |||
// 修改合作商状态 | |||
serviceInfoMapper.update(null, new LambdaUpdateWrapper<ServiceInfo>() | |||
.set(ServiceInfo::getStatus, dto.getStatus()) | |||
.eq(ServiceInfo::getId, dto.getId())); | |||
if (CommonConstants.STATUS_ABNORMAL.equals(dto.getStatus())) { | |||
// 若合作商为锁定状态,则修改秘钥状态 | |||
wxThirdPartyApiMapper.update(null, new LambdaUpdateWrapper<WxThirdPartyApi>() | |||
.set(WxThirdPartyApi::getStatus, dto.getStatus()) | |||
.eq(WxThirdPartyApi::getServiceId, dto.getId())); | |||
} | |||
} | |||
} |
@@ -0,0 +1,41 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
<mapper namespace="com.iformall.mapper.ServiceInfoMapper"> | |||
<sql id="allColumns"> | |||
`id`, `create_time`, `update_time`, `name`, `address`, `code`, `type`, `status`, `del_flag` | |||
</sql> | |||
<sql id="dynamicWhereConditions"> | |||
where 1 = 1 | |||
<if test=" null != id "> | |||
and `id` = #{id} | |||
</if> | |||
<if test=" null != name and '' != name"> | |||
and `name` LIKE CONCAT('%', #{name},'%') | |||
</if> | |||
<if test=" null != code and '' != code"> | |||
and `code` = #{code} | |||
</if> | |||
<if test=" null != type "> | |||
and `type` = #{type} | |||
</if> | |||
<if test=" null != status "> | |||
and `status` = #{status} | |||
</if> | |||
<if test=" null != delFlag "> | |||
and `del_flag` = #{delFlag} | |||
</if> | |||
</sql> | |||
<select id="listServiceInfo" resultType="com.iformall.domain.po.sm.ServiceInfo"> | |||
SELECT | |||
<include refid="allColumns"/> | |||
FROM service_info | |||
<include refid="dynamicWhereConditions"/> | |||
</select> | |||
</mapper> |
@@ -21,8 +21,33 @@ | |||
</resultMap> | |||
<sql id="allColumns"> | |||
`id`,`tenant_id`,`parent_tenant_id`,`type`,`name`,`app_id`,`app_key`,`sign_key`,`api_url`, `token`,`token_expired_time`,`user_name`,`password`,`version`,`remark`,`tp_id` | |||
`id`, `tenant_id`, `parent_tenant_id`, `type`, `name`, `service_id`, `app_id`, `app_key`, `sign_key`, `api_url`, `token`, `token_expired_time`, `user_name`, `password`, `version`, `tp_id`, `remark`, `status` | |||
</sql> | |||
<sql id="generalWhereConditions"> | |||
WHERE 1 = 1 | |||
<if test=" null != id "> | |||
AND `id` = #{id} | |||
</if> | |||
<if test=" null != type "> | |||
AND `type` = #{type} | |||
</if> | |||
<if test=" null != name and '' != name "> | |||
AND `name` = #{name} | |||
</if> | |||
<if test=" null != serviceId "> | |||
AND `service_id` = #{serviceId} | |||
</if> | |||
<if test=" null != appId "> | |||
AND `app_id` = #{appId} | |||
</if> | |||
<if test=" null != appKey "> | |||
AND `app_key` = #{appKey} | |||
</if> | |||
<if test=" null != status "> | |||
AND `status` = #{status} | |||
</if> | |||
</sql> | |||
<sql id="dynamicWhereConditions"> | |||
where 1 = 1 | |||
@@ -62,6 +87,10 @@ | |||
<include refid="dynamicWhereConditions"/> | |||
</select> | |||
<select id="listThirdPartyApi" resultType="com.iformall.domain.po.WxThirdPartyApi"> | |||
SELECT | |||
<include refid="allColumns"/> | |||
FROM wx_third_party_api | |||
<include refid="generalWhereConditions"></include> | |||
</select> | |||
</mapper> |