Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ab5408ed0c
@ -12,6 +12,18 @@
|
||||
<description>地图插件,画网格</description>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.cm</groupId>
|
||||
<artifactId>cloud-common</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.security.oauth.boot</groupId>
|
||||
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,118 @@
|
||||
package com.cm.plugin.map.dao;
|
||||
|
||||
import com.cm.common.exception.RemoveException;
|
||||
import com.cm.common.exception.SaveException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.plugin.map.pojo.dto.GridDTO;
|
||||
import com.cm.plugin.map.pojo.dto.GridPointDTO;
|
||||
import com.cm.plugin.map.pojo.dto.GridRelationDTO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IGridDao
|
||||
* @Description: 网格业务
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/10/21 11:16
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Repository
|
||||
public interface IGridDao {
|
||||
/**
|
||||
* 保存网格
|
||||
*
|
||||
* @param params
|
||||
* @throws SaveException
|
||||
*/
|
||||
void saveGrid(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 保存网格关联关系
|
||||
*
|
||||
* @param params
|
||||
* @throws SaveException
|
||||
*/
|
||||
void saveGridRelation(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 保存网格点
|
||||
*
|
||||
* @param params
|
||||
* @throws SaveException
|
||||
*/
|
||||
void saveGridPoint(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 删除网格
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void deleteGrid(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 删除网格点
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void deleteGridPoint(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 删除网格关联关系
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void deleteGridRelation(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 获取关联关系列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<GridRelationDTO> listGridRelation(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取网格列表
|
||||
*
|
||||
* @param relationId 关联ID
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<GridDTO> listGridByRelationId(String relationId) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取网格点列表
|
||||
*
|
||||
* @param gridId 网格ID
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<GridPointDTO> listPointByGridId(String gridId) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取网格点列表
|
||||
*
|
||||
* @param relationIds 关联ID列表
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<GridDTO> listGridByRelationIds(List<String> relationIds) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取网格点列表
|
||||
*
|
||||
* @param gridIds 网格ID列表
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<GridPointDTO> listPointByGridIds(List<String> gridIds) throws SearchException;
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package com.cm.plugin.map.pojo.dto;
|
||||
|
||||
import com.cm.plugin.map.pojo.vo.GridPointVO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: GridDTO
|
||||
* @Description: 网格
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/10/21 17:01
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class GridDTO extends GridRelationDTO {
|
||||
|
||||
@ApiModelProperty(name = "fillColor", value = "填充颜色")
|
||||
private String fillColor;
|
||||
@ApiModelProperty(name = "gridName", value = "网格名称")
|
||||
private String gridName;
|
||||
@ApiModelProperty(name = "relationIdArray", value = "关联ID列表")
|
||||
private List<String> relationIdArray;
|
||||
@ApiModelProperty(name = "pointArray", value = "网格点列表")
|
||||
private List<GridPointDTO> pointArray;
|
||||
|
||||
public String getFillColor() {
|
||||
return fillColor == null ? "" : fillColor.trim();
|
||||
}
|
||||
|
||||
public void setFillColor(String fillColor) {
|
||||
this.fillColor = fillColor;
|
||||
}
|
||||
|
||||
public String getGridName() {
|
||||
return gridName == null ? "" : gridName.trim();
|
||||
}
|
||||
|
||||
public void setGridName(String gridName) {
|
||||
this.gridName = gridName;
|
||||
}
|
||||
|
||||
public List<String> getRelationIdArray() {
|
||||
if (relationIdArray == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return relationIdArray;
|
||||
}
|
||||
|
||||
public void setRelationIdArray(List<String> relationIdArray) {
|
||||
this.relationIdArray = relationIdArray;
|
||||
}
|
||||
|
||||
public List<GridPointDTO> getPointArray() {
|
||||
if (pointArray == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return pointArray;
|
||||
}
|
||||
|
||||
public void setPointArray(List<GridPointDTO> pointArray) {
|
||||
this.pointArray = pointArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"fillColor\":\"")
|
||||
.append(fillColor).append('\"');
|
||||
sb.append(",\"gridName\":\"")
|
||||
.append(gridName).append('\"');
|
||||
sb.append(",\"relationIdArray\":")
|
||||
.append(relationIdArray);
|
||||
sb.append(",\"pointArray\":")
|
||||
.append(pointArray);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.cm.plugin.map.pojo.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: BaiduGridPointVO
|
||||
* @Description: 百度地图网格点
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/10/21 11:02
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class GridPointDTO {
|
||||
|
||||
@ApiModelProperty(name = "gridId", value = "网格ID")
|
||||
private String gridId;
|
||||
@ApiModelProperty(name = "lng", value = "经度")
|
||||
private String lng;
|
||||
@ApiModelProperty(name = "lat", value = "纬度")
|
||||
private String lat;
|
||||
|
||||
public String getGridId() {
|
||||
return gridId == null ? "" : gridId.trim();
|
||||
}
|
||||
|
||||
public void setGridId(String gridId) {
|
||||
this.gridId = gridId;
|
||||
}
|
||||
|
||||
public String getLng() {
|
||||
return lng == null ? "" : lng.trim();
|
||||
}
|
||||
|
||||
public void setLng(String lng) {
|
||||
this.lng = lng;
|
||||
}
|
||||
|
||||
public String getLat() {
|
||||
return lat == null ? "" : lat.trim();
|
||||
}
|
||||
|
||||
public void setLat(String lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"gridId\":\"")
|
||||
.append(gridId).append('\"');
|
||||
sb.append(",\"lng\":\"")
|
||||
.append(lng).append('\"');
|
||||
sb.append(",\"lat\":\"")
|
||||
.append(lat).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.cm.plugin.map.pojo.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: GridRelationDTO
|
||||
* @Description: 网格关联
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/10/21 12:11
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class GridRelationDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 9159203095930603288L;
|
||||
@ApiModelProperty(name = "gridId", value = "网格ID")
|
||||
private String gridId;
|
||||
@ApiModelProperty(name = "relationId", value = "关联ID")
|
||||
private String relationId;
|
||||
|
||||
public String getGridId() {
|
||||
return gridId == null ? "" : gridId.trim();
|
||||
}
|
||||
|
||||
public void setGridId(String gridId) {
|
||||
this.gridId = gridId;
|
||||
}
|
||||
|
||||
public String getRelationId() {
|
||||
return relationId == null ? "" : relationId.trim();
|
||||
}
|
||||
|
||||
public void setRelationId(String relationId) {
|
||||
this.relationId = relationId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"gridId\":\"")
|
||||
.append(gridId).append('\"');
|
||||
sb.append(",\"relationId\":\"")
|
||||
.append(relationId).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.cm.plugin.map.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: BaiduGridPointVO
|
||||
* @Description: 百度地图网格点
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/10/21 11:02
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class GridPointVO {
|
||||
|
||||
@ApiModelProperty(name = "gridId", value = "网格ID")
|
||||
private String gridId;
|
||||
@ApiModelProperty(name = "lng", value = "经度")
|
||||
private String lng;
|
||||
@ApiModelProperty(name = "lat", value = "纬度")
|
||||
private String lat;
|
||||
|
||||
public String getGridId() {
|
||||
return gridId == null ? "" : gridId.trim();
|
||||
}
|
||||
|
||||
public void setGridId(String gridId) {
|
||||
this.gridId = gridId;
|
||||
}
|
||||
|
||||
public String getLng() {
|
||||
return lng == null ? "" : lng.trim();
|
||||
}
|
||||
|
||||
public void setLng(String lng) {
|
||||
this.lng = lng;
|
||||
}
|
||||
|
||||
public String getLat() {
|
||||
return lat == null ? "" : lat.trim();
|
||||
}
|
||||
|
||||
public void setLat(String lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"gridId\":\"")
|
||||
.append(gridId).append('\"');
|
||||
sb.append(",\"lng\":\"")
|
||||
.append(lng).append('\"');
|
||||
sb.append(",\"lat\":\"")
|
||||
.append(lat).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package com.cm.plugin.map.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: BaiduGridVO
|
||||
* @Description: 百度地图网格
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/10/21 11:02
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class GridVO {
|
||||
|
||||
@ApiModelProperty(name = "id", value = "网格ID")
|
||||
private String id;
|
||||
@ApiModelProperty(name = "fillColor", value = "填充颜色")
|
||||
private String fillColor;
|
||||
@ApiModelProperty(name = "gridName", value = "网格名称")
|
||||
private String gridName;
|
||||
@ApiModelProperty(name = "relationIdArray", value = "关联ID列表")
|
||||
private List<String> relationIdArray;
|
||||
@ApiModelProperty(name = "pointArray", value = "网格点列表")
|
||||
private List<GridPointVO> pointArray;
|
||||
|
||||
public String getId() {
|
||||
return id == null ? "" : id.trim();
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFillColor() {
|
||||
return fillColor == null ? "" : fillColor.trim();
|
||||
}
|
||||
|
||||
public void setFillColor(String fillColor) {
|
||||
this.fillColor = fillColor;
|
||||
}
|
||||
|
||||
public String getGridName() {
|
||||
return gridName == null ? "" : gridName.trim();
|
||||
}
|
||||
|
||||
public void setGridName(String gridName) {
|
||||
this.gridName = gridName;
|
||||
}
|
||||
|
||||
public List<String> getRelationIdArray() {
|
||||
if (relationIdArray == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return relationIdArray;
|
||||
}
|
||||
|
||||
public void setRelationIdArray(List<String> relationIdArray) {
|
||||
this.relationIdArray = relationIdArray;
|
||||
}
|
||||
|
||||
public List<GridPointVO> getPointArray() {
|
||||
if (pointArray == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return pointArray;
|
||||
}
|
||||
|
||||
public void setPointArray(List<GridPointVO> pointArray) {
|
||||
this.pointArray = pointArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"id\":\"")
|
||||
.append(id).append('\"');
|
||||
sb.append(",\"fillColor\":\"")
|
||||
.append(fillColor).append('\"');
|
||||
sb.append(",\"gridName\":\"")
|
||||
.append(gridName).append('\"');
|
||||
sb.append(",\"relationIdArray\":")
|
||||
.append(relationIdArray);
|
||||
sb.append(",\"pointArray\":")
|
||||
.append(pointArray);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
package com.cm.plugin.map.service;
|
||||
|
||||
import com.cm.common.exception.RemoveException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.plugin.map.pojo.dto.GridDTO;
|
||||
import com.cm.plugin.map.pojo.dto.GridRelationDTO;
|
||||
import com.cm.plugin.map.pojo.vo.GridPointVO;
|
||||
import com.cm.plugin.map.pojo.vo.GridVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IGridService
|
||||
* @Description: 网格业务
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/10/21 11:14
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public interface IGridService {
|
||||
|
||||
/**
|
||||
* 保存网格并返回ID
|
||||
*
|
||||
* @param gridVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
void saveGrid(GridVO gridVO) throws Exception;
|
||||
|
||||
/**
|
||||
* 更新网格数组
|
||||
*
|
||||
* @param gridId 网格ID
|
||||
* @param pointArray 点数组
|
||||
* @throws Exception
|
||||
*/
|
||||
void updateGridPointArrayByGridId(String gridId, List<GridPointVO> pointArray) throws Exception;
|
||||
|
||||
/**
|
||||
* 删除网格
|
||||
*
|
||||
* @param relationId 关联关系
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void deleteGridByRelationId(String relationId) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 删除网格
|
||||
*
|
||||
* @param gridIds 网格ID列表
|
||||
* @throws SearchException
|
||||
*/
|
||||
void deleteGridByGridIds(List<String> gridIds) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 获取网格关系列表
|
||||
*
|
||||
* @param relationId 关联ID
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<GridRelationDTO> listGridRelationByRelationId(String relationId) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取网格关系列表
|
||||
*
|
||||
* @param relationIds 关联ID列表
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<GridRelationDTO> listGridRelationByRelationIds(List<String> relationIds) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取网格关系列表
|
||||
*
|
||||
* @param gridId 网格ID
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<GridRelationDTO> listGridRelationByGridId(String gridId) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取网格关系列表
|
||||
*
|
||||
* @param gridIds 网格ID列表
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<GridRelationDTO> listGridRelationByGridIds(List<String> gridIds) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取网格列表
|
||||
*
|
||||
* @param relationId 关联ID
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<GridDTO> listGridByRelationId(String relationId) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取网格列表
|
||||
*
|
||||
* @param relationIds 关联ID列表
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<GridDTO> listGridByRelationIds(List<String> relationIds) throws SearchException;
|
||||
|
||||
}
|
@ -0,0 +1,216 @@
|
||||
package com.cm.plugin.map.service.impl;
|
||||
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.cm.common.base.AbstractService;
|
||||
import com.cm.common.exception.RemoveException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.utils.HashMapUtil;
|
||||
import com.cm.common.utils.UUIDUtil;
|
||||
import com.cm.plugin.map.dao.IGridDao;
|
||||
import com.cm.plugin.map.pojo.dto.GridDTO;
|
||||
import com.cm.plugin.map.pojo.dto.GridPointDTO;
|
||||
import com.cm.plugin.map.pojo.dto.GridRelationDTO;
|
||||
import com.cm.plugin.map.pojo.vo.GridPointVO;
|
||||
import com.cm.plugin.map.pojo.vo.GridVO;
|
||||
import com.cm.plugin.map.service.IGridService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: GridServiceImpl
|
||||
* @Description: 网格业务
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/10/21 11:14
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Service
|
||||
public class GridServiceImpl extends AbstractService implements IGridService {
|
||||
|
||||
@Autowired
|
||||
private IGridDao gridDao;
|
||||
|
||||
@Override
|
||||
public void saveGrid(GridVO gridVO) throws Exception {
|
||||
String gridId = UUIDUtil.getUUID();
|
||||
List<String> relationIdArray = gridVO.getRelationIdArray();
|
||||
List<GridPointVO> pointArray = gridVO.getPointArray();
|
||||
// 保存网格
|
||||
Map<String, Object> params = HashMapUtil.beanToMap(gridVO);
|
||||
params.put("gridId", gridId);
|
||||
params.remove("relationIdArray");
|
||||
params.remove("pointArray");
|
||||
setSaveInfo(params);
|
||||
gridDao.saveGrid(params);
|
||||
// 保存拓展属性
|
||||
saveRelationIdArray(gridId, relationIdArray);
|
||||
savePointArray(gridId, pointArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGridPointArrayByGridId(String gridId, List<GridPointVO> pointArray) throws Exception {
|
||||
// 删除原有网格数组
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("gridId", gridId);
|
||||
gridDao.deleteGridPoint(params);
|
||||
// 新增网格数组
|
||||
for (GridPointVO gridPointVO : pointArray) {
|
||||
params = HashMapUtil.beanToMap(gridPointVO);
|
||||
params.put("gridId", gridId);
|
||||
gridDao.saveGridPoint(params);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteGridByRelationId(String relationId) throws RemoveException {
|
||||
List<GridRelationDTO> gridRelationDTOs = listGridRelationByRelationId(relationId);
|
||||
if (gridRelationDTOs.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<String> gridIds = new ArrayList<>();
|
||||
for (GridRelationDTO gridRelationDTO : gridRelationDTOs) {
|
||||
gridIds.add(gridRelationDTO.getGridId());
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("gridIds", gridIds);
|
||||
// 删除网格
|
||||
gridDao.deleteGrid(params);
|
||||
// 删除网格点
|
||||
gridDao.deleteGridPoint(params);
|
||||
// 删除关联关系
|
||||
params.clear();
|
||||
params.put("relationId", relationId);
|
||||
gridDao.deleteGridRelation(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteGridByGridIds(List<String> gridIds) throws RemoveException {
|
||||
if (gridIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// 删除网格
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("gridIds", gridIds);
|
||||
gridDao.deleteGrid(params);
|
||||
// 删除点数组
|
||||
gridDao.deleteGridPoint(params);
|
||||
// 删除关联
|
||||
gridDao.deleteGridRelation(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GridRelationDTO> listGridRelationByRelationId(String relationId) throws SearchException {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("relationId", relationId);
|
||||
return gridDao.listGridRelation(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GridRelationDTO> listGridRelationByRelationIds(List<String> relationIds) throws SearchException {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("relationIds", relationIds);
|
||||
return gridDao.listGridRelation(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GridRelationDTO> listGridRelationByGridId(String gridId) throws SearchException {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("gridId", gridId);
|
||||
return gridDao.listGridRelation(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GridRelationDTO> listGridRelationByGridIds(List<String> gridIds) throws SearchException {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("gridIds", gridIds);
|
||||
return gridDao.listGridRelation(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GridDTO> listGridByRelationId(String relationId) throws SearchException {
|
||||
List<GridDTO> gridDTOs = gridDao.listGridByRelationId(relationId);
|
||||
if (gridDTOs.isEmpty()) {
|
||||
return gridDTOs;
|
||||
}
|
||||
for (GridDTO gridDTO : gridDTOs) {
|
||||
List<GridPointDTO> gridPointDTOs = gridDao.listPointByGridId(gridDTO.getGridId());
|
||||
gridDTO.setPointArray(gridPointDTOs);
|
||||
}
|
||||
return gridDTOs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GridDTO> listGridByRelationIds(List<String> relationIds) throws SearchException {
|
||||
if (relationIds == null || relationIds.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<GridDTO> gridDTOs = gridDao.listGridByRelationIds(relationIds);
|
||||
if (gridDTOs.isEmpty()) {
|
||||
return gridDTOs;
|
||||
}
|
||||
List<String> gridIds = new ArrayList<>();
|
||||
for (GridDTO gridDTO : gridDTOs) {
|
||||
gridIds.add(gridDTO.getGridId());
|
||||
}
|
||||
// 获取所有点
|
||||
List<GridPointDTO> gridPointDTOs = gridDao.listPointByGridIds(gridIds);
|
||||
if (gridPointDTOs.isEmpty()) {
|
||||
return gridDTOs;
|
||||
}
|
||||
// 构建所有点
|
||||
for (GridDTO gridDTO : gridDTOs) {
|
||||
List<GridPointDTO> pointArray = new ArrayList<>();
|
||||
for (GridPointDTO gridPointDTO : gridPointDTOs) {
|
||||
if (StringUtils.equals(gridDTO.getGridId(), gridPointDTO.getGridId())) {
|
||||
pointArray.add(gridPointDTO);
|
||||
}
|
||||
}
|
||||
gridDTO.setPointArray(pointArray);
|
||||
}
|
||||
return gridDTOs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存关联关系
|
||||
*
|
||||
* @param gridId
|
||||
* @param relationIdArray
|
||||
*/
|
||||
private void saveRelationIdArray(String gridId, List<String> relationIdArray) {
|
||||
if (relationIdArray == null || relationIdArray.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("gridId", gridId);
|
||||
for (String relationId : relationIdArray) {
|
||||
params.put("relationId", relationId);
|
||||
gridDao.saveGridRelation(params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存网格点
|
||||
*
|
||||
* @param gridId
|
||||
* @param pointArray
|
||||
*/
|
||||
private void savePointArray(String gridId, List<GridPointVO> pointArray) {
|
||||
if (pointArray == null || pointArray.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("gridId", gridId);
|
||||
for (GridPointVO gridPointVO : pointArray) {
|
||||
params.put("lng", gridPointVO.getLng());
|
||||
params.put("lat", gridPointVO.getLat());
|
||||
gridDao.saveGridPoint(params);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,221 @@
|
||||
<?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.cm.plugin.map.dao.IGridDao">
|
||||
|
||||
<resultMap id="gridRelationDTO" type="com.cm.plugin.map.pojo.dto.GridRelationDTO">
|
||||
<id column="relation_id" property="relationId"/>
|
||||
<result column="grid_id" property="gridId"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="gridDTO" type="com.cm.plugin.map.pojo.dto.GridDTO" extends="gridRelationDTO">
|
||||
<id column="grid_id" property="gridId"/>
|
||||
<result column="fill_color" property="fillColor"/>
|
||||
<result column="grid_name" property="gridName"/>
|
||||
<result column="relation_id" property="relationId"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="gridPointDTO" type="com.cm.plugin.map.pojo.dto.GridPointDTO">
|
||||
<id column="grid_id" property="gridId"/>
|
||||
<result column="lng" property="lng"/>
|
||||
<result column="lat" property="lat"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 保存网格 -->
|
||||
<insert id="saveGrid" parameterType="map">
|
||||
INSERT INTO map_grid(
|
||||
grid_id,
|
||||
grid_name,
|
||||
fill_color,
|
||||
gmt_create,
|
||||
creator,
|
||||
gmt_modified,
|
||||
modifier,
|
||||
is_delete
|
||||
) VALUES(
|
||||
#{gridId},
|
||||
#{gridName},
|
||||
#{fillColor},
|
||||
#{gmtCreate},
|
||||
#{creator},
|
||||
#{gmtModified},
|
||||
#{modifier},
|
||||
#{isDelete}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 保存网格关联关系 -->
|
||||
<insert id="saveGridRelation" parameterType="map">
|
||||
INSERT INTO map_grid_relation(
|
||||
grid_id,
|
||||
relation_id
|
||||
) VALUES(
|
||||
#{gridId},
|
||||
#{relationId}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 删除网格 -->
|
||||
<delete id="deleteGrid" parameterType="map">
|
||||
DELETE FROM
|
||||
map_grid
|
||||
WHERE
|
||||
<if test="gridId != null and gridId != ''">
|
||||
grid_id = #{gridId}
|
||||
</if>
|
||||
<if test="gridIds != null and gridIds.size > 0">
|
||||
grid_id IN
|
||||
<foreach collection="gridIds" index="index" open="(" separator="," close=")">
|
||||
#{gridIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</delete>
|
||||
|
||||
<!-- 删除网格点 -->
|
||||
<delete id="deleteGridPoint" parameterType="map">
|
||||
DELETE FROM
|
||||
map_grid_point
|
||||
WHERE
|
||||
<if test="gridId != null and gridId != ''">
|
||||
grid_id = #{gridId}
|
||||
</if>
|
||||
<if test="gridIds != null and gridIds.size > 0">
|
||||
grid_id IN
|
||||
<foreach collection="gridIds" index="index" open="(" separator="," close=")">
|
||||
#{gridIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</delete>
|
||||
|
||||
<!-- 删除网格关联关系 -->
|
||||
<delete id="deleteGridRelation" parameterType="map">
|
||||
DELETE FROM
|
||||
map_grid_relation
|
||||
WHERE
|
||||
<if test="gridId != null and gridId != ''">
|
||||
grid_id = #{gridId}
|
||||
</if>
|
||||
<if test="gridIds != null and gridIds.size > 0">
|
||||
grid_id IN
|
||||
<foreach collection="gridIds" index="index" open="(" separator="," close=")">
|
||||
#{gridIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="relationId != null and relationId != ''">
|
||||
relation_id = #{relationId}
|
||||
</if>
|
||||
</delete>
|
||||
|
||||
<!-- 保存网格点 -->
|
||||
<insert id="saveGridPoint" parameterType="map">
|
||||
INSERT INTO map_grid_point(
|
||||
grid_id,
|
||||
lng,
|
||||
lat
|
||||
) VALUES(
|
||||
#{gridId},
|
||||
#{lng},
|
||||
#{lat}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 获取关联关系列表 -->
|
||||
<select id="listGridRelation" parameterType="map" resultMap="gridRelationDTO">
|
||||
SELECT
|
||||
relation_id,
|
||||
grid_id
|
||||
FROM
|
||||
map_grid_relation
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="relationId != null">
|
||||
AND
|
||||
relation_id = #{relationId}
|
||||
</if>
|
||||
<if test="relationIds != null and relationIds.size > 0">
|
||||
AND
|
||||
relation_id IN
|
||||
<foreach collection="relationIds" index="index" open="(" separator="," close=")">
|
||||
#{relationIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="gridId != null and gridId != ''">
|
||||
AND
|
||||
grid_id = #{gridId}
|
||||
</if>
|
||||
<if test="gridIds != null and gridIds.size > 0">
|
||||
AND
|
||||
grid_id IN
|
||||
<foreach collection="gridIds" index="index" open="(" separator="," close=")">
|
||||
#{gridIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 获取网格列表(通过关联ID) -->
|
||||
<select id="listGridByRelationId" parameterType="java.lang.String" resultMap="gridDTO">
|
||||
SELECT
|
||||
t1.grid_id,
|
||||
t1.fill_color,
|
||||
t1.grid_name,
|
||||
t2.relation_id
|
||||
FROM
|
||||
map_grid t1
|
||||
LEFT JOIN
|
||||
map_grid_relation t2
|
||||
ON
|
||||
t1.grid_id = t2.grid_id
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t2.relation_id = #{_parameter}
|
||||
</select>
|
||||
|
||||
<select id="listGridByRelationIds" parameterType="java.util.List" resultMap="gridDTO">
|
||||
SELECT
|
||||
t1.grid_id,
|
||||
t1.fill_color,
|
||||
t1.grid_name,
|
||||
t2.relation_id
|
||||
FROM
|
||||
map_grid t1
|
||||
LEFT JOIN
|
||||
map_grid_relation t2
|
||||
ON
|
||||
t1.grid_id = t2.grid_id
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t2.relation_id IN
|
||||
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
|
||||
#{list[${index}]}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 获取网格点列表(通过网格ID) -->
|
||||
<select id="listPointByGridId" parameterType="java.lang.String" resultMap="gridPointDTO">
|
||||
SELECT
|
||||
grid_id,
|
||||
lng,
|
||||
lat
|
||||
FROM
|
||||
map_grid_point
|
||||
WHERE
|
||||
grid_id = #{_parameter}
|
||||
</select>
|
||||
|
||||
<!-- 获取网格点列表(通过网格ID列表) -->
|
||||
<select id="listPointByGridIds" parameterType="java.util.List" resultMap="gridPointDTO">
|
||||
SELECT
|
||||
grid_id,
|
||||
lng,
|
||||
lat
|
||||
FROM
|
||||
map_grid_point
|
||||
WHERE
|
||||
grid_id IN
|
||||
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
|
||||
#{list[${index}]}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,14 @@
|
||||
<!doctype html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<base th:href="${#request.getContextPath() + '/'} ">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" src="http://api.map.baidu.com/api?type=webgl&v=1.0&ak=mlfOah4gWM1FjEo9CmlI64zK6MhyiMPW"></script>
|
||||
<script type="text/javascript" src="js/baidu-map.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -182,5 +182,18 @@ public interface IApiConsts {
|
||||
* 获取所在部门用户列表(通过职位ID列表)
|
||||
*/
|
||||
String LIST_USER_DEPARTMENT_RESOURCE_BY_POSITION_IDS = "%s/resource/user/listuserdepartmentresourcebypositionids";
|
||||
/**
|
||||
* 组织部门人员分页列表
|
||||
*/
|
||||
String LIST_SELECT_DEPARTMENT_USER = "%s/resource/user/listselectdepartmentuser/%s";
|
||||
/**
|
||||
* 通过id列表获取用户ID
|
||||
*/
|
||||
String LIST_PAGE_SELECT_DEPARTMENT_USER = "%s/resource/user/listpageselectdepartmentuser/%s";
|
||||
|
||||
/**
|
||||
* 发送钉钉消息通过电话列表
|
||||
*/
|
||||
String SEND_DINGDING_MSG_BY_PHONES = "%s/resource/dingdingmessage/sendbyphones";
|
||||
|
||||
}
|
||||
|
@ -11,13 +11,16 @@ import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.exception.UpdateException;
|
||||
import com.cm.common.plugin.oauth.service.user.IUserService;
|
||||
import com.cm.common.plugin.pojo.bos.UserResourceBO;
|
||||
import com.cm.common.pojo.ListPage;
|
||||
import com.cm.common.result.ErrorResult;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import com.cm.common.result.SuccessResultList;
|
||||
import io.swagger.annotations.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -87,18 +90,6 @@ public class UserController extends AbstractController {
|
||||
return userService.listPositionUsers(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过用户ID获取用户列表", notes = "通过用户ID获取用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userIds", value = "用不ID列表", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listuserbyids/{userIds}")
|
||||
public JSONArray listUserByIds(@PathVariable("userIds") String userIds) throws AccessTokenException, SearchException {
|
||||
Map<String, Object> params = getParams();
|
||||
params.put("userIds", userIds);
|
||||
return userService.listUserByIds(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "全部用户列表", notes = "全部用户列表接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listallusers")
|
||||
@ -189,4 +180,47 @@ public class UserController extends AbstractController {
|
||||
return userService.listPageUserSimple(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门人员列表", notes = "组织部门人员列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
|
||||
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listselectdepartmentuser/{departmentId}")
|
||||
public JSONArray listSelectDepartmentUser(@PathVariable("departmentId") String departmentId) throws SearchException {
|
||||
return userService.listSelectDepartmentUser(departmentId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门人员分页列表", notes = "组织部门人员分页列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
|
||||
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpageselectdepartmentuser/{departmentId}")
|
||||
public JSONObject listPageSelectDepartmentUser(@PathVariable("departmentId") String departmentId, ListPage page) throws SearchException {
|
||||
Map<String, Object> params = requestParams();
|
||||
page.setParams(params);
|
||||
return userService.listPageSelectDepartmentUserByDepartmentId(departmentId, page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过ID列表获取用户列表", notes = "通过ID列表获取用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userIds", value = "用户ID列表,用下划线分隔,如:1_2_3", paramType = "body")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("listuserbyids")
|
||||
public JSONArray listUserByIds(@RequestBody Map<String, Object> params) throws SearchException, ParamsException {
|
||||
if (params.get("selectedUserIds") == null || StringUtils.isBlank(params.get("selectedUserIds").toString())) {
|
||||
throw new ParamsException("用户列表不能为空");
|
||||
}
|
||||
params.put("userIds", params.get("selectedUserIds"));
|
||||
params.remove("selectedUserIds");
|
||||
return userService.listUserByIds(params);
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ import com.cm.common.config.properties.OauthProperties;
|
||||
import com.cm.common.config.properties.SystemProperties;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.pojo.bos.UserInfoBO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -37,7 +38,12 @@ public class RouteController {
|
||||
ModelAndView mv = new ModelAndView("index");
|
||||
UserInfoBO userInfoBO = securityComponent.getCurrentUser();
|
||||
mv.addObject("userUsername", userInfoBO.getUserUsername());
|
||||
mv.addObject("oauthServer", oauthProperties.getOauthServer());
|
||||
// 门户URL不存在,跳转统一用户
|
||||
if (StringUtils.isBlank(systemProperties.getPortalUrl())) {
|
||||
mv.addObject("oauthServer", oauthProperties.getOauthServer());
|
||||
} else {
|
||||
mv.addObject("oauthServer", systemProperties.getPortalUrl());
|
||||
}
|
||||
mv.addObject("title", systemProperties.getTitle());
|
||||
return mv;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.cm.common.exception.AccessTokenException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.plugin.pojo.bos.UserResourceBO;
|
||||
import com.cm.common.plugin.pojo.bos.user.UserDepartmentResourceBO;
|
||||
import com.cm.common.pojo.ListPage;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import com.cm.common.result.SuccessResultList;
|
||||
import org.aspectj.lang.annotation.DeclareError;
|
||||
@ -68,17 +69,6 @@ public interface IUserService {
|
||||
@Deprecated
|
||||
JSONArray listPositionUsers(Map<String, Object> params) throws AccessTokenException, SearchException;
|
||||
|
||||
/**
|
||||
* 通过id列表获取用户ID
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws AccessTokenException
|
||||
* @throws SearchException
|
||||
*/
|
||||
@Deprecated
|
||||
JSONArray listUserByIds(Map<String, Object> params) throws AccessTokenException, SearchException;
|
||||
|
||||
/**
|
||||
* 全部用户
|
||||
*
|
||||
@ -331,4 +321,32 @@ public interface IUserService {
|
||||
*/
|
||||
List<UserDepartmentResourceBO> listUserDepartmentResourceByPositionIds(List<String> positionIds) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取选择的部门用户(插件用)
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
JSONArray listSelectDepartmentUser(String departmentId) throws AccessTokenException, SearchException;
|
||||
|
||||
/**
|
||||
* 组织部门人员分页列表(插件用)
|
||||
*
|
||||
* @param departmentId
|
||||
* @param page
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
JSONObject listPageSelectDepartmentUserByDepartmentId(String departmentId, ListPage page) throws AccessTokenException, SearchException;
|
||||
|
||||
/**
|
||||
* 通过id列表获取用户ID(插件用)
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws AccessTokenException
|
||||
* @throws SearchException
|
||||
*/
|
||||
JSONArray listUserByIds(Map<String, Object> params) throws AccessTokenException, SearchException;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import com.cm.common.plugin.oauth.token.ClientTokenManager;
|
||||
import com.cm.common.plugin.pojo.bos.UserResourceBO;
|
||||
import com.cm.common.plugin.pojo.bos.user.UserDepartmentResourceBO;
|
||||
import com.cm.common.plugin.utils.RestTemplateUtil;
|
||||
import com.cm.common.pojo.ListPage;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import com.cm.common.result.SuccessResultList;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -71,13 +72,6 @@ public class UserServiceImpl extends AbstractService implements IUserService {
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listUserByIds(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_USER_BY_ID, apiPathProperties.getUserCenter()), params);
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listAllUsers(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_ALL_USER, apiPathProperties.getUserCenter()), params);
|
||||
@ -380,4 +374,29 @@ public class UserServiceImpl extends AbstractService implements IUserService {
|
||||
searchResourceResult(result, "获取人员信息失败");
|
||||
return JSONArray.parseArray(result, UserDepartmentResourceBO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listSelectDepartmentUser(String departmentId) throws SearchException {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken());
|
||||
String result = restTemplateUtil.doGetFormNormal(String.format(IApiConsts.LIST_SELECT_DEPARTMENT_USER, apiPathProperties.getUserCenter(), departmentId), params);
|
||||
searchResourceResult(result, "获取组织部门人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject listPageSelectDepartmentUserByDepartmentId(String departmentId, ListPage page) throws SearchException {
|
||||
page.getParams().put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken());
|
||||
String result = restTemplateUtil.doGetFormNormal(String.format(IApiConsts.LIST_PAGE_SELECT_DEPARTMENT_USER, apiPathProperties.getUserCenter(), departmentId), page.getParams());
|
||||
searchResourceResult(result, "获取组织部门人员分页列表失败");
|
||||
return JSONObject.parseObject(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listUserByIds(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken());
|
||||
String result = restTemplateUtil.doPostFormNormal(String.format(IApiConsts.LIST_USER_BY_ID, apiPathProperties.getUserCenter()), params);
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
}
|
||||
|
@ -1,193 +1,337 @@
|
||||
<!doctype html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<base th:href="${#request.getContextPath() + '/'} ">
|
||||
<meta charset="UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11,chrome=1"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<link rel="stylesheet" type="text/css" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/vendor/bootstrap/css/bootstrap.min.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/easyui/themes/default/easyui.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/easyui/themes/icon.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="assets/css/minimal.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="assets/css/system.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" class="easyui-layout easyui-layout-dialog dept-selector">
|
||||
<div class="selector-title" data-options="region:'north'">
|
||||
<div id="selectUsers" class="selector-title-wrapper"></div>
|
||||
</div>
|
||||
<div class="selector-tree" data-options="region:'west',split:false,collapsible:false,border:true">
|
||||
<div class="selector-tree-wrapper">
|
||||
<ul id="leftTree" class="ztree"></ul>
|
||||
<head>
|
||||
<base th:href="${#request.getContextPath() + '/'}">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
<style>
|
||||
.user-search {width: 188px !important; display: inline;}
|
||||
.user-selected {border-left: 2px solid #009688 !important;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0;">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body" style="padding: 0px;">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs12">
|
||||
<div id="selectUsers" class="layui-btn-container selector-title-wrapper"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="selector-body" data-options="region:'center',border:true">
|
||||
<div class="selector-body-wrapper">
|
||||
<div class="selector-body-search">
|
||||
<input type="text" class="form-control" id="name" placeholder="检索用户名" oninput="searchUser()"/>
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs5">
|
||||
<div class="selector-tree-wrapper">
|
||||
<ul id="leftTree" class="ztree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs7">
|
||||
<div class="selector-body-wrapper">
|
||||
<div class="selector-body-search">
|
||||
<input type="text" id="searchUser" class="layui-input user-search" placeholder="快捷检索当前列表"/>
|
||||
<div class="layui-btn-group">
|
||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-click-select-all-user>全选</button>
|
||||
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-click-clear-all-user>清空</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="users" class="selector-body-content list-group">
|
||||
<div id="userWrapper"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="users" class="selector-body-content list-group"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="edit-button-footer2">
|
||||
<div class="col-sm-offset-4 col-sm-8">
|
||||
<button type="button" class="btn btn-primary" onclick="confirmBox()">确认</button>
|
||||
<!--
|
||||
<button type="button" class="btn btn-default" onclick="closeBox()">关闭</button>
|
||||
-->
|
||||
<div class="layui-form-item layui-layout-admin">
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-footer" style="left: 0;">
|
||||
<button type="button" class="layui-btn confirm">确认</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary close">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="selectedUserIds"/>
|
||||
<script type="text/javascript" src="assets/js/jquery-3.5.1.min.js"></script>
|
||||
<script type="text/javascript" src="assets/js/easyui/jquery.easyui.min.js"></script>
|
||||
<script type="text/javascript" src="assets/js/easyui/locale/easyui-lang-zh_CN.js"></script>
|
||||
<script type="text/javascript" src="assets/js/vendor/zTree3/js/jquery.ztree.all.js"></script>
|
||||
<script type="text/javascript" src="assets/js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var hrefParams = top.restAjax.params(window.location.href);
|
||||
$('#selectedUserIds').val(hrefParams.selectedUserIds);
|
||||
// 是否单选
|
||||
var single = hrefParams.single;
|
||||
var selectDepartmentUserArray = [];
|
||||
function closeBox() {
|
||||
top.DialogBox.closeBox();
|
||||
}
|
||||
function confirmBox() {
|
||||
top.DialogBox.dialogData.selectedDepartmentUsers = selectDepartmentUserArray;
|
||||
closeBox();
|
||||
}
|
||||
// 人员是否已经选择
|
||||
function isUserSelected(userId) {
|
||||
var isSelected = false;
|
||||
for(var i = 0, item; item = selectDepartmentUserArray[i++];) {
|
||||
if(item.userId == userId) {
|
||||
isSelected = true;
|
||||
break;
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/'
|
||||
}).extend({
|
||||
index: 'lib/index'
|
||||
}).use(['index', 'flow', 'ztree', 'common'], function() {
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var common = layui.common;
|
||||
var flow = layui.flow;
|
||||
var selectedUserIds = top.dialog.dialogData.selectedUserIds;
|
||||
var selectDepartmentUserOldArray = [];
|
||||
var selectDepartmentUserArray = [];
|
||||
var selectedParentId = 0;
|
||||
var searchTimeout;
|
||||
top.dialog.dialogData.selectedDepartmentUsers = [];
|
||||
|
||||
function closeBox() {
|
||||
top.dialog.closeBox();
|
||||
}
|
||||
function initFrame() {
|
||||
var height = $win.height() - 160;
|
||||
$('.selector-tree-wrapper').css({
|
||||
height: height +'px',
|
||||
border: '1px dotted silver'
|
||||
});
|
||||
$('.selector-body-wrapper').css({
|
||||
height: (height - 10) +'px',
|
||||
border: '1px dotted silver'
|
||||
});
|
||||
$('.selector-body-content').css({
|
||||
height: ($('.selector-body-wrapper').height() - 30) +'px'
|
||||
});
|
||||
}
|
||||
// 初始化树
|
||||
function initThree() {
|
||||
var setting = {
|
||||
async: {
|
||||
enable: true,
|
||||
autoLoad: false,
|
||||
type: 'get',
|
||||
url: top.restAjax.path('api/department/listztreedepartment', []),
|
||||
autoParam:['id'],
|
||||
otherParam:{},
|
||||
dataFilter: function(treeId, parentNode, childNodes) {
|
||||
if (!childNodes) return null;
|
||||
for (var i=0, l=childNodes.length; i<l; i++) {
|
||||
childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
|
||||
}
|
||||
return childNodes;
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: function(event, treeId, treeNode) {
|
||||
parentId = treeNode.id;
|
||||
$('#searchUser').val('');
|
||||
initUsers(treeNode.id);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
view: {
|
||||
fontCss: {'color': 'black'}
|
||||
}
|
||||
return isSelected;
|
||||
};
|
||||
var zTree = $.fn.zTree.init($('#leftTree'), setting);
|
||||
zTree.addNodes(null, {id: '0', pId: '-1', name: '未划分人员', url: 'javascript:void(0);', isParent: 'true'});
|
||||
common.refreshTree('leftTree');
|
||||
}
|
||||
// 添加人员dom
|
||||
function addUserDom(data) {
|
||||
var userDom = '';
|
||||
for(var i = 0, item; item = data[i++];) {
|
||||
var avatarDom;
|
||||
if(null == item.userAvatar || '' == item.userAvatar) {
|
||||
avatarDom = '<img class="user-avatar" src="assets/images/profile-photo.jpg"/> '
|
||||
} else {
|
||||
avatarDom = '<img class="user-avatar" src="route/file/downloadfile/false/'+ item.userAvatar +'"/> ';
|
||||
}
|
||||
userDom += '<a id="user_'+ item.userId +'" href="javascript:void(0);" class="users list-group-item '+ (isUserSelected(item.userId) ? 'user-selected' : '') +'" lay-click-user data-userid="'+ item.userId +'" data-username="'+ item.userName +'">'+ avatarDom + item.userName +' ['+ item.userUsername +']</a>';
|
||||
}
|
||||
// 删除已经选择的人员
|
||||
function removeSelectedUser(userId) {
|
||||
for(var i = 0, item; item = selectDepartmentUserArray[i]; i++) {
|
||||
if(item.userId == userId) {
|
||||
selectDepartmentUserArray.splice(i, 1);
|
||||
$('#selected_user_'+ userId).remove();
|
||||
$('#userWrapper').append(userDom);
|
||||
}
|
||||
function addSearchUserDom(data) {
|
||||
if(data.length < 1) {
|
||||
return;
|
||||
}
|
||||
var users = $('.users');
|
||||
for(var i = 0; i < data.length; i++) {
|
||||
var user = data[i];
|
||||
for(var j = 0, userItem; userItem = users[j++];) {
|
||||
if(user.userId === userItem.dataset.userid) {
|
||||
data.splice(i, 1);
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 清空已经选择的人员
|
||||
function clearSelectedUser() {
|
||||
selectDepartmentUserArray.splice(0, selectDepartmentUserArray.length);
|
||||
$('.selected_user').remove();
|
||||
}
|
||||
// 添加人员
|
||||
function addSelectedUser(userId, userName, userUsername) {
|
||||
selectDepartmentUserArray.push({
|
||||
userId: userId,
|
||||
userName: userName,
|
||||
userUsername: userUsername
|
||||
});
|
||||
$('#selectUsers').append('<a id="selected_user_'+ userId +'" href="javascript:;" class="btn btn-success btn-xs selected_user">'+ userName +' <i class="fa fa-close" onclick="removeSelectedUser(\''+ userId +'\')"></i></a>');
|
||||
}
|
||||
// 选择人员
|
||||
function selectUser(userId, userName, userUsername) {
|
||||
// 如果是单选
|
||||
if(single == 'true') {
|
||||
clearSelectedUser();
|
||||
addSelectedUser(userId, userName, userUsername);
|
||||
return;
|
||||
}
|
||||
if(!isUserSelected(userId)) {
|
||||
addSelectedUser(userId, userName, userUsername);
|
||||
var userDom = '';
|
||||
for(var i = 0, item; item = data[i++];) {
|
||||
var avatarDom;
|
||||
if(null == item.userAvatar || '' == item.userAvatar) {
|
||||
avatarDom = '<img class="user-avatar" src="assets/images/profile-photo.jpg"/> '
|
||||
} else {
|
||||
avatarDom = '<img class="user-avatar" src="route/file/downloadfile/false/'+ item.userAvatar +'"/> ';
|
||||
}
|
||||
userDom += '<a id="user_'+ item.userId +'" href="javascript:void(0);" class="users search-users list-group-item '+ (isUserSelected(item.userId) ? 'user-selected' : '') +'" lay-click-user data-userid="'+ item.userId +'" data-username="'+ item.userName +'">'+ avatarDom + item.userName +' ['+ item.userUsername +']</a>';
|
||||
}
|
||||
// 筛选人员
|
||||
function searchUser() {
|
||||
$('.users').hide().filter(":contains('" + $('#name').val() + "')").show();
|
||||
}
|
||||
// 初始化人员列表
|
||||
function initUsers(parentId) {
|
||||
var loadLayerIndex;
|
||||
top.restAjax.get(top.restAjax.path('api/user/listdepartmentusers/{parentId}', [parentId]), {}, null, function(code, data) {
|
||||
$('#users').empty();
|
||||
var userDom = '';
|
||||
for(var i = 0, item; item = data[i++];) {
|
||||
var avatarDom;
|
||||
if(null == item.userAvatar || '' == item.userAvatar) {
|
||||
avatarDom = '<img class="user-avatar" src="assets/images/profile-photo.jpg"/> '
|
||||
} else {
|
||||
avatarDom = '<img class="user-avatar" src="route/file/downloadfile/false/'+ item.userAvatar +'"/> ';
|
||||
}
|
||||
userDom += '<a id="user_'+ item.userId +'" href="javascript:;" class="users list-group-item" onclick="selectUser(\''+ item.userId +'\', \''+ item.userName +'\', \''+ item.userUsername +'\')">'+ avatarDom + item.userName +' ['+ item.userUsername +']</a>';
|
||||
}
|
||||
$('#users').append(userDom);
|
||||
}, function(code, data) {
|
||||
top.DialogBox.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.DialogBox.msg(TextMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.DialogBox.close(loadLayerIndex);
|
||||
});
|
||||
}
|
||||
// 初始化树
|
||||
function initThree() {
|
||||
var setting = {
|
||||
async: {
|
||||
enable: true,
|
||||
autoLoad: false,
|
||||
type: 'get',
|
||||
url: top.restAjax.path('api/department/listdepartments', []),
|
||||
autoParam:['id'],
|
||||
otherParam:{},
|
||||
dataFilter: function(treeId, parentNode, childNodes) {
|
||||
if (!childNodes) return null;
|
||||
for (var i=0, l=childNodes.length; i<l; i++) {
|
||||
childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
|
||||
}
|
||||
return childNodes;
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: function(event, treeId, treeNode) {
|
||||
initUsers(treeNode.id);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
view: {
|
||||
fontCss: {'color': 'black'}
|
||||
}
|
||||
};
|
||||
var zTree = $.fn.zTree.init($("#leftTree"), setting);
|
||||
zTree.addNodes(null, {id: '0', pId: '-1', name: '未划分人员', url: 'javascript:;', isParent: 'true'})
|
||||
}
|
||||
// 初始化选择的人员
|
||||
function initSelectedUsers() {
|
||||
if($('#selectedUserIds').val() != '') {
|
||||
top.restAjax.get(top.restAjax.path('api/user/listuserbyids/{selectedUserIds}', [$('#selectedUserIds').val()]), {}, null, function(code, data) {
|
||||
for(var i = 0, item; item = data[i++]; ) {
|
||||
selectUser(item.userId, item.userName, item.userUsername);
|
||||
}
|
||||
$('#userWrapper').append(userDom);
|
||||
}
|
||||
// 初始化懒加载
|
||||
function initUserFlowLoad() {
|
||||
flow.load({
|
||||
elem: '#users',
|
||||
scrollElem: '#users',
|
||||
isAuto: false,
|
||||
done: function(page, next) {
|
||||
var loadLayerIndex;
|
||||
top.restAjax.get(top.restAjax.path('api/user/listpageselectdepartmentuser/{parentId}', [selectedParentId]), {
|
||||
page: page,
|
||||
rows: 20
|
||||
}, null, function(code, data) {
|
||||
next(addUserDom(data.rows), page < (parseInt(data.total / 20) + 1));
|
||||
}, function(code, data) {
|
||||
top.DialogBox.msg(data.msg);
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.DialogBox.msg(TextMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.DialogBox.close(loadLayerIndex);
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
}
|
||||
}
|
||||
$(function() {
|
||||
$('#app').fadeTo(1000, 1);
|
||||
initThree();
|
||||
initUsers(0);
|
||||
initSelectedUsers();
|
||||
top.DialogBox.dialogData.selectedDepartmentUsers = null;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
}
|
||||
function listSearchUser(searchUser) {
|
||||
if(!searchUser) {
|
||||
return;
|
||||
}
|
||||
var loadLayerIndex;
|
||||
top.restAjax.get(top.restAjax.path('api/user/listselectdepartmentuser/{parentId}', [selectedParentId]), {
|
||||
keywords: searchUser
|
||||
}, null, function(code, data) {
|
||||
addSearchUserDom(data);
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
}
|
||||
// 初始化人员列表
|
||||
function initUsers(parentId) {
|
||||
selectedParentId = parentId;
|
||||
$('#userWrapper').empty();
|
||||
$('.layui-flow-more').remove();
|
||||
initUserFlowLoad();
|
||||
}
|
||||
// 初始化选择的人员
|
||||
function initSelectedUsers(callback) {
|
||||
if(typeof(selectedUserIds) != 'undefined' && selectedUserIds != null && selectedUserIds != '') {
|
||||
var loadLayerIndex;
|
||||
top.restAjax.post(top.restAjax.path('api/user/listuserbyids', []), {
|
||||
selectedUserIds: selectedUserIds
|
||||
}, null, function(code, data) {
|
||||
for(var i = 0, item; item = data[i++]; ) {
|
||||
selectUser(item.userId, item.userName);
|
||||
selectDepartmentUserOldArray.push({
|
||||
userId: item.userId,
|
||||
userName: item.userName
|
||||
});
|
||||
}
|
||||
callback();
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
initFrame();
|
||||
initThree();
|
||||
initSelectedUsers(function() {
|
||||
initUsers(0);
|
||||
});
|
||||
$('#searchUser').on('keyup', function() {
|
||||
var value = $(this).val();
|
||||
if(value) {
|
||||
$('.layui-flow-more').hide();
|
||||
} else {
|
||||
$('.layui-flow-more').show();
|
||||
}
|
||||
$('.users').hide().filter(":contains('" + value + "')").show();
|
||||
$('.search-users').remove();
|
||||
if(searchTimeout) {
|
||||
clearTimeout(searchTimeout);
|
||||
}
|
||||
searchTimeout = setTimeout(function() {
|
||||
listSearchUser(value);
|
||||
}, 1000);
|
||||
});
|
||||
// 人员是否已经选择
|
||||
function isUserSelected(userId) {
|
||||
var isSelected = false;
|
||||
for(var i = 0, item; item = selectDepartmentUserArray[i]; i++) {
|
||||
if(item.userId == userId) {
|
||||
isSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isSelected;
|
||||
}
|
||||
// 删除已经选择的人员
|
||||
function removeSelectedUser(userId) {
|
||||
for(var i = 0, item; item = selectDepartmentUserArray[i]; i++) {
|
||||
if(item.userId == userId) {
|
||||
selectDepartmentUserArray.splice(i, 1);
|
||||
var selectedUserDom = $('#selected_user_'+ userId);
|
||||
selectedUserDom.focus();
|
||||
selectedUserDom.remove();
|
||||
$('#user_'+ userId).removeClass('user-selected');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 选择人员
|
||||
function selectUser(userId, userName, isOnlySelect) {
|
||||
if(!isUserSelected(userId)) {
|
||||
$('#user_'+ userId).addClass('user-selected');
|
||||
selectDepartmentUserArray.push({
|
||||
userId: userId,
|
||||
userName: userName
|
||||
});
|
||||
$('#selectUsers').append('<a id="selected_user_'+ userId +'" href="javascript:void(0);" class="layui-btn layui-btn-xs">'+ userName +' <i class="fa fa-close" lay-click-removeuser data-userid="'+ userId +'"></i></a>');
|
||||
$('#selected_user_'+ userId).focus();
|
||||
} else {
|
||||
if(!isOnlySelect) {
|
||||
removeSelectedUser(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
$(document.body).on('click', '*[lay-click-user]', null, function() {
|
||||
var data = this.dataset;
|
||||
selectUser(data.userid, data.username);
|
||||
});
|
||||
$(document.body).on('click', '*[lay-click-removeuser]', null, function() {
|
||||
var data = this.dataset;
|
||||
removeSelectedUser(data.userid);
|
||||
});
|
||||
$(document.body).on('click', '*[lay-click-select-all-user]', null, function() {
|
||||
$('#userWrapper').children().each(function() {
|
||||
var data = this.dataset;
|
||||
selectUser(data.userid, data.username, true);
|
||||
});
|
||||
});
|
||||
$(document.body).on('click', '*[lay-click-clear-all-user]', null, function() {
|
||||
$('#userWrapper').children().each(function() {
|
||||
var data = this.dataset;
|
||||
removeSelectedUser(data.userid);
|
||||
});
|
||||
});
|
||||
$('.close').on('click', function() {
|
||||
// 关闭按钮返回之前的数据
|
||||
top.dialog.dialogData.selectedDepartmentUsers = selectDepartmentUserOldArray;
|
||||
top.dialog.dialogData.selectedUserIds = null;
|
||||
closeBox();
|
||||
});
|
||||
$('.confirm').on('click', function() {
|
||||
top.dialog.dialogData.selectedDepartmentUsers = selectDepartmentUserArray;
|
||||
top.dialog.dialogData.selectedUserIds = null;
|
||||
closeBox();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,9 +1,15 @@
|
||||
package com.cm.common.wechat.manager.miniapp;
|
||||
|
||||
import com.cm.common.wechat.config.pojo.WechatMiniAppProperties;
|
||||
import com.cm.common.wechat.pojo.WechatMiniAppUserInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
@ -17,11 +23,66 @@ import org.slf4j.LoggerFactory;
|
||||
public class WechatMiniAppManager {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WechatMiniAppManager.class);
|
||||
private static WechatMiniAppManager wechatMiniAppManager = WechatMiniAppManagerBuilder.wechatMiniAppManager;
|
||||
// 超时分钟
|
||||
private final int TIME_OUT_SECOND = 120 * 60;
|
||||
private WechatMiniAppProperties wechatMiniAppProperties;
|
||||
|
||||
private WechatMiniAppManager() {
|
||||
}
|
||||
|
||||
private Map<String, WechatMiniAppUserInfo> users = new ConcurrentHashMap<>();
|
||||
|
||||
public static WechatMiniAppManager getInstance() {
|
||||
return wechatMiniAppManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加用户
|
||||
*
|
||||
* @param token
|
||||
* @param wechatMiniAppUserInfo
|
||||
*/
|
||||
public void addUser(String token, WechatMiniAppUserInfo wechatMiniAppUserInfo) {
|
||||
wechatMiniAppUserInfo.setUpdateTime(System.currentTimeMillis());
|
||||
users.put(token, wechatMiniAppUserInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序应用
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public WechatMiniAppUserInfo getWechatMiniAppUserInfoByToken(String token) {
|
||||
return users.get(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除超时用户
|
||||
*/
|
||||
public void removeTimeoutUser() {
|
||||
LOG.debug("delete timeout wechat mini app user start");
|
||||
long startTime = System.currentTimeMillis();
|
||||
List<String> tokenList = new ArrayList<>();
|
||||
for (Map.Entry<String, WechatMiniAppUserInfo> kv : users.entrySet()) {
|
||||
// 超时
|
||||
if ((startTime - kv.getValue().getUpdateTime()) / 1000 > TIME_OUT_SECOND) {
|
||||
tokenList.add(kv.getKey());
|
||||
}
|
||||
}
|
||||
for (String token : tokenList) {
|
||||
users.remove(token);
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
LOG.debug("delete timeout wechat mini app user end, delete count: {}, useTime: {}ms", tokenList.size(), endTime - startTime);
|
||||
}
|
||||
|
||||
public void setWechatMiniAppProperties(WechatMiniAppProperties wechatMiniAppProperties) {
|
||||
this.wechatMiniAppProperties = wechatMiniAppProperties;
|
||||
}
|
||||
|
||||
private static class WechatMiniAppManagerBuilder {
|
||||
public static final WechatMiniAppManager wechatMiniAppManager = new WechatMiniAppManager();
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ public class WechatMiniAppUserInfo {
|
||||
private String unionid;
|
||||
private Integer errcode;
|
||||
private String errmsg;
|
||||
private long updateTime;
|
||||
|
||||
public String getOpenid() {
|
||||
return openid == null ? "" : openid;
|
||||
@ -58,6 +59,14 @@ public class WechatMiniAppUserInfo {
|
||||
this.errmsg = errmsg;
|
||||
}
|
||||
|
||||
public long getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(long updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
@ -67,10 +76,12 @@ public class WechatMiniAppUserInfo {
|
||||
.append(session_key).append('\"');
|
||||
sb.append(",\"unionid\":\"")
|
||||
.append(unionid).append('\"');
|
||||
sb.append(",\"errcode\":\"")
|
||||
.append(errcode).append('\"');
|
||||
sb.append(",\"errcode\":")
|
||||
.append(errcode);
|
||||
sb.append(",\"errmsg\":\"")
|
||||
.append(errmsg).append('\"');
|
||||
sb.append(",\"updateTime\":")
|
||||
.append(updateTime);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -0,0 +1,187 @@
|
||||
package com.cm.common.wechat.pojo;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: WechatMiniAppUserInfoDetail
|
||||
* @Description:
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/10/29 18:36
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class WechatMiniAppUserInfoDetail {
|
||||
|
||||
private String openId;
|
||||
private String nickName;
|
||||
private Integer gender;
|
||||
private String city;
|
||||
private String province;
|
||||
private String country;
|
||||
private String avatarUrl;
|
||||
private String unionId;
|
||||
private String phoneNumber;
|
||||
private String purePhoneNumber;
|
||||
private String countryCode;
|
||||
private WaterMark watermark;
|
||||
|
||||
public String getOpenId() {
|
||||
return openId == null ? "" : openId.trim();
|
||||
}
|
||||
|
||||
public void setOpenId(String openId) {
|
||||
this.openId = openId;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName == null ? "" : nickName.trim();
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public Integer getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(Integer gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city == null ? "" : city.trim();
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return province == null ? "" : province.trim();
|
||||
}
|
||||
|
||||
public void setProvince(String province) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country == null ? "" : country.trim();
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getAvatarUrl() {
|
||||
return avatarUrl == null ? "" : avatarUrl.trim();
|
||||
}
|
||||
|
||||
public void setAvatarUrl(String avatarUrl) {
|
||||
this.avatarUrl = avatarUrl;
|
||||
}
|
||||
|
||||
public String getUnionId() {
|
||||
return unionId == null ? "" : unionId.trim();
|
||||
}
|
||||
|
||||
public void setUnionId(String unionId) {
|
||||
this.unionId = unionId;
|
||||
}
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber == null ? "" : phoneNumber.trim();
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public String getPurePhoneNumber() {
|
||||
return purePhoneNumber == null ? "" : purePhoneNumber.trim();
|
||||
}
|
||||
|
||||
public void setPurePhoneNumber(String purePhoneNumber) {
|
||||
this.purePhoneNumber = purePhoneNumber;
|
||||
}
|
||||
|
||||
public String getCountryCode() {
|
||||
return countryCode == null ? "" : countryCode.trim();
|
||||
}
|
||||
|
||||
public void setCountryCode(String countryCode) {
|
||||
this.countryCode = countryCode;
|
||||
}
|
||||
|
||||
public WaterMark getWatermark() {
|
||||
return watermark;
|
||||
}
|
||||
|
||||
public void setWatermark(WaterMark watermark) {
|
||||
this.watermark = watermark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"openId\":\"")
|
||||
.append(openId).append('\"');
|
||||
sb.append(",\"nickName\":\"")
|
||||
.append(nickName).append('\"');
|
||||
sb.append(",\"gender\":")
|
||||
.append(gender);
|
||||
sb.append(",\"city\":\"")
|
||||
.append(city).append('\"');
|
||||
sb.append(",\"province\":\"")
|
||||
.append(province).append('\"');
|
||||
sb.append(",\"country\":\"")
|
||||
.append(country).append('\"');
|
||||
sb.append(",\"avatarUrl\":\"")
|
||||
.append(avatarUrl).append('\"');
|
||||
sb.append(",\"unionId\":\"")
|
||||
.append(unionId).append('\"');
|
||||
sb.append(",\"phoneNumber\":\"")
|
||||
.append(phoneNumber).append('\"');
|
||||
sb.append(",\"purePhoneNumber\":\"")
|
||||
.append(purePhoneNumber).append('\"');
|
||||
sb.append(",\"countryCode\":\"")
|
||||
.append(countryCode).append('\"');
|
||||
sb.append(",\"watermark\":")
|
||||
.append(watermark);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static class WaterMark {
|
||||
private String appid;
|
||||
private Long timestamp;
|
||||
|
||||
public String getAppid() {
|
||||
return appid == null ? "" : appid.trim();
|
||||
}
|
||||
|
||||
public void setAppid(String appid) {
|
||||
this.appid = appid;
|
||||
}
|
||||
|
||||
public Long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"appid\":\"")
|
||||
.append(appid).append('\"');
|
||||
sb.append(",\"timestamp\":")
|
||||
.append(timestamp);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -8,6 +8,7 @@ import com.cm.common.result.SuccessResultData;
|
||||
import com.cm.common.utils.AesUtil;
|
||||
import com.cm.common.utils.http.RestRequestUtil;
|
||||
import com.cm.common.wechat.config.pojo.WechatMiniAppProperties;
|
||||
import com.cm.common.wechat.manager.miniapp.WechatMiniAppManager;
|
||||
import com.cm.common.wechat.pojo.WechatMiniAppLoginVO;
|
||||
import com.cm.common.wechat.pojo.WechatMiniAppUserInfo;
|
||||
import com.cm.common.wechat.pojo.WechatOfficialAccountUserInfo;
|
||||
@ -73,10 +74,14 @@ public class WechatMiniAppAuthServiceImpl implements IWechatMiniAppAuthService {
|
||||
if (wechatMiniAppUserInfo.getErrcode() != null && wechatMiniAppUserInfo.getErrcode() != 0) {
|
||||
throw new WechatAccessTokenForUserException(String.format("获取用户信息失败,错误码:%s,错误信息:%s", wechatMiniAppUserInfo.getErrcode(), wechatMiniAppUserInfo.getErrmsg()));
|
||||
}
|
||||
|
||||
LOG.debug("绑定用户 | 登录");
|
||||
String wechatSignInfo = Base64.encodeBase64String(AesUtil.aesCommonEncoder("WECHAT_SIGN_INFO", new StringBuilder(wechatMiniAppUserInfo.getOpenid()).append("_WenG_").append(wechatMiniAppProperties.getAppKey()).toString()).getBytes("UTF-8"));
|
||||
String token = getAppToken(wechatSignInfo);
|
||||
if (token.endsWith("_0") || token.endsWith("_1")) {
|
||||
WechatMiniAppManager.getInstance().addUser(token.substring(0, token.length() - 2), wechatMiniAppUserInfo);
|
||||
} else {
|
||||
WechatMiniAppManager.getInstance().addUser(token, wechatMiniAppUserInfo);
|
||||
}
|
||||
return new SuccessResultData(token);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.cm.common.wechat.task;
|
||||
|
||||
import com.cm.common.wechat.config.pojo.WechatOfficialAccountProperties;
|
||||
import com.cm.common.wechat.manager.miniapp.WechatMiniAppManager;
|
||||
import com.cm.common.wechat.manager.officialaccount.WechatOfficialAccountManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -39,4 +40,12 @@ public class WechatTask {
|
||||
WechatOfficialAccountManager.getInstance().refreshAccessToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除小程序超时用户,每10分钟执行一次
|
||||
*/
|
||||
@Scheduled(cron = "0 0/10 * * * ?")
|
||||
public void removeTimeoutMiniAppUser() {
|
||||
WechatMiniAppManager.getInstance().removeTimeoutUser();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public class SystemProperties {
|
||||
private Integer port;
|
||||
private String url;
|
||||
private String title;
|
||||
private String portalUrl;
|
||||
private String loginPageName;
|
||||
|
||||
public Integer getPort() {
|
||||
@ -46,6 +47,14 @@ public class SystemProperties {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getPortalUrl() {
|
||||
return portalUrl == null ? "" : portalUrl.trim();
|
||||
}
|
||||
|
||||
public void setPortalUrl(String portalUrl) {
|
||||
this.portalUrl = portalUrl;
|
||||
}
|
||||
|
||||
public String getLoginPageName() {
|
||||
return loginPageName == null ? "" : loginPageName.trim();
|
||||
}
|
||||
|
@ -1,19 +1,25 @@
|
||||
package com.cm.common.utils;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.codec.binary.StringUtils;
|
||||
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.*;
|
||||
|
||||
public class AesUtil {
|
||||
|
||||
private static final String IV_STRING = "16-Bytes--String";
|
||||
/**
|
||||
* PKCS#7
|
||||
*/
|
||||
public static final String PKCS_7 = "PKCS7Padding";
|
||||
/**
|
||||
* PKCS#5
|
||||
*/
|
||||
public static final String PKCS_5 = "PKCS5Padding";
|
||||
|
||||
/**
|
||||
* AES加密
|
||||
@ -84,15 +90,30 @@ public class AesUtil {
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String aesCommonEncoder(String key, String content) throws Exception {
|
||||
byte[] encryptedBytes = aesCommonEncodeDetail(key, content, IV_STRING.getBytes(), PKCS_5);
|
||||
return new String(Base64.encodeBase64(encryptedBytes), "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用aes加密,兼容IOS
|
||||
*
|
||||
* @param key
|
||||
* @param content
|
||||
* @param paddingType
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] aesCommonEncodeDetail(String key, String content, byte[] ivBytes, String paddingType) throws Exception {
|
||||
byte[] byteContent = content.getBytes("UTF-8");
|
||||
byte[] enCodeFormat = key.getBytes();
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(enCodeFormat, "AES");
|
||||
byte[] initParam = IV_STRING.getBytes();
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(initParam);
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(ivBytes);
|
||||
if (StringUtils.equals(paddingType, PKCS_7)) {
|
||||
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
||||
}
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/" + paddingType);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec);
|
||||
byte[] encryptedBytes = cipher.doFinal(byteContent);
|
||||
return new String(Base64.encodeBase64(encryptedBytes), "UTF-8");
|
||||
return cipher.doFinal(byteContent);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,13 +126,30 @@ public class AesUtil {
|
||||
*/
|
||||
public static String aesCommonDecoder(String key, String content) throws Exception {
|
||||
byte[] encryptedBytes = Base64.decodeBase64(content);
|
||||
byte[] enCodeFormat = key.getBytes();
|
||||
SecretKeySpec secretKey = new SecretKeySpec(enCodeFormat, "AES");
|
||||
byte[] initParam = IV_STRING.getBytes();
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(initParam);
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey, ivParameterSpec);
|
||||
byte[] result = cipher.doFinal(encryptedBytes);
|
||||
byte[] keyBytes = key.getBytes();
|
||||
byte[] result = aesCommonDecoderDetail(keyBytes, encryptedBytes, IV_STRING.getBytes(), PKCS_5);
|
||||
return new String(result, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* aes cbc 通用解密
|
||||
*
|
||||
* @param keyBytes 秘钥字节数组
|
||||
* @param encryptedBytes 密文字节数组
|
||||
* @param ivBytes 向量字节数组
|
||||
* @param paddingType 填充类型
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] aesCommonDecoderDetail(byte[] keyBytes, byte[] encryptedBytes, byte[] ivBytes, String paddingType) throws Exception {
|
||||
SecretKeySpec secretKey = new SecretKeySpec(keyBytes, "AES");
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(ivBytes);
|
||||
Cipher cipher;
|
||||
if (StringUtils.equals(paddingType, PKCS_7)) {
|
||||
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
||||
}
|
||||
cipher = Cipher.getInstance("AES/CBC/" + paddingType);
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey, ivParameterSpec);
|
||||
return cipher.doFinal(encryptedBytes);
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,13 @@
|
||||
<artifactId>qcloudsms</artifactId>
|
||||
<version>1.0.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
36
cloud-manager-sms/src/test/java/SmsTest.java
Normal file
36
cloud-manager-sms/src/test/java/SmsTest.java
Normal file
@ -0,0 +1,36 @@
|
||||
import com.cm.manager.sms.config.properties.SmsDefaultProperties;
|
||||
import com.cm.manager.sms.utils.DefaultSmsUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: SmsTest
|
||||
* @Description: 短信测试
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/10/20 9:39
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class SmsTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
// 包头政法 btzfw
|
||||
// 西藏日喀则 xzrkz
|
||||
String account = "xzrkz";
|
||||
String password = "xzrkz123";
|
||||
String phone = "15147146676";
|
||||
StringBuilder contentSB = new StringBuilder("【山西腾狮科技】").append("测试短信");
|
||||
String url = "https://dx.ipyy.net/sms.aspx?action=send&userid=&account={account}&password={password}&mobile={mobile}&content={content}&sendTime=&extno={extno}";
|
||||
String[] paramArray = new String[]{
|
||||
account,
|
||||
password,
|
||||
phone,
|
||||
contentSB.toString(),
|
||||
phone
|
||||
};
|
||||
DefaultSmsUtil.sendSms(url, paramArray);
|
||||
}
|
||||
|
||||
}
|
12
pom.xml
12
pom.xml
@ -78,6 +78,7 @@
|
||||
<jna-platform.version>5.5.0</jna-platform.version>
|
||||
<spring-security-jwt.version>1.0.9.RELEASE</spring-security-jwt.version>
|
||||
<netty.version>4.1.50.Final</netty.version>
|
||||
<bouncycastle.version>1.46</bouncycastle.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖管理 -->
|
||||
@ -431,6 +432,13 @@
|
||||
<version>${netty.version}</version>
|
||||
</dependency>
|
||||
<!-- netty end -->
|
||||
<!-- bouncycastle start -->
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.56</version>
|
||||
</dependency>
|
||||
<!-- bouncycastle end -->
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
@ -438,11 +446,11 @@
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>maven-releases</id>
|
||||
<url>http://124.67.110.245:8888/repository/maven-releases/</url>
|
||||
<url>http://121.36.71.250:8888/repository/maven-releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>maven-snapshots</id>
|
||||
<url>http://124.67.110.245:8888/repository/maven-snapshots/</url>
|
||||
<url>http://121.36.71.250:8888/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user