Commit 281e8074 by zhiwj

添加查询短信签名的接口

parent 0635a37e
package com.gic.auth.dto;
import java.io.Serializable;
import java.util.List;
/**
*
* @Description:
* @author zhiwj
* @date 2019-12-17 16:46
*/
public class SmsSignResourceDTO implements Serializable {
private static final long serialVersionUID = -6009818220117316815L;
//
private List<Long> ids;
// 1:全部 2:部分
private Integer type;
public List<Long> getIds() {
return ids;
}
public void setIds(List<Long> ids) {
this.ids = ids;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
}
...@@ -3,6 +3,9 @@ package com.gic.auth.service; ...@@ -3,6 +3,9 @@ package com.gic.auth.service;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.ResourceDTO; import com.gic.auth.dto.ResourceDTO;
import com.gic.auth.dto.SmsSignResourceDTO;
import java.util.List;
/** /**
* *
...@@ -58,4 +61,9 @@ public interface ResourceApiService { ...@@ -58,4 +61,9 @@ public interface ResourceApiService {
* @throws * @throws
*/ */
ServiceResponse<ResourceDTO> getResource(Integer resourceId); ServiceResponse<ResourceDTO> getResource(Integer resourceId);
/**
* 查询短信签名
*/
ServiceResponse<SmsSignResourceDTO> getSmsResourceByUserId(Integer userId);
} }
package com.gic.auth.dao.mapper; package com.gic.auth.dao.mapper;
import com.gic.auth.entity.TabSysOrderAppResource; import com.gic.auth.entity.TabSysOrderAppResource;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabSysOrderAppResourceMapper { public interface TabSysOrderAppResourceMapper {
/** /**
...@@ -50,4 +53,6 @@ public interface TabSysOrderAppResourceMapper { ...@@ -50,4 +53,6 @@ public interface TabSysOrderAppResourceMapper {
* @return 更新条目数 * @return 更新条目数
*/ */
int updateByPrimaryKey(TabSysOrderAppResource record); int updateByPrimaryKey(TabSysOrderAppResource record);
List<TabSysOrderAppResource> listByIds(@Param("ids") List<Integer> smsSignList, @Param("type") Integer type);
} }
\ No newline at end of file
...@@ -3,6 +3,8 @@ package com.gic.auth.service; ...@@ -3,6 +3,8 @@ package com.gic.auth.service;
import com.gic.auth.dto.OrderAppResourceDTO; import com.gic.auth.dto.OrderAppResourceDTO;
import com.gic.auth.entity.TabSysOrderAppResource; import com.gic.auth.entity.TabSysOrderAppResource;
import java.util.List;
/** /**
* *
* @Description: * @Description:
...@@ -18,4 +20,6 @@ public interface OrderAppResourceService { ...@@ -18,4 +20,6 @@ public interface OrderAppResourceService {
Integer del(Integer orderAppResourceId); Integer del(Integer orderAppResourceId);
TabSysOrderAppResource getById(Integer orderAppResourceId); TabSysOrderAppResource getById(Integer orderAppResourceId);
List<TabSysOrderAppResource> listByIds(List<Integer> smsSignList, Integer type);
} }
...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* *
...@@ -52,4 +53,9 @@ public class OrderAppResourceServiceImpl implements OrderAppResourceService { ...@@ -52,4 +53,9 @@ public class OrderAppResourceServiceImpl implements OrderAppResourceService {
public TabSysOrderAppResource getById(Integer orderAppResourceId) { public TabSysOrderAppResource getById(Integer orderAppResourceId) {
return tabSysOrderAppResourceMapper.selectByPrimaryKey(orderAppResourceId); return tabSysOrderAppResourceMapper.selectByPrimaryKey(orderAppResourceId);
} }
@Override
public List<TabSysOrderAppResource> listByIds(List<Integer> smsSignList, Integer type) {
return tabSysOrderAppResourceMapper.listByIds(smsSignList, type);
}
} }
package com.gic.auth.service.outer.impl; package com.gic.auth.service.outer.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.constant.OrderOrAppEnum; import com.gic.auth.constant.OrderOrAppEnum;
import com.gic.auth.dto.OrderAppResourceDTO; import com.gic.auth.dto.OrderAppResourceDTO;
import com.gic.auth.dto.ResourceDTO; import com.gic.auth.dto.ResourceDTO;
import com.gic.auth.dto.SmsSignResourceDTO;
import com.gic.auth.dto.UserResourceDTO;
import com.gic.auth.entity.TabSysOrderAppResource; import com.gic.auth.entity.TabSysOrderAppResource;
import com.gic.auth.entity.TabSysResource; import com.gic.auth.entity.TabSysResource;
import com.gic.auth.service.OrderAppResourceService; import com.gic.auth.service.OrderAppResourceService;
...@@ -14,15 +19,19 @@ import com.gic.auth.service.UserResourceService; ...@@ -14,15 +19,19 @@ import com.gic.auth.service.UserResourceService;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.PageHelperUtils; import com.gic.commons.util.PageHelperUtils;
import com.gic.enterprise.error.ErrorCode; import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.response.EnterpriseServiceResponse;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -81,6 +90,7 @@ public class ResourceApiServiceImpl implements ResourceApiService { ...@@ -81,6 +90,7 @@ public class ResourceApiServiceImpl implements ResourceApiService {
TabSysResource resource = resourceService.getResource(resourceDTO.getResourceId()); TabSysResource resource = resourceService.getResource(resourceDTO.getResourceId());
orderAppResourceService.del(resource.getOrderResource()); orderAppResourceService.del(resource.getOrderResource());
orderAppResourceService.del(resource.getAppResource()); orderAppResourceService.del(resource.getAppResource());
orderAppResourceService.del(resource.getSmsSignResource());
resourceService.update(resourceDTO); resourceService.update(resourceDTO);
} }
return ServiceResponse.success(); return ServiceResponse.success();
...@@ -134,4 +144,38 @@ public class ResourceApiServiceImpl implements ResourceApiService { ...@@ -134,4 +144,38 @@ public class ResourceApiServiceImpl implements ResourceApiService {
} }
return ServiceResponse.success(resourceDTO); return ServiceResponse.success(resourceDTO);
} }
@Override
public ServiceResponse<SmsSignResourceDTO> getSmsResourceByUserId(Integer userId) {
List<UserResourceDTO> userResourceList = userResourceService.listUserResourceByUserId(userId);
if (CollectionUtils.isEmpty(userResourceList)) {
return EnterpriseServiceResponse.success();
}
List<Integer> resourceIds = userResourceList.stream().map(UserResourceDTO::getResourceId).collect(Collectors.toList());
List<TabSysResource> resourceList = resourceService.listByIds(resourceIds);
List<Integer> smsSignList = resourceList.stream().filter(Objects::nonNull).map(TabSysResource::getSmsSignResource).collect(Collectors.toList());
if (CollectionUtils.isEmpty(smsSignList)) {
return EnterpriseServiceResponse.success();
}
List<TabSysOrderAppResource> orderAppResourceList = orderAppResourceService.listByIds(smsSignList, OrderOrAppEnum.SMS_SIGN.getCode());
SmsSignResourceDTO result = new SmsSignResourceDTO();
List<Long> resultIds = new ArrayList<>();
for (TabSysOrderAppResource orderAppResource : orderAppResourceList) {
String json = orderAppResource.getContent();
if (StringUtils.isNotBlank(json)) {
JSONObject jsonObject = JSON.parseObject(json);
Integer type = jsonObject.getInteger("type");
if (type == 1) {
result.setType(1);
return EnterpriseServiceResponse.success(result);
}
JSONArray ids = jsonObject.getJSONArray("ids");
for (Object id : ids) {
resultIds.add(Long.valueOf(id.toString()));
}
}
}
result.setIds(resultIds);
return EnterpriseServiceResponse.success(result);
}
} }
...@@ -117,4 +117,20 @@ ...@@ -117,4 +117,20 @@
status = #{status,jdbcType=INTEGER} status = #{status,jdbcType=INTEGER}
where order_app_resource_id = #{orderAppResourceId,jdbcType=INTEGER} where order_app_resource_id = #{orderAppResourceId,jdbcType=INTEGER}
</update> </update>
<select id="listByIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_order_app_resource
<where>
<if test="type != null ">
and type = #{type}
</if>
<if test="null != ids and ids.size > 0">
and order_app_resource_id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -131,8 +131,8 @@ public class ResourceController { ...@@ -131,8 +131,8 @@ public class ResourceController {
resourceDTO.setAppResourceJson(JSON.toJSONString(resourceQO.getAppResourceJSON())); resourceDTO.setAppResourceJson(JSON.toJSONString(resourceQO.getAppResourceJSON()));
} }
// 短信签名资源 // 短信签名资源
if (CollectionUtils.isNotEmpty(resourceQO.getSmsSignResourceJSON())) { if (CollectionUtils.isNotEmpty(resourceQO.getSmsResourceJSON())) {
resourceDTO.setSmsSignResourceJson(JSON.toJSONString(resourceQO.getSmsSignResourceJSON())); resourceDTO.setSmsSignResourceJson(JSON.toJSONString(resourceQO.getSmsResourceJSON()));
} }
ServiceResponse<Integer> response = resourceApiService.saveOrUpdateResource(resourceDTO); ServiceResponse<Integer> response = resourceApiService.saveOrUpdateResource(resourceDTO);
......
...@@ -66,7 +66,7 @@ public class ResourceQO implements Serializable { ...@@ -66,7 +66,7 @@ public class ResourceQO implements Serializable {
private List<List<Long>> appResourceJSON; private List<List<Long>> appResourceJSON;
private List<SmsSignResourceQO> smsSignResourceJSON; private List<SmsSignResourceQO> smsResourceJSON;
public Integer getResourceId() { public Integer getResourceId() {
return resourceId; return resourceId;
...@@ -156,11 +156,11 @@ public class ResourceQO implements Serializable { ...@@ -156,11 +156,11 @@ public class ResourceQO implements Serializable {
this.goodsResource = goodsResource; this.goodsResource = goodsResource;
} }
public List<SmsSignResourceQO> getSmsSignResourceJSON() { public List<SmsSignResourceQO> getSmsResourceJSON() {
return smsSignResourceJSON; return smsResourceJSON;
} }
public void setSmsSignResourceJSON(List<SmsSignResourceQO> smsSignResourceJSON) { public void setSmsResourceJSON(List<SmsSignResourceQO> smsResourceJSON) {
this.smsSignResourceJSON = smsSignResourceJSON; this.smsResourceJSON = smsResourceJSON;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment