+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.controller;
+
+import com.elink.esua.epdc.commons.mybatis.annotation.DataFilter;
+import com.elink.esua.epdc.commons.tools.page.PageData;
+import com.elink.esua.epdc.commons.tools.utils.ExcelUtils;
+import com.elink.esua.epdc.commons.tools.utils.Result;
+import com.elink.esua.epdc.commons.tools.validator.AssertUtils;
+import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
+import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
+import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
+import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
+import com.elink.esua.epdc.dto.DeptMaCodeDTO;
+import com.elink.esua.epdc.excel.DeptMaCodeExcel;
+import com.elink.esua.epdc.service.DeptMaCodeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * 网格小程序码
+ *
+ * @author work@yujt.net.cn
+ * @since v1.0.0 2019-09-19
+ */
+@RestController
+@RequestMapping("deptmacode")
+public class DeptMaCodeController {
+
+ @Autowired
+ private DeptMaCodeService deptMaCodeService;
+
+ @GetMapping("page")
+ @DataFilter(tableAlias = "dg", deptId = "id", prefix = "AND")
+ public Result> page(@RequestParam Map params) {
+ PageData page = deptMaCodeService.page(params);
+ return new Result>().ok(page);
+ }
+
+ @GetMapping("{id}")
+ public Result get(@PathVariable("id") String id) {
+ DeptMaCodeDTO data = deptMaCodeService.get(id);
+ return new Result().ok(data);
+ }
+
+ @PostMapping
+ public Result save(@RequestBody DeptMaCodeDTO dto) {
+ //效验数据
+ ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
+ deptMaCodeService.save(dto);
+ return new Result();
+ }
+
+ @PutMapping
+ public Result update(@RequestBody DeptMaCodeDTO dto) {
+ //效验数据
+ ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
+ deptMaCodeService.update(dto);
+ return new Result();
+ }
+
+ @DeleteMapping
+ public Result delete(@RequestBody String[] ids) {
+ //效验数据
+ AssertUtils.isArrayEmpty(ids, "id");
+ deptMaCodeService.delete(ids);
+ return new Result();
+ }
+
+ @GetMapping("export")
+ public void export(@RequestParam Map params, HttpServletResponse response) throws Exception {
+ List list = deptMaCodeService.list(params);
+ ExcelUtils.exportExcelToTarget(response, null, list, DeptMaCodeExcel.class);
+ }
+
+ /**
+ * 所有部门小程序码初始化
+ *
+ * @return com.elink.esua.epdc.commons.tools.utils.Result
+ * @author work@yujt.net.cn
+ * @date 2019/9/19 09:33
+ */
+ @PostMapping("init")
+ public Result initDeptMaCode() {
+ return deptMaCodeService.initDeptMaCode();
+ }
+
+ /**
+ * 生成指定网格小程序码
+ *
+ * @param gridId
+ * @return com.elink.esua.epdc.commons.tools.utils.Result
+ * @author work@yujt.net.cn
+ * @date 2019/9/19 11:04
+ */
+ @PostMapping("create/{gridId}")
+ public Result createDeptMaCode(@PathVariable("gridId") String gridId) {
+ return deptMaCodeService.createDeptMaCode(gridId);
+ }
+
+
+}
\ No newline at end of file
diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/DeptMaCodeDao.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/DeptMaCodeDao.java
new file mode 100644
index 000000000..c5bb9c476
--- /dev/null
+++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/DeptMaCodeDao.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.dao;
+
+import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
+import com.elink.esua.epdc.dto.DeptMaCodeDTO;
+import com.elink.esua.epdc.entity.DeptMaCodeEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 网格小程序码
+ *
+ * @author work@yujt.net.cn
+ * @since v1.0.0 2019-09-19
+ */
+@Mapper
+public interface DeptMaCodeDao extends BaseDao {
+
+ /**
+ * 获取部门小程序码列表
+ *
+ * @param params
+ * @return java.util.List
+ * @author work@yujt.net.cn
+ * @date 2019/9/19 09:18
+ */
+ List selectListDeptMaCode(Map params);
+
+ /**
+ * 查询所有未生成小程序码的网格ID
+ *
+ * @param
+ * @return java.util.List
+ * @author work@yujt.net.cn
+ * @date 2019/9/19 10:38
+ */
+ List selectListNoCodeGridId();
+}
\ No newline at end of file
diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/entity/DeptMaCodeEntity.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/entity/DeptMaCodeEntity.java
new file mode 100644
index 000000000..ee301c719
--- /dev/null
+++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/entity/DeptMaCodeEntity.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 网格小程序码
+ *
+ * @author work@yujt.net.cn
+ * @since v1.0.0 2019-09-19
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("epdc_dept_ma_code")
+public class DeptMaCodeEntity extends BaseEpdcEntity {
+
+ private static final long serialVersionUID = 7851330983990440333L;
+
+ /**
+ * 网格ID
+ */
+ private Long gridId;
+
+ /**
+ * 小程序码URL
+ */
+ private String codeUrl;
+
+}
\ No newline at end of file
diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/excel/DeptMaCodeExcel.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/excel/DeptMaCodeExcel.java
new file mode 100644
index 000000000..87a1936ea
--- /dev/null
+++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/excel/DeptMaCodeExcel.java
@@ -0,0 +1,62 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *