增加数据字典mongo模块

This commit is contained in:
wanggeng 2021-11-24 18:44:34 +08:00
parent 6d401e5b06
commit 6ecbc1b492
24 changed files with 2764 additions and 0 deletions

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>wg-basic</artifactId>
<groupId>ink.wgink</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>mongo-module-dictionary</artifactId>
<description>mongo字典</description>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ink.wgink</groupId>
<artifactId>module-dictionary</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,123 @@
package ink.wgink.mongo.module.dictionary.controller.apis;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.dictionary.pojo.dtos.AreaDTO;
import ink.wgink.mongo.module.dictionary.service.IMongoAreaService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.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.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: AreaAreaController
* @Description: 地区字典
* @Author: WangGeng
* @Date: 2019/11/18 14:00
* @Version: 1.0
**/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "地区字典接口")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/mongo/area")
public class MongoAreaController extends DefaultBaseController {
@Autowired
private IMongoAreaService mongoAreaService;
@ApiOperation(value = "更新mongo", notes = "更新mongo接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("update-mongo")
public SuccessResult updateMongo() {
mongoAreaService.updateMongo();
return new SuccessResult();
}
@ApiOperation(value = "地区字典详情ID查询", notes = "地区字典详情ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "areaId", value = "地区字典ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get/{areaId}")
public AreaDTO get(@PathVariable("areaId") String areaId) {
return mongoAreaService.get(areaId);
}
@ApiOperation(value = "地区字典列表上级ID查询", notes = "地区字典列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "areaParentId", value = "地区字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list/parent-id/{areaParentId}")
public List<AreaDTO> listByParentId(@PathVariable("areaParentId") String areaParentId) {
return mongoAreaService.listByParentId(areaParentId);
}
@ApiOperation(value = "地区字典全部列表上级ID查询", notes = "地区字典全部列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "areaParentId", value = "地区字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-all/parent-id/{areaParentId}")
public List<AreaDTO> listAllByParentId(@PathVariable("areaParentId") String areaParentId) {
return mongoAreaService.listAllByParentId(areaParentId);
}
@ApiOperation(value = "地区字典分页列表", notes = "地区字典分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "parentId", value = "上级ID", paramType = "query", dataType = "String"),
@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("listpage")
public SuccessResultList<List<AreaDTO>> listPage(ListPage page) {
Map<String, Object> params = requestParams();
String parentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_PARENT_ID) == null ? null : params.get(ISystemConstant.PARAMS_PARENT_ID).toString())) {
parentId = params.get(ISystemConstant.PARAMS_PARENT_ID).toString();
}
params.put("areaParentId", parentId);
page.setParams(params);
return mongoAreaService.listPage(page);
}
@ApiOperation(value = "地区字典zTree列表", notes = "地区字典zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "父ID", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-ztree")
public List<ZTreeDTO> listZTree() {
Map<String, Object> params = requestParams();
String parentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_ID) == null ? null : params.get(ISystemConstant.PARAMS_ID).toString())) {
parentId = params.get(ISystemConstant.PARAMS_ID).toString();
}
return mongoAreaService.listZTree(parentId);
}
@ApiOperation(value = "地区字典列表(通过地区字典编码)", notes = "地区字典列表(通过地区字典编码)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "areaCode", value = "地区字典编码", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list/code/{areaCode}")
public List<AreaDTO> listByCode(@PathVariable("areaCode") String areaCode) {
return mongoAreaService.listByCode(areaCode);
}
}

View File

@ -0,0 +1,123 @@
package ink.wgink.mongo.module.dictionary.controller.apis;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.dictionary.pojo.dtos.DataDTO;
import ink.wgink.mongo.module.dictionary.service.IMongoDataService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.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.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: DataController
* @Description: 字典
* @Author: WangGeng
* @Date: 2019/11/18 14:00
* @Version: 1.0
**/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "字典接口")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/mongo/data")
public class MongoDataController extends DefaultBaseController {
@Autowired
private IMongoDataService mongoDataService;
@ApiOperation(value = "更新mongo", notes = "更新mongo接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("update-mongo")
public SuccessResult updateMongo() {
mongoDataService.updateMongo();
return new SuccessResult();
}
@ApiOperation(value = "字典详情ID查询", notes = "字典详情ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "Id", value = "字典ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get/{Id}")
public DataDTO get(@PathVariable("Id") String Id) {
return mongoDataService.get(Id);
}
@ApiOperation(value = "字典列表上级ID查询", notes = "字典列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "ParentId", value = "字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list/parent-id/{dataParentId}")
public List<DataDTO> listByParentId(@PathVariable("dataParentId") String dataParentId) {
return mongoDataService.listByParentId(dataParentId);
}
@ApiOperation(value = "字典全部列表上级ID查询", notes = "字典全部列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "ParentId", value = "字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-all/parent-id/{dataParentId}")
public List<DataDTO> listAllByParentId(@PathVariable("dataParentId") String dataParentId) {
return mongoDataService.listAllByParentId(dataParentId);
}
@ApiOperation(value = "字典分页列表", notes = "字典分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "parentId", value = "上级ID", paramType = "query", dataType = "String"),
@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("listpage")
public SuccessResultList<List<DataDTO>> listPage(ListPage page) {
Map<String, Object> params = requestParams();
String parentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_PARENT_ID) == null ? null : params.get(ISystemConstant.PARAMS_PARENT_ID).toString())) {
parentId = params.get(ISystemConstant.PARAMS_PARENT_ID).toString();
}
params.put("dataParentId", parentId);
page.setParams(params);
return mongoDataService.listPage(page);
}
@ApiOperation(value = "字典zTree列表", notes = "字典zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "父ID", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-ztree")
public List<ZTreeDTO> listZTree() {
Map<String, Object> params = requestParams();
String dataParentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_ID) == null ? null : params.get(ISystemConstant.PARAMS_ID).toString())) {
dataParentId = params.get(ISystemConstant.PARAMS_ID).toString();
}
return mongoDataService.listZTree(dataParentId);
}
@ApiOperation(value = "字典列表(通过字典编码)", notes = "字典列表(通过字典编码)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "Code", value = "字典编码", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list/code/{Code}")
public List<DataDTO> listByCode(@PathVariable("Code") String Code) {
return mongoDataService.listByCode(Code);
}
}

View File

@ -0,0 +1,164 @@
package ink.wgink.mongo.module.dictionary.controller.app.apis;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.dictionary.pojo.dtos.AreaDTO;
import ink.wgink.mongo.module.dictionary.service.IMongoAreaService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.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.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: AreaAreaAppController
* @Description: 地区字典
* @Author: WangGeng
* @Date: 2019/11/18 14:00
* @Version: 1.0
**/
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "地区字典管理接口")
@RestController
@RequestMapping(ISystemConstant.APP_PREFIX + "/mongo/area")
public class MongoAreaAppController extends DefaultBaseController {
@Autowired
private IMongoAreaService mongoAreaService;
@ApiOperation(value = "地区字典详情ID查询", notes = "地区字典详情ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "areaId", value = "地区字典ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get/{areaId}")
public AreaDTO get(@RequestHeader("token") String token, @PathVariable("areaId") String areaId) {
return getRelease(areaId);
}
@ApiOperation(value = ISystemConstant.API_TAGS_RELEASE_PREFIX + "地区字典详情ID查询", notes = ISystemConstant.API_TAGS_RELEASE_PREFIX + "地区字典详情ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "areaId", value = "地区字典ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get" + ISystemConstant.RELEASE_SUFFIX + "/{areaId}")
public AreaDTO getRelease(@PathVariable("areaId") String areaId) {
return mongoAreaService.get(areaId);
}
@ApiOperation(value = "地区字典列表上级ID查询", notes = "地区字典列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "areaParentId", value = "地区字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list/parent-id/{areaParentId}")
public List<AreaDTO> listByParentId(@RequestHeader("token") String token, @PathVariable("areaParentId") String areaParentId) {
return listByParentIdRelease(areaParentId);
}
@ApiOperation(value = ISystemConstant.API_TAGS_RELEASE_PREFIX + "地区字典列表上级ID查询", notes = ISystemConstant.API_TAGS_RELEASE_PREFIX + "地区字典列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "areaParentId", value = "地区字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list/parent-id-" + ISystemConstant.RELEASE_SUFFIX + "/{areaParentId}")
public List<AreaDTO> listByParentIdRelease(@PathVariable("areaParentId") String areaParentId) {
return mongoAreaService.listByParentId(areaParentId);
}
@ApiOperation(value = "地区字典全部列表上级ID查询", notes = "地区字典全部列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "areaParentId", value = "地区字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-all/parent-id/{areaParentId}")
public List<AreaDTO> list(@RequestHeader("token") String token, @PathVariable("areaParentId") String areaParentId) {
return listAllByParentIdRelease(areaParentId);
}
@ApiOperation(value = ISystemConstant.API_TAGS_RELEASE_PREFIX + "地区字典全部列表上级ID查询", notes = ISystemConstant.API_TAGS_RELEASE_PREFIX + "地区字典全部列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "areaParentId", value = "地区字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-all/parent-id-" + ISystemConstant.RELEASE_SUFFIX + "/{areaParentId}")
public List<AreaDTO> listAllByParentIdRelease(@PathVariable("areaParentId") String areaParentId) {
return mongoAreaService.listAllByParentId(areaParentId);
}
@ApiOperation(value = "分页地区字典列表", notes = "分页地区字典列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "parentId", value = "上级ID", paramType = "query", dataType = "String"),
@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("listpage")
public SuccessResultList<List<AreaDTO>> listPage(@RequestHeader("token") String token, ListPage page) {
return listPageRelease(page);
}
@ApiOperation(value = ISystemConstant.API_TAGS_RELEASE_PREFIX + "分页地区字典列表", notes = ISystemConstant.API_TAGS_RELEASE_PREFIX + "分页地区字典列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "parentId", value = "上级ID", paramType = "query", dataType = "String"),
@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("listpage" + ISystemConstant.RELEASE_SUFFIX)
public SuccessResultList<List<AreaDTO>> listPageRelease(ListPage page) {
Map<String, Object> params = requestParams();
String areaParentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_PARENT_ID) == null ? null : params.get(ISystemConstant.PARAMS_PARENT_ID).toString())) {
areaParentId = params.get(ISystemConstant.PARAMS_PARENT_ID).toString();
}
params.put("areaParentId", areaParentId);
page.setParams(params);
return mongoAreaService.listPage(page);
}
@ApiOperation(value = "zTree列表", notes = "zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "id", value = "父ID", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-ztree")
public List<ZTreeDTO> listZTree(@RequestHeader("token") String token) {
return listZTreeRelease();
}
@ApiOperation(value = ISystemConstant.API_TAGS_RELEASE_PREFIX + "zTree列表", notes = ISystemConstant.API_TAGS_RELEASE_PREFIX + "zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "父ID", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-ztree-" + ISystemConstant.RELEASE_SUFFIX)
public List<ZTreeDTO> listZTreeRelease() {
Map<String, Object> params = requestParams();
String areaParentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_ID) == null ? null : params.get(ISystemConstant.PARAMS_ID).toString())) {
areaParentId = params.get(ISystemConstant.PARAMS_ID).toString();
}
return mongoAreaService.listZTree(areaParentId);
}
}

View File

@ -0,0 +1,164 @@
package ink.wgink.mongo.module.dictionary.controller.app.apis;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.dictionary.pojo.dtos.DataDTO;
import ink.wgink.mongo.module.dictionary.service.IMongoDataService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.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.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: DictionaryController
* @Description: 字典
* @Author: WangGeng
* @Date: 2019/11/18 14:00
* @Version: 1.0
**/
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "字典管理接口")
@RestController
@RequestMapping(ISystemConstant.APP_PREFIX + "/mongo/data")
public class MongoDataAppController extends DefaultBaseController {
@Autowired
private IMongoDataService mongoDataService;
@ApiOperation(value = "字典详情ID查询", notes = "字典详情ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "dataId", value = "字典ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get/{dataId}")
public DataDTO get(@RequestHeader("token") String token, @PathVariable("dataId") String dataId) {
return getByIdRelease(dataId);
}
@ApiOperation(value = ISystemConstant.API_TAGS_RELEASE_PREFIX + "字典详情ID查询", notes = ISystemConstant.API_TAGS_RELEASE_PREFIX + "字典详情ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "dataId", value = "字典ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get/id-" + ISystemConstant.RELEASE_SUFFIX + "/{dataId}")
public DataDTO getByIdRelease(@PathVariable("dataId") String dataId) {
return mongoDataService.get(dataId);
}
@ApiOperation(value = "字典列表上级ID查询", notes = "字典列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "dataParentId", value = "字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list/parent-id/{dataParentId}")
public List<DataDTO> listByParentId(@RequestHeader("token") String token, @PathVariable("dataParentId") String dataParentId) {
return listByParentIdRelease(dataParentId);
}
@ApiOperation(value = ISystemConstant.API_TAGS_RELEASE_PREFIX + "字典列表上级ID查询", notes = ISystemConstant.API_TAGS_RELEASE_PREFIX + "字典列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "dataParentId", value = "字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list/parent-id-" + ISystemConstant.RELEASE_SUFFIX + "/{dataParentId}")
public List<DataDTO> listByParentIdRelease(@PathVariable("dataParentId") String dataParentId) {
return mongoDataService.listByParentId(dataParentId);
}
@ApiOperation(value = "字典全部列表上级ID查询", notes = "字典全部列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "dataParentId", value = "字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-all/parent-id/{dataParentId}")
public List<DataDTO> listAllByParentId(@RequestHeader("token") String token, @PathVariable("dataParentId") String dataParentId) {
return listAllByParentIdRelease(dataParentId);
}
@ApiOperation(value = ISystemConstant.API_TAGS_RELEASE_PREFIX + "字典全部列表上级ID查询", notes = ISystemConstant.API_TAGS_RELEASE_PREFIX + "字典全部列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "dataParentId", value = "字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-all/parent-id-" + ISystemConstant.RELEASE_SUFFIX + "/{dataParentId}")
public List<DataDTO> listAllByParentIdRelease(@PathVariable("dataParentId") String dataParentId) {
return mongoDataService.listAllByParentId(dataParentId);
}
@ApiOperation(value = "分页字典列表", notes = "分页字典列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "parentId", value = "上级ID", paramType = "query", dataType = "String"),
@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("listpage")
public SuccessResultList<List<DataDTO>> listPage(@RequestHeader("token") String token, ListPage page) {
return listPageRelease(page);
}
@ApiOperation(value = ISystemConstant.API_TAGS_RELEASE_PREFIX + "分页字典列表", notes = ISystemConstant.API_TAGS_RELEASE_PREFIX + "分页字典列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "parentId", value = "上级ID", paramType = "query", dataType = "String"),
@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("listpage-" + ISystemConstant.RELEASE_SUFFIX)
public SuccessResultList<List<DataDTO>> listPageRelease(ListPage page) {
Map<String, Object> params = requestParams();
String dataParentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_PARENT_ID) == null ? null : params.get(ISystemConstant.PARAMS_PARENT_ID).toString())) {
dataParentId = params.get(ISystemConstant.PARAMS_PARENT_ID).toString();
}
params.put("dataParentId", dataParentId);
page.setParams(params);
return mongoDataService.listPage(page);
}
@ApiOperation(value = "zTree列表", notes = "zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "id", value = "父ID", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listztree")
public List<ZTreeDTO> listZTree(@RequestHeader("token") String token) {
return listZTreeRelease();
}
@ApiOperation(value = ISystemConstant.API_TAGS_RELEASE_PREFIX + "zTree列表", notes = ISystemConstant.API_TAGS_RELEASE_PREFIX + "zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "父ID", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-ztree-" + ISystemConstant.RELEASE_SUFFIX)
public List<ZTreeDTO> listZTreeRelease() {
Map<String, Object> params = requestParams();
String dataParentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_ID) == null ? null : params.get(ISystemConstant.PARAMS_ID).toString())) {
dataParentId = params.get(ISystemConstant.PARAMS_ID).toString();
}
return mongoDataService.listZTree(dataParentId);
}
}

View File

@ -0,0 +1,50 @@
package ink.wgink.mongo.module.dictionary.controller.route;
import ink.wgink.interfaces.consts.ISystemConstant;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: IDataDictionaryRouteController
* @Description: 数据字典
* @Author: WangGeng
* @Date: 2019/12/6 16:52
* @Version: 1.0
**/
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "地区字典页面接口")
@Controller
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/mongo/area")
public class MongoAreaRouteController {
@GetMapping("list-tree")
public ModelAndView listTree() {
return new ModelAndView("mongo/area/list-tree");
}
@GetMapping("list-tree-mongo")
public ModelAndView listTreeMongo() {
return new ModelAndView("mongo/area/list-tree-mongo");
}
@GetMapping("list")
public ModelAndView list() {
return new ModelAndView("mongo/area/list");
}
@GetMapping("list-mongo")
public ModelAndView listMongo() {
return new ModelAndView("mongo/area/list-mongo");
}
@GetMapping("get-select")
public ModelAndView getSelect() {
return new ModelAndView("mongo/area/get-select");
}
}

View File

@ -0,0 +1,42 @@
package ink.wgink.mongo.module.dictionary.controller.route;
import ink.wgink.interfaces.consts.ISystemConstant;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
/**
* @ClassName: IDataDictionaryRouteController
* @Description: 数据字典
* @Author: WangGeng
* @Date: 2019/12/6 16:52
* @Version: 1.0
**/
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "数据字典页面接口")
@Controller
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/mongo/data")
public class MongoDataRouteController {
@GetMapping("list-tree")
public ModelAndView listTree() {
return new ModelAndView("mongo/data/list-tree");
}
@GetMapping("list-tree-mongo")
public ModelAndView listTreeMongo() {
return new ModelAndView("mongo/data/list-tree-mongo");
}
@GetMapping("list")
public ModelAndView list() {
return new ModelAndView("mongo/data/list");
}
@GetMapping("list-mongo")
public ModelAndView listMongo() {
return new ModelAndView("mongo/data/list-mongo");
}
}

View File

@ -0,0 +1,107 @@
package ink.wgink.mongo.module.dictionary.controller.wechat;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.dictionary.pojo.dtos.AreaDTO;
import ink.wgink.mongo.module.dictionary.service.IMongoAreaService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.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.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: AreaAreaWechatController
* @Description: 微信数据地区字典
* @Author: WangGeng
* @Date: 2020/3/8 9:47 上午
* @Version: 1.0
**/
@Api(tags = ISystemConstant.API_TAGS_WECHAT_PREFIX + "地区字典管理接口")
@RestController
@RequestMapping(ISystemConstant.WECHAT_PREFIX + "/mongo/area")
public class MongoAreaWechatController extends DefaultBaseController {
@Autowired
private IMongoAreaService mongoAreaService;
@ApiOperation(value = "地区字典详情ID查询", notes = "地区字典详情ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "areaId", value = "地区字典ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get/{areaId}")
public AreaDTO get(@PathVariable("areaId") String areaId) {
return mongoAreaService.get(areaId);
}
@ApiOperation(value = "地区字典列表上级ID查询", notes = "地区字典列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "areaParentId", value = "地区字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list/parent-id/{areaParentId}")
public List<AreaDTO> listByParentId(@PathVariable("areaParentId") String areaParentId) {
return mongoAreaService.listByParentId(areaParentId);
}
@ApiOperation(value = "地区字典全部列表上级ID查询", notes = "地区字典全部列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "areaParentId", value = "地区字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-all/parent-id/{areaParentId}")
public List<AreaDTO> listAllByParentId(@PathVariable("areaParentId") String areaParentId) {
return mongoAreaService.listAllByParentId(areaParentId);
}
@ApiOperation(value = "分页地区字典列表", notes = "分页地区字典列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "parentId", value = "上级ID", paramType = "query", dataType = "String"),
@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("listpage")
public SuccessResultList<List<AreaDTO>> listPage(ListPage page) {
Map<String, Object> params = requestParams();
String areaParentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_PARENT_ID) == null ? null : params.get(ISystemConstant.PARAMS_PARENT_ID).toString())) {
areaParentId = params.get(ISystemConstant.PARAMS_PARENT_ID).toString();
}
params.put("areaParentId", areaParentId);
page.setParams(params);
return mongoAreaService.listPage(page);
}
@ApiOperation(value = "zTree列表", notes = "zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "父ID", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-ztree")
public List<ZTreeDTO> listZTree() {
Map<String, Object> params = requestParams();
String areaParentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_ID) == null ? null : params.get(ISystemConstant.PARAMS_ID).toString())) {
areaParentId = params.get(ISystemConstant.PARAMS_ID).toString();
}
return mongoAreaService.listZTree(areaParentId);
}
}

View File

@ -0,0 +1,115 @@
package ink.wgink.mongo.module.dictionary.controller.wechat;
import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.dictionary.pojo.dtos.DataDTO;
import ink.wgink.module.dictionary.pojo.vos.AreaVO;
import ink.wgink.mongo.module.dictionary.service.IMongoDataService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.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.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: DataWechatController
* @Description: 微信数据字典
* @Author: WangGeng
* @Date: 2020/3/8 9:47 上午
* @Version: 1.0
**/
@Api(tags = ISystemConstant.API_TAGS_WECHAT_PREFIX + "字典管理接口")
@RestController
@RequestMapping(ISystemConstant.WECHAT_PREFIX + "/mongo/data")
public class MongoDataWechatController extends DefaultBaseController {
@Autowired
private IMongoDataService mongoDataService;
@ApiOperation(value = "更新mongo", notes = "更新mongo接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("update-mongo")
public SuccessResult updateMongo() {
mongoDataService.updateMongo();
return new SuccessResult();
}
@ApiOperation(value = "字典详情ID查询", notes = "字典详情ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "dataId", value = "字典ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get/{dataId}")
public DataDTO get(@PathVariable("dataId") String dataId) {
return mongoDataService.get(dataId);
}
@ApiOperation(value = "字典列表上级ID查询", notes = "字典列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "dataParentId", value = "字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list/parent-id/{dataParentId}")
public List<DataDTO> listByParentId(@PathVariable("dataParentId") String dataParentId) {
return mongoDataService.listByParentId(dataParentId);
}
@ApiOperation(value = "字典全部列表上级ID查询", notes = "字典全部列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "dataParentId", value = "字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-all/parent-id/{dataParentId}")
public List<DataDTO> listAllByParentId(@PathVariable("dataParentId") String dataParentId) {
return mongoDataService.listAllByParentId(dataParentId);
}
@ApiOperation(value = "分页字典列表", notes = "分页字典列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "parentId", value = "上级ID", paramType = "query", dataType = "String"),
@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("listpage")
public SuccessResultList<List<DataDTO>> listPage(ListPage page) {
Map<String, Object> params = requestParams();
String dataParentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_PARENT_ID) == null ? null : params.get(ISystemConstant.PARAMS_PARENT_ID).toString())) {
dataParentId = params.get(ISystemConstant.PARAMS_PARENT_ID).toString();
}
params.put("dataParentId", dataParentId);
page.setParams(params);
return mongoDataService.listPage(page);
}
@ApiOperation(value = "zTree列表", notes = "zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "父ID", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-ztree")
public List<ZTreeDTO> listZTree() {
Map<String, Object> params = requestParams();
String dataParentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_ID) == null ? null : params.get(ISystemConstant.PARAMS_ID).toString())) {
dataParentId = params.get(ISystemConstant.PARAMS_ID).toString();
}
return mongoDataService.listZTree(dataParentId);
}
}

View File

@ -0,0 +1,30 @@
package ink.wgink.mongo.module.dictionary.enums;
/**
* @ClassName: MongoDictionaryCollectionEnum
* @Description:
* @Author: wanggeng
* @Date: 2021/11/19 10:45 上午
* @Version: 1.0
*/
public enum MongoDictionaryCollectionEnum {
DATA("dictionaryData", "数据字典"),
AREA("dictionaryArea", "地区字典");
private String value;
private String summary;
MongoDictionaryCollectionEnum(String value, String summary) {
this.value = value;
this.summary = summary;
}
public String getValue() {
return value == null ? "" : value.trim();
}
public String getSummary() {
return summary == null ? "" : summary.trim();
}
}

View File

@ -0,0 +1,91 @@
package ink.wgink.mongo.module.dictionary.service;
import ink.wgink.module.dictionary.pojo.dtos.AreaDTO;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.result.SuccessResultList;
import java.util.List;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: IAreaAreaService
* @Description: 地区字典
* @Author: WangGeng
* @Date: 2019/11/18 14:09
* @Version: 1.0
**/
public interface IMongoAreaService {
/**
* 更新mongo
*/
void updateMongo();
/**
* 通过ID获取地区字典
*
* @param areaId
* @return
*/
AreaDTO get(String areaId);
/**
* 通过编码获取地区字典详情
*
* @param areaCode
* @return
*/
AreaDTO getByCode(String areaCode);
/**
* 通过上级ID获取地区字典列表
*
* @param areaParentId
* @return
*/
List<AreaDTO> listByParentId(String areaParentId);
/**
* 通过上级ID获取地区字典全部列表
*
* @param areaParentId
* @return
*/
List<AreaDTO> listAllByParentId(String areaParentId);
/**
* 分页获取地区字典列表
*
* @param page
* @return
*/
SuccessResultList<List<AreaDTO>> listPage(ListPage page);
/**
* zTree列表
*
* @param areaParentId
* @return
*/
List<ZTreeDTO> listZTree(String areaParentId);
/**
* 地区字典列表通过地区字典编码
*
* @param areaCode 地区编码
* @return
*/
List<AreaDTO> listByCode(String areaCode);
/**
* 地区字典子列表不包含本级
*
* @param areaCode 地区编码
* @return
*/
List<AreaDTO> listSubByCode(String areaCode);
}

View File

@ -0,0 +1,75 @@
package ink.wgink.mongo.module.dictionary.service;
import ink.wgink.module.dictionary.pojo.dtos.DataDTO;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.result.SuccessResultList;
import java.util.List;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: IDictionaryService
* @Description: 字典
* @Author: WangGeng
* @Date: 2019/11/18 14:09
* @Version: 1.0
**/
public interface IMongoDataService {
/**
* 更新mongo
*/
void updateMongo();
/**
* 通过ID获取字典
*
* @param dataId
* @return
*/
DataDTO get(String dataId);
/**
* 通过上级ID获取字典列表
*
* @param dataParentId
* @return
*/
List<DataDTO> listByParentId(String dataParentId);
/**
* 通过上级ID获取字典全部列表
*
* @param dataParentId
* @return
*/
List<DataDTO> listAllByParentId(String dataParentId);
/**
* 分页获取字典列表
*
* @param page
* @return
*/
SuccessResultList<List<DataDTO>> listPage(ListPage page);
/**
* zTree列表
*
* @param dataParentId
* @return
*/
List<ZTreeDTO> listZTree(String dataParentId);
/**
* 字典列表通过字典编码
*
* @param dataCode
* @return
*/
List<DataDTO> listByCode(String dataCode);
}

View File

@ -0,0 +1,126 @@
package ink.wgink.mongo.module.dictionary.service.impl;
import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.module.dictionary.pojo.dtos.AreaDTO;
import ink.wgink.module.dictionary.service.IAreaService;
import ink.wgink.mongo.module.dictionary.enums.MongoDictionaryCollectionEnum;
import ink.wgink.mongo.module.dictionary.service.IMongoAreaService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.util.string.WStringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
/**
* @ClassName: AreaServiceImpl
* @Description: 字典
* @Author: WangGeng
* @Date: 2019/11/18 14:09
* @Version: 1.0
**/
@Service
public class MongoAreaServiceImpl extends DefaultBaseService implements IMongoAreaService {
@Autowired
private IAreaService areaService;
@Autowired
private MongoTemplate mongoTemplate;
@Override
public void updateMongo() {
List<AreaDTO> dataDTOs = areaService.list();
mongoTemplate.remove(new Query(), MongoDictionaryCollectionEnum.AREA.getValue());
mongoTemplate.insert(dataDTOs, MongoDictionaryCollectionEnum.AREA.getValue());
}
@Override
public AreaDTO get(String areaId) {
return mongoTemplate.findOne(Query.query(Criteria.where("areaId").is(areaId)), AreaDTO.class, MongoDictionaryCollectionEnum.AREA.getValue());
}
@Override
public AreaDTO getByCode(String areaCode) {
return mongoTemplate.findOne(Query.query(Criteria.where("areaCode").is(areaCode)), AreaDTO.class, MongoDictionaryCollectionEnum.AREA.getValue());
}
@Override
public List<AreaDTO> listByParentId(String areaParentId) {
return mongoTemplate.find(Query.query(Criteria.where("areaParentId").is(areaParentId)), AreaDTO.class, MongoDictionaryCollectionEnum.AREA.getValue());
}
@Override
public List<AreaDTO> listAllByParentId(String areaParentId) {
List<AreaDTO> areaDTOs = listByParentId(areaParentId);
listSub(areaDTOs);
return areaDTOs;
}
@Override
public SuccessResultList<List<AreaDTO>> listPage(ListPage page) {
Query query = new Query();
String keywords = getKeywords(page.getParams());
if (!StringUtils.isBlank(keywords)) {
Pattern pattern = Pattern.compile("^.*" + keywords + ".*$", Pattern.CASE_INSENSITIVE);
query.addCriteria(Criteria.where("areaName").regex(pattern));
}
long total = mongoTemplate.count(query, MongoDictionaryCollectionEnum.AREA.getValue());
query.with(Pageable.ofSize(page.getRows()).withPage(page.getPage() - 1));
List<AreaDTO> dataDTOs = mongoTemplate.find(query, AreaDTO.class, MongoDictionaryCollectionEnum.AREA.getValue());
return new SuccessResultList<>(dataDTOs, page.getPage(), total);
}
@Override
public List<ZTreeDTO> listZTree(String areaParentId) {
List<AreaDTO> areaDTOs = listByParentId(areaParentId);
List<ZTreeDTO> zTreeDTOs = new ArrayList<>();
for (AreaDTO areaDTO : areaDTOs) {
ZTreeDTO zTreeDTO = new ZTreeDTO();
zTreeDTO.setId(areaDTO.getAreaId());
zTreeDTO.setpId(areaDTO.getAreaParentId());
zTreeDTO.setName(areaDTO.getAreaName());
long subCount = mongoTemplate.count(Query.query(Criteria.where("areaParentId").is(areaDTO.getAreaId())), MongoDictionaryCollectionEnum.AREA.getValue());
setZTreeInfo(zTreeDTO, subCount);
zTreeDTOs.add(zTreeDTO);
}
return zTreeDTOs;
}
@Override
public List<AreaDTO> listByCode(String areaCode) {
Pattern pattern = Pattern.compile("^" + areaCode + ".*$", Pattern.CASE_INSENSITIVE);
return mongoTemplate.find(Query.query(Criteria.where("areaCode").regex(pattern)), AreaDTO.class, MongoDictionaryCollectionEnum.AREA.getValue());
}
@Override
public List<AreaDTO> listSubByCode(String areaCode) {
Pattern pattern = Pattern.compile("^" + WStringUtil.cutContinuityRepeatCharDesc(areaCode, '0') + ".*$", Pattern.CASE_INSENSITIVE);
Query query = new Query();
query.addCriteria(Criteria.where("areaCode").regex(pattern));
query.addCriteria(Criteria.where("areaCode").ne(areaCode));
return mongoTemplate.find(query, AreaDTO.class, MongoDictionaryCollectionEnum.AREA.getValue());
}
/**
* 递归查询子组
*
* @param areaDTOs
*/
private void listSub(List<AreaDTO> areaDTOs) {
for (AreaDTO areaDTO : areaDTOs) {
List<AreaDTO> subAreaDTOs = listByParentId(areaDTO.getAreaId());
areaDTO.setSubArea(subAreaDTOs);
listSub(subAreaDTOs);
}
}
}

View File

@ -0,0 +1,111 @@
package ink.wgink.mongo.module.dictionary.service.impl;
import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.module.dictionary.pojo.dtos.DataDTO;
import ink.wgink.module.dictionary.service.IDataService;
import ink.wgink.mongo.module.dictionary.enums.MongoDictionaryCollectionEnum;
import ink.wgink.mongo.module.dictionary.service.IMongoDataService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.result.SuccessResultList;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
/**
* @ClassName: DictionaryServiceImpl
* @Description: 字典
* @Author: WangGeng
* @Date: 2019/11/18 14:09
* @Version: 1.0
**/
@Service
public class MongoDataServiceImpl extends DefaultBaseService implements IMongoDataService {
@Autowired
private IDataService dataService;
@Autowired
private MongoTemplate mongoTemplate;
@Override
public void updateMongo() {
List<DataDTO> dataDTOs = dataService.list();
mongoTemplate.remove(new Query(), MongoDictionaryCollectionEnum.DATA.getValue());
mongoTemplate.insert(dataDTOs, MongoDictionaryCollectionEnum.DATA.getValue());
}
@Override
public DataDTO get(String dataId) {
return mongoTemplate.findOne(Query.query(Criteria.where("dataId").is(dataId)), DataDTO.class, MongoDictionaryCollectionEnum.DATA.getValue());
}
@Override
public List<DataDTO> listByParentId(String dataParentId) {
return mongoTemplate.find(Query.query(Criteria.where("dataParentId").is(dataParentId)), DataDTO.class, MongoDictionaryCollectionEnum.DATA.getValue());
}
@Override
public List<DataDTO> listAllByParentId(String dataParentId) {
List<DataDTO> dataDTOs = listByParentId(dataParentId);
listSub(dataDTOs);
return dataDTOs;
}
@Override
public SuccessResultList<List<DataDTO>> listPage(ListPage page) {
Query query = new Query(Criteria.where("dataParentId").is(page.getParams().get("dataParentId").toString()));
String keywords = getKeywords(page.getParams());
if (!StringUtils.isBlank(keywords)) {
Pattern pattern = Pattern.compile("^.*" + keywords + ".*$", Pattern.CASE_INSENSITIVE);
query.addCriteria(Criteria.where("dataName").regex(pattern));
}
long total = mongoTemplate.count(query, MongoDictionaryCollectionEnum.DATA.getValue());
query.with(Pageable.ofSize(page.getRows()).withPage(page.getPage() - 1));
List<DataDTO> dataDTOs = mongoTemplate.find(query, DataDTO.class, MongoDictionaryCollectionEnum.DATA.getValue());
return new SuccessResultList<>(dataDTOs, page.getPage(), total);
}
@Override
public List<ZTreeDTO> listZTree(String dataParentId) {
List<DataDTO> dataDTOs = listByParentId(dataParentId);
List<ZTreeDTO> zTreeDTOs = new ArrayList<>();
for (DataDTO dataDTO : dataDTOs) {
ZTreeDTO zTreeDTO = new ZTreeDTO();
zTreeDTO.setId(dataDTO.getDataId());
zTreeDTO.setpId(dataDTO.getDataParentId());
zTreeDTO.setName(dataDTO.getDataName());
long subCount = mongoTemplate.count(Query.query(Criteria.where("dataParentId").is(dataDTO.getDataId())), MongoDictionaryCollectionEnum.DATA.getValue());
setZTreeInfo(zTreeDTO, subCount);
zTreeDTOs.add(zTreeDTO);
}
return zTreeDTOs;
}
@Override
public List<DataDTO> listByCode(String dataCode) {
Pattern pattern = Pattern.compile("^" + dataCode + ".*$", Pattern.CASE_INSENSITIVE);
return mongoTemplate.find(Query.query(Criteria.where("dataCode").regex(pattern)), DataDTO.class, MongoDictionaryCollectionEnum.DATA.getValue());
}
/**
* 递归查询子组
*
* @param dataDTOs
*/
private void listSub(List<DataDTO> dataDTOs) {
for (DataDTO dataDTO : dataDTOs) {
List<DataDTO> subDataDTOs = listByParentId(dataDTO.getDataId());
dataDTO.setSubData(subDataDTOs);
listSub(subDataDTOs);
}
}
}

View File

@ -0,0 +1,288 @@
<!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">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.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>
.layui-form-selected dl {max-height: 100px;}
</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: 15px;">
<form class="layui-form" lay-filter="dataForm">
<div class="layui-row">
<div class="layui-col-xs2">
<div class="layui-form-item">
<div id="area1IdSelectTemplateBox" lay-filter="area1IdSelectTemplateBox"></div>
<script id="area1IdSelectTemplate" type="text/html">
<select id="area1Id" name="area1Id" lay-filter="area1Id" lay-search>
<option value="">1级区域</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.areaId}}_{{item.areaCode}}_{{item.areaName}}">{{item.areaName}}</option>
{{# } }}
</select>
</script>
</div>
</div>
<div class="layui-col-xs2">
<div class="layui-form-item">
<div id="area2IdSelectTemplateBox" lay-filter="area2IdSelectTemplateBox"></div>
<script id="area2IdSelectTemplate" type="text/html">
<select id="area2Id" name="area2Id" lay-filter="area2Id" lay-search>
<option value="">2级区域</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.areaId}}_{{item.areaCode}}_{{item.areaName}}">{{item.areaName}}</option>
{{# } }}
</select>
</script>
</div>
</div>
<div class="layui-col-xs2">
<div class="layui-form-item">
<div id="area3IdSelectTemplateBox" lay-filter="area3IdSelectTemplateBox"></div>
<script id="area3IdSelectTemplate" type="text/html">
<select id="area3Id" name="area3Id" lay-filter="area3Id" lay-search>
<option value="">3级区域</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.areaId}}_{{item.areaCode}}_{{item.areaName}}">{{item.areaName}}</option>
{{# } }}
</select>
</script>
</div>
</div>
<div class="layui-col-xs2">
<div class="layui-form-item">
<div id="area4IdSelectTemplateBox" lay-filter="area4IdSelectTemplateBox"></div>
<script id="area4IdSelectTemplate" type="text/html">
<select id="area4Id" name="area4Id" lay-filter="area4Id" lay-search>
<option value="">4级区域</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.areaId}}_{{item.areaCode}}_{{item.areaName}}">{{item.areaName}}</option>
{{# } }}
</select>
</script>
</div>
</div>
<div class="layui-col-xs2">
<div class="layui-form-item">
<div id="area5IdSelectTemplateBox" lay-filter="area5IdSelectTemplateBox"></div>
<script id="area5IdSelectTemplate" type="text/html">
<select id="area5Id" name="area5Id" lay-filter="area5Id" lay-search>
<option value="">5级区域</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.areaId}}_{{item.areaCode}}_{{item.areaName}}">{{item.areaName}}</option>
{{# } }}
</select>
</script>
</div>
</div>
<div class="layui-col-xs2">
<button id="confirmBtn" type="button" class="layui-btn" style="width: 100%;">确定</button>
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs12">
<fieldset class="layui-elem-field layui-field-title">
<legend>当前地区</legend>
<div class="layui-field-box" id="currentAreaName"></div>
</fieldset>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laytpl'], function(){
top.dialog.dialogData.selectedAreaArray = [];
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var defaultAreaName = top.restAjax.params(window.location.href).areaName;
var selectedAreaArray = [];
function closeBox() {
top.dialog.dialogData.selectedAreaArray = selectedAreaArray;
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 显示选择地区
function showAreaName() {
if(selectedAreaArray.length == 0) {
$('#currentAreaName').text(defaultAreaName ? decodeURI(defaultAreaName) : '无');
return;
}
var areaNames = '';
for(var i = 0, item; item = selectedAreaArray[i++];) {
if(areaNames.length > 0) {
areaNames += ' / ';
}
areaNames += item.areaName;
}
$('#currentAreaName').text(areaNames);
}
// 初始化选择框、单选、复选模板
function initSelectRadioCheckboxTemplate(templateId, templateBoxId, data, callback) {
laytpl(document.getElementById(templateId).innerHTML).render(data, function(html) {
document.getElementById(templateBoxId).innerHTML = html;
});
form.render('select');
if(callback) {
callback();
}
}
// 初始化1级区域下拉选择
function initArea1CodeSelect() {
top.restAjax.get(top.restAjax.path('api/area/listbyparentid/0', []), {}, null, function(code, data, args) {
initSelectRadioCheckboxTemplate('area1IdSelectTemplate', 'area1IdSelectTemplateBox', data);
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化2级区域下拉选择
function initArea2CodeSelect(area1) {
if(!area1) {
initSelectRadioCheckboxTemplate('area2IdSelectTemplate', 'area2IdSelectTemplateBox', []);
return;
}
top.restAjax.get(top.restAjax.path('api/area/listbyparentid/{area1}', [area1]), {}, null, function(code, data, args) {
initSelectRadioCheckboxTemplate('area2IdSelectTemplate', 'area2IdSelectTemplateBox', data);
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化3级区域下拉选择
function initArea3CodeSelect(area2) {
if(!area2) {
initSelectRadioCheckboxTemplate('area3IdSelectTemplate', 'area3IdSelectTemplateBox', []);
return;
}
top.restAjax.get(top.restAjax.path('api/area/listbyparentid/{area2}', [area2]), {}, null, function(code, data, args) {
initSelectRadioCheckboxTemplate('area3IdSelectTemplate', 'area3IdSelectTemplateBox', data);
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化4级区域下拉选择
function initArea4CodeSelect(area3) {
if(!area3) {
initSelectRadioCheckboxTemplate('area4IdSelectTemplate', 'area4IdSelectTemplateBox', []);
return;
}
top.restAjax.get(top.restAjax.path('api/area/listbyparentid/{area3}', [area3]), {}, null, function(code, data, args) {
initSelectRadioCheckboxTemplate('area4IdSelectTemplate', 'area4IdSelectTemplateBox', data);
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化5级区域下拉选择
function initArea5CodeSelect(area4) {
if(!area4) {
initSelectRadioCheckboxTemplate('area5IdSelectTemplate', 'area5IdSelectTemplateBox', []);
return;
}
top.restAjax.get(top.restAjax.path('api/area/listbyparentid/{area4}', [area4]), {}, null, function(code, data, args) {
initSelectRadioCheckboxTemplate('area5IdSelectTemplate', 'area5IdSelectTemplateBox', data);
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化
function initData() {
initArea1CodeSelect();
initArea2CodeSelect();
initArea3CodeSelect();
initArea4CodeSelect();
initArea5CodeSelect();
}
initData();
showAreaName();
// 获取地区ID
function getAreaId(areaLevel, data) {
var areaId = data.value;
var index = areaLevel - 1;
if(areaId) {
var valueArray = data.value.split('_');
areaId = valueArray[0];
// 结果存在,替换,不存在新增
if(!selectedAreaArray[index]) {
selectedAreaArray.push({
areaId: valueArray[0],
areaCode: valueArray[1],
areaName: valueArray[2]
});
} else {
selectedAreaArray.splice(index, 1, {
areaId: valueArray[0],
areaCode: valueArray[1],
areaName: valueArray[2]
});
}
} else {
selectedAreaArray.splice(index, selectedAreaArray.length);
}
showAreaName();
return areaId;
}
// area1Id 选择事件
form.on('select(area1Id)', function(data) {
var areaId = getAreaId(1, data);
initArea2CodeSelect(areaId);
initArea3CodeSelect();
initArea4CodeSelect();
initArea5CodeSelect();
});
// area2Id 选择事件
form.on('select(area2Id)', function(data) {
var areaId = getAreaId(2, data);
initArea3CodeSelect(areaId);
initArea4CodeSelect();
initArea5CodeSelect();
});
// area3Id 选择事件
form.on('select(area3Id)', function(data) {
var areaId = getAreaId(3, data);
initArea4CodeSelect(areaId);
initArea5CodeSelect();
});
// area4Id 选择事件
form.on('select(area4Id)', function(data) {
var areaId = getAreaId(4, data);
initArea5CodeSelect(areaId);
});
// area5Id 选择事件
form.on('select(area5Id)', function(data) {
getAreaId(5, data);
});
$('#confirmBtn').on('click', function() {
closeBox();
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,121 @@
<!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">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0;">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入名称">
</div>
<div class="layui-btn-group">
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
</div>
</div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
</div>
</div>
</div>
</div>
</div>
<input type="hidden" id="areaParentId" th:value="${areaParentId}">
<script src="assets/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'table', 'laydate', 'ztree'], function() {
var $ = layui.$;
var $win = $(window);
var table = layui.table;
var admin = layui.admin;
var laydate = layui.laydate;
var parentId = top.restAjax.params(window.location.href).parentId;
var tableUrl = top.restAjax.path('api/mongo/area/listpage?parentId={parentId}', [parentId]);
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: tableUrl,
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 60,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
request: {
pageName: 'page',
limitName: 'rows'
},
cols: [
[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field:'areaId', width:120, title: '地区ID', align:'center',},
{field:'areaName', width:160, title: '地区名称', align:'center',},
{field:'areaCode', width:160, title: '地区编码', align:'center',},
{field:'areaCityCode', width:160, title: '城市编码', align:'center',},
{field:'areaMergerName', width:160, title: '合并名称', align:'center',},
{field:'areaShortName', width:160, title: '简称', align:'center',},
{field:'areaZipCode', width:160, title: '邮政编码', align:'center',},
{field:'areaLevel', width:60, title: '级别', align:'center',},
{field:'areaLng', width:160, title: '地区经度', align:'center',},
{field:'areaLat', width:160, title: '地区纬度', align:'center',},
{field:'areaPinyin', width:160, title: '拼音', align:'center',},
{field:'areaFirst', width:80, title: '首字母', align:'center',},
]
],
page: true,
parseData: function(data) {
return {
'code': 0,
'msg': '',
'count': data.total,
'data': data.rows
};
}
});
}
// 重载表格
function reloadTable() {
table.reload('dataTable', {
url: tableUrl,
where: {
keywords: $('#keywords').val(),
},
height: $win.height() - 60,
});
}
// 初始化日期
function initDate() {}
initTable();
initDate();
// 事件 - 页面变化
$win.on('resize', function() {
reloadTable();
});
// 事件 - 搜索
$(document).on('click', '#search', function() {
reloadTable();
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,106 @@
<!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">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
<link rel="stylesheet" href="assets/layuiadmin/style/common.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row layui-col-space15">
<div class="layui-col-md2 layui-col-sm2 layui-col-xs2">
<div class="layui-card">
<div class="layui-card-body left-tree-wrap">
<div id="leftTreeWrap">
<ul id="leftTree" class="ztree"></ul>
</div>
</div>
</div>
</div>
<div class="layui-col-md10 layui-col-sm10 layui-col-xs10">
<div class="layui-card">
<div id="listContentWrap" class="layui-card-body">
<iframe id="listContent" frameborder="0" class="layadmin-iframe"></iframe>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
var common;
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'ztree', 'common'], function() {
common = layui.common;
var $ = layui.$;
var $win = $(window);
var resizeTimeout = null;
var parentId = 0;
// 初始化IFrame
function initIFrame() {
$('#listContent').attr('src', top.restAjax.path('route/mongo/area/list-mongo?parentId={parentId}', [parentId]));
}
// 初始化大小
function initSize() {
$('#leftTreeWrap').css({
height: $win.height() - 30,
overflow: 'auto'
});
$('#listContentWrap').css({
height: $win.height() - 50,
});
}
// 初始化树
function initThree() {
var setting = {
async: {
enable: true,
autoLoad: true,
type: 'get',
url: top.restAjax.path('api/mongo/area/list-ztree', []),
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;
initIFrame();
return false;
}
},
};
var zTree = $.fn.zTree.init($("#leftTree"), setting);
}
initSize();
initIFrame();
initThree();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
initSize();
}, 500);
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,114 @@
<!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">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
<link rel="stylesheet" href="assets/layuiadmin/style/common.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row layui-col-space15">
<div class="layui-col-md2 layui-col-sm2 layui-col-xs2">
<div class="layui-card">
<div class="layui-card-body left-tree-wrap">
<div id="leftTreeWrap">
<ul id="leftTree" class="ztree"></ul>
</div>
</div>
</div>
</div>
<div class="layui-col-md10 layui-col-sm10 layui-col-xs10">
<div class="layui-card">
<div id="listContentWrap" class="layui-card-body">
<iframe id="listContent" frameborder="0" class="layadmin-iframe"></iframe>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
var common;
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'ztree', 'common'], function() {
common = layui.common;
var $ = layui.$;
var $win = $(window);
var resizeTimeout = null;
var parentId = 0;
// 初始化IFrame
function initIFrame() {
$('#listContent').attr('src', top.restAjax.path('route/mongo/area/list?parentId={parentId}', [parentId]));
}
// 初始化大小
function initSize() {
$('#leftTreeWrap').css({
height: $win.height() - 30,
overflow: 'auto'
});
$('#listContentWrap').css({
height: $win.height() - 50,
});
}
// 初始化树
function initThree() {
var setting = {
async: {
enable: true,
autoLoad: false,
type: 'get',
url: top.restAjax.path('api/area/listztree', []),
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;
initIFrame();
return false;
}
},
};
var zTree = $.fn.zTree.init($("#leftTree"), setting);
zTree.addNodes(null, {
id: '0',
pId: '-1',
name: top.dataMessage.tree.rootName,
url: 'javascript:;',
isParent: 'true'
});
common.refreshTree('leftTree');
}
initSize();
initIFrame();
initThree();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
initSize();
}, 500);
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,227 @@
<!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">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0;">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入名称">
</div>
<div class="layui-btn-group">
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
<button type="button" id="updateMongo" class="layui-btn layui-btn-sm layui-btn-primary">更新MONGO</button>
</div>
</div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
<!-- 表头按钮地区 -->
<script type="text/html" id="headerToolBar">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" lay-event="save">
<i class="fa fa-lg fa-plus"></i> 新增
</button>
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="update">
<i class="fa fa-lg fa-edit"></i> 编辑
</button>
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="remove">
<i class="fa fa-lg fa-trash"></i> 删除
</button>
</div>
</script>
</div>
</div>
</div>
</div>
</div>
<input type="hidden" id="areaParentId" th:value="${areaParentId}">
<script src="assets/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'table', 'laydate', 'ztree'], function() {
var $ = layui.$;
var $win = $(window);
var table = layui.table;
var admin = layui.admin;
var laydate = layui.laydate;
var parentId = top.restAjax.params(window.location.href).parentId;
var tableUrl = top.restAjax.path('api/area/listpage?parentId={parentId}', [parentId]);
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: tableUrl,
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 60,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
request: {
pageName: 'page',
limitName: 'rows'
},
cols: [
[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field:'areaId', width:120, title: '地区ID', align:'center',},
{field:'areaName', width:160, title: '地区名称', align:'center',},
{field:'areaCode', width:160, title: '地区编码', align:'center',},
{field:'areaCityCode', width:160, title: '城市编码', align:'center',},
{field:'areaMergerName', width:160, title: '合并名称', align:'center',},
{field:'areaShortName', width:160, title: '简称', align:'center',},
{field:'areaZipCode', width:160, title: '邮政编码', align:'center',},
{field:'areaLevel', width:60, title: '级别', align:'center',},
{field:'areaLng', width:160, title: '地区经度', align:'center',},
{field:'areaLat', width:160, title: '地区纬度', align:'center',},
{field:'areaPinyin', width:160, title: '拼音', align:'center',},
{field:'areaFirst', width:80, title: '首字母', align:'center',},
]
],
page: true,
parseData: function(data) {
return {
'code': 0,
'msg': '',
'count': data.total,
'data': data.rows
};
}
});
}
// 重载表格
function reloadTable() {
table.reload('dataTable', {
url: tableUrl,
where: {
keywords: $('#keywords').val(),
},
height: $win.height() - 60,
});
}
// 初始化日期
function initDate() {}
// 删除
function removeData(ids) {
top.dialog.msg(top.dataMessage.delete, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function (index) {
top.dialog.close(index);
var layIndex;
top.restAjax.delete(top.restAjax.path('api/area/remove/{ids}', [ids]), {}, null, function (code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000}, function () {
parent.common.refreshTree('leftTree');
reloadTable();
});
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
});
}
initTable();
initDate();
// 事件 - 页面变化
$win.on('resize', function() {
reloadTable();
});
// 事件 - 搜索
$(document).on('click', '#search', function() {
reloadTable();
});
$('#updateMongo').on('click', function() {
var loadLayerIndex;
top.dialog.confirm('确认同步?', function(index) {
top.dialog.close(index);
top.restAjax.put(top.restAjax.path('api/mongo/area/update-mongo', []), {}, null, function(code, data) {
top.dialog.msg('同步成功');
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg('正在同步...', {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
})
});
});
// 事件 - 增删改
table.on('toolbar(dataTable)', function(obj) {
var layEvent = obj.event;
var checkStatus = table.checkStatus('dataTable');
var checkDatas = checkStatus.data;
if(layEvent === 'save') {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/area/save?areaParentId={parentId}', [parentId]),
end: function() {
reloadTable();
}
});
} else if(layEvent === 'update') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectEdit);
} else if(checkDatas.length > 1) {
top.dialog.msg(top.dataMessage.table.selectOneEdit);
} else {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/area/update?areaId={areaId}', [checkDatas[0].areaId]),
end: function() {
reloadTable();
}
});
}
} else if(layEvent === 'remove') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectDelete);
} else {
var ids = '';
for(var i = 0, item; item = checkDatas[i++];) {
if(i > 1) {
ids += '_';
}
ids += item.areaId;
}
removeData(ids);
}
}
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,111 @@
<!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">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0;">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入名称">
</div>
<div class="layui-btn-group">
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
</div>
</div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'table', 'laydate', 'ztree'], function() {
var $ = layui.$;
var $win = $(window);
var table = layui.table;
var admin = layui.admin;
var laydate = layui.laydate;
var parentId = top.restAjax.params(window.location.href).parentId;
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path('api/mongo/data/listpage?parentId={parentId}', [parentId]),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 60,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
request: {
pageName: 'page',
limitName: 'rows'
},
cols: [
[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field:'dataId', width:200, title: '字典ID', align:'center',},
{field:'dataName', width:160, title: '字典名称', align:'center',},
{field:'dataSummary', width:160, title: '字典说明', align:'center',},
{field:'dataCode', width:160, title: '字典编码', align:'center',},
{field:'dataSort', width:100, title: '字典排序', align:'center',},
]
],
page: true,
parseData: function(data) {
return {
'code': 0,
'msg': '',
'count': data.total,
'data': data.rows
};
}
});
}
// 重载表格
function reloadTable() {
table.reload('dataTable', {
where: {
keywords: $('#keywords').val(),
},
height: $win.height() - 60,
});
}
// 初始化日期
function initDate() {}
initTable();
initDate();
// 事件 - 页面变化
$win.on('resize', function() {
reloadTable();
});
// 事件 - 搜索
$(document).on('click', '#search', function() {
reloadTable();
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,106 @@
<!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">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
<link rel="stylesheet" href="assets/layuiadmin/style/common.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row layui-col-space15">
<div class="layui-col-md2 layui-col-sm2 layui-col-xs2">
<div class="layui-card">
<div class="layui-card-body left-tree-wrap">
<div id="leftTreeWrap">
<ul id="leftTree" class="ztree"></ul>
</div>
</div>
</div>
</div>
<div class="layui-col-md10 layui-col-sm10 layui-col-xs10">
<div class="layui-card">
<div id="listContentWrap" class="layui-card-body">
<iframe id="listContent" frameborder="0" class="layadmin-iframe"></iframe>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
var common;
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'ztree', 'common'], function() {
common = layui.common;
var $ = layui.$;
var $win = $(window);
var resizeTimeout = null;
var parentId = 0;
// 初始化IFrame
function initIFrame() {
$('#listContent').attr('src', top.restAjax.path('route/mongo/data/list-mongo?parentId={parentId}', [parentId]));
}
// 初始化大小
function initSize() {
$('#leftTreeWrap').css({
height: $win.height() - 30,
overflow: 'auto'
});
$('#listContentWrap').css({
height: $win.height() - 50,
});
}
// 初始化树
function initThree() {
var setting = {
async: {
enable: true,
autoLoad: true,
type: 'get',
url: top.restAjax.path('api/mongo/data/list-ztree', []),
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;
initIFrame();
return false;
}
},
};
var zTree = $.fn.zTree.init($("#leftTree"), setting);
}
initSize();
initIFrame();
initThree();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
initSize();
}, 500);
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,114 @@
<!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">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
<link rel="stylesheet" href="assets/layuiadmin/style/common.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row layui-col-space15">
<div class="layui-col-md2 layui-col-sm2 layui-col-xs2">
<div class="layui-card">
<div class="layui-card-body left-tree-wrap">
<div id="leftTreeWrap">
<ul id="leftTree" class="ztree"></ul>
</div>
</div>
</div>
</div>
<div class="layui-col-md10 layui-col-sm10 layui-col-xs10">
<div class="layui-card">
<div id="listContentWrap" class="layui-card-body">
<iframe id="listContent" frameborder="0" class="layadmin-iframe"></iframe>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
var common;
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'ztree', 'common'], function() {
common = layui.common;
var $ = layui.$;
var $win = $(window);
var resizeTimeout = null;
var parentId = 0;
// 初始化IFrame
function initIFrame() {
$('#listContent').attr('src', top.restAjax.path('route/mongo/data/list?parentId={parentId}', [parentId]));
}
// 初始化大小
function initSize() {
$('#leftTreeWrap').css({
height: $win.height() - 30,
overflow: 'auto'
});
$('#listContentWrap').css({
height: $win.height() - 50,
});
}
// 初始化树
function initThree() {
var setting = {
async: {
enable: true,
autoLoad: false,
type: 'get',
url: top.restAjax.path('api/data/listztree', []),
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;
initIFrame();
return false;
}
},
};
var zTree = $.fn.zTree.init($("#leftTree"), setting);
zTree.addNodes(null, {
id: '0',
pId: '-1',
name: top.dataMessage.tree.rootName,
url: 'javascript:;',
isParent: 'true'
});
common.refreshTree('leftTree');
}
initSize();
initIFrame();
initThree();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
initSize();
}, 500);
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,217 @@
<!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">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0;">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入名称">
</div>
<div class="layui-btn-group">
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
<button type="button" id="updateMongo" class="layui-btn layui-btn-sm layui-btn-primary">更新MONGO</button>
</div>
</div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
<!-- 表头按钮字典 -->
<script type="text/html" id="headerToolBar">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" lay-event="save">
<i class="fa fa-lg fa-plus"></i> 新增
</button>
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="update">
<i class="fa fa-lg fa-edit"></i> 编辑
</button>
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="remove">
<i class="fa fa-lg fa-trash"></i> 删除
</button>
</div>
</script>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'table', 'laydate', 'ztree'], function() {
var $ = layui.$;
var $win = $(window);
var table = layui.table;
var admin = layui.admin;
var laydate = layui.laydate;
var parentId = top.restAjax.params(window.location.href).parentId;
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path('api/data/listpage?parentId={parentId}', [parentId]),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 60,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
request: {
pageName: 'page',
limitName: 'rows'
},
cols: [
[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field:'dataId', width:200, title: '字典ID', align:'center',},
{field:'dataName', width:160, title: '字典名称', align:'center',},
{field:'dataSummary', width:160, title: '字典说明', align:'center',},
{field:'dataCode', width:160, title: '字典编码', align:'center',},
{field:'dataSort', width:100, title: '字典排序', align:'center',},
]
],
page: true,
parseData: function(data) {
return {
'code': 0,
'msg': '',
'count': data.total,
'data': data.rows
};
}
});
}
// 重载表格
function reloadTable() {
table.reload('dataTable', {
where: {
keywords: $('#keywords').val(),
},
height: $win.height() - 60,
});
}
// 初始化日期
function initDate() {}
// 删除
function removeData(ids) {
top.dialog.msg(top.dataMessage.delete, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function (index) {
top.dialog.close(index);
var layIndex;
top.restAjax.delete(top.restAjax.path('api/data/remove/{ids}', [ids]), {}, null, function (code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000}, function () {
parent.common.refreshTree('leftTree');
reloadTable();
});
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
});
}
initTable();
initDate();
// 事件 - 页面变化
$win.on('resize', function() {
reloadTable();
});
// 事件 - 搜索
$(document).on('click', '#search', function() {
reloadTable();
});
$('#updateMongo').on('click', function() {
var loadLayerIndex;
top.dialog.confirm('确认同步?', function(index) {
top.dialog.close(index);
top.restAjax.put(top.restAjax.path('api/mongo/data/update-mongo', []), {}, null, function(code, data) {
top.dialog.msg('同步成功');
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg('正在同步...', {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
})
});
});
// 事件 - 增删改
table.on('toolbar(dataTable)', function(obj) {
var layEvent = obj.event;
var checkStatus = table.checkStatus('dataTable');
var checkDatas = checkStatus.data;
if(layEvent === 'save') {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/data/save?dataParentId={parentId}', [parentId]),
end: function() {
reloadTable();
}
});
} else if(layEvent === 'update') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectEdit);
} else if(checkDatas.length > 1) {
top.dialog.msg(top.dataMessage.table.selectOneEdit);
} else {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/data/update?dataId={dataId}', [checkDatas[0].dataId]),
end: function() {
reloadTable();
}
});
}
} else if(layEvent === 'remove') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectDelete);
} else {
var ids = '';
for(var i = 0, item; item = checkDatas[i++];) {
if(i > 1) {
ids += '_';
}
ids += item.dataId;
}
removeData(ids);
}
}
});
});
</script>
</body>
</html>

10
pom.xml
View File

@ -40,6 +40,7 @@
<module>module-instant-message</module>
<module>login-oauth2-client</module>
<module>module-oauth2-client</module>
<module>mongo-module-dictionary</module>
</modules>
<packaging>pom</packaging>
@ -90,6 +91,7 @@
<activiti.version>6.0.0</activiti.version>
<xmlgraphics.version>1.10</xmlgraphics.version>
<minio.version>7.0.2</minio.version>
<mongo.version>3.2.5</mongo.version>
</properties>
<dependencyManagement>
@ -514,6 +516,14 @@
<version>${minio.version}</version>
</dependency>
<!-- minio end -->
<!-- mongo start -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>${mongo.version}</version>
</dependency>
<!-- mongo end -->
</dependencies>
</dependencyManagement>