Browse Source

Merge remote-tracking branch 'origin/develop' into develop

FengChaoYu 10 months ago
parent
commit
b767ba066a

+ 21 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/admin/AdminDeptTree.java

@@ -0,0 +1,21 @@
+package com.gree.mall.manager.bean.admin;
+
+import com.gree.mall.manager.plus.entity.AdminDept;
+import com.gree.mall.manager.plus.entity.AdminWebsit;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@ApiModel
+@Data
+public class AdminDeptTree extends AdminDept {
+
+    @ApiModelProperty(value = "是否网点")
+    private Boolean isWebsit = false;
+
+    @ApiModelProperty("children")
+    private List<AdminDeptTree> children;
+
+}

+ 53 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/admin/AdminDeptWebsitVO.java

@@ -0,0 +1,53 @@
+package com.gree.mall.manager.bean.admin;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.gree.mall.manager.annotation.ZfireField;
+import com.gree.mall.manager.plus.entity.AdminDeptWebsit;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@ApiModel
+public class AdminDeptWebsitVO   {
+
+
+    @ZfireField(hide = true)
+    @TableId(value = "admin_dept_websit_id", type = IdType.ID_WORKER_STR)
+    private String adminDeptWebsitId;
+
+    @ApiModelProperty(value = "部门名称")
+    private String deptName;
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "部门id")
+    private String adminDeptId;
+
+    @ApiModelProperty(value = "创建人")
+    @TableField(fill = FieldFill.INSERT)
+    private String createBy;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(fill = FieldFill.INSERT)
+    private Date createTime;
+
+    @ApiModelProperty(value = "更新人")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private String updateBy;
+
+    @ApiModelProperty(value = "更新时间")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Date updateTime;
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "网点商户id")
+    private String websitId;
+
+    @ApiModelProperty(value = "网点名称")
+    private String websitName;
+}

+ 4 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/admin/AdminUserBean.java

@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.util.Date;
+import java.util.List;
 
 @ApiModel
 @Data
@@ -43,6 +44,9 @@ public class AdminUserBean extends AdminUser {
     private String minLogo3;
     @ApiModelProperty("部门id")
     private String adminWebsitId;
+
+    @ApiModelProperty("部门ids")
+    private List<String> adminWebsitIds;
     @ApiModelProperty("使用小程序模板类型:  1=模板1 2=模板2")
     private Integer useTemplate;
 

+ 2 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/admin/AdminUserCom.java

@@ -2,6 +2,7 @@ package com.gree.mall.manager.bean.admin;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.gree.mall.manager.plus.entity.AdminCompanyWechat;
+import com.gree.mall.manager.plus.entity.AdminDept;
 import com.gree.mall.manager.plus.entity.AdminUser;
 import com.gree.mall.manager.plus.entity.AdminWebsit;
 import io.swagger.annotations.ApiModelProperty;
@@ -15,6 +16,7 @@ public class AdminUserCom extends AdminUser {
 
 
     private AdminWebsit adminWebsit;
+    private AdminDept adminDept;
 
     @ApiModelProperty("部门id")
     private List<String> adminWebsitIds;

+ 4 - 0
mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/AdminMapper.java

@@ -3,6 +3,7 @@ package com.gree.mall.manager.commonmapper;
 import com.baomidou.mybatisplus.annotation.SqlParser;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gree.mall.manager.bean.admin.AdminDeptWebsitVO;
 import com.gree.mall.manager.bean.admin.respDto.AdminCompanyWechatRespPageBean;
 import com.gree.mall.manager.bean.common.SysDictCompanyVO;
 import com.gree.mall.manager.bean.common.SysDictVO;
@@ -57,4 +58,7 @@ public interface AdminMapper {
      */
     @SqlParser(filter = true)
     IPage<SysDictCompanyVO> sysDictCompanyList(Page page, @Param("ex") ZfireParamBean zfireParam, List<String> companyWechatIds);
+
+    @SqlParser(filter = true)
+    IPage<AdminDeptWebsitVO> list(Page page, @Param("ex") ZfireParamBean zfireParam);
 }

+ 143 - 0
mall-server-api/src/main/java/com/gree/mall/manager/controller/admin/AdminDeptController.java

@@ -0,0 +1,143 @@
+package com.gree.mall.manager.controller.admin;
+
+import cn.hutool.core.lang.TypeReference;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gree.mall.manager.annotation.ZfireList;
+import com.gree.mall.manager.bean.admin.AdminDeptTree;
+import com.gree.mall.manager.bean.admin.AdminDeptWebsitVO;
+import com.gree.mall.manager.bean.notice.NoticeRecordReadBean;
+import com.gree.mall.manager.bean.workorder.IncreAddOrUp;
+import com.gree.mall.manager.bean.workorder.IncreVO;
+import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.helper.ResponseHelper;
+import com.gree.mall.manager.logic.admin.AdminDeptLogic;
+import com.gree.mall.manager.plus.entity.AdminDept;
+import com.gree.mall.manager.plus.entity.AdminDeptWebsit;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
+import com.gree.mall.manager.zfire.util.FieldUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.text.ParseException;
+import java.util.List;
+
+@Slf4j
+@RestController
+@Api(value = "部门级别api", tags = {"部门级别api"})
+@RequestMapping(value = "/admin/dept", produces = "application/json; charset=utf-8")
+public class AdminDeptController {
+
+    @Autowired
+    AdminDeptLogic adminDeptLogic;
+
+
+    @GetMapping("/tree")
+    @ApiOperation("部门树")
+    public ResponseHelper<AdminDeptTree> tree(HttpServletRequest request) {
+        List<AdminDeptTree> tree = adminDeptLogic.tree(request);
+        return ResponseHelper.success(tree);
+    }
+
+    @GetMapping("/treeWebsit")
+    @ApiOperation("部门树合并网点")
+    public ResponseHelper<AdminDeptTree> treeWebsit(HttpServletRequest request) {
+        List<AdminDeptTree> tree = adminDeptLogic.treeWebsit(request);
+        return ResponseHelper.success(tree);
+    }
+
+
+    @ZfireList
+    @PostMapping("/list")
+    @ApiOperation(value = "部门网点列表")
+    public ResponseHelper<IPage<AdminDeptWebsitVO>> list(
+            @RequestBody ZfireParamBean zfireParamBean
+    ) throws RemoteServiceException {
+        ZfireParamBean zfireParam = FieldUtils.supplyParam(zfireParamBean);
+        IPage<AdminDeptWebsitVO> adminDeptVOIPage = adminDeptLogic.list(new Page(zfireParam.getPageNum(), zfireParam.getPageSize()), zfireParam);
+        return ResponseHelper.success(adminDeptVOIPage, new TypeReference<AdminDeptWebsitVO>() {});
+    }
+
+    @PostMapping("/list/export")
+    @ApiOperation(value = "部门网点列表导出")
+    public void listExport(
+            @RequestBody ZfireParamBean zfireParamBean,
+            HttpServletRequest request,
+            HttpServletResponse response
+    ) throws Exception {
+        //1.组装查询条件
+        ZfireParamBean zfireParam = FieldUtils.supplyParam(zfireParamBean);
+        //2.查询要导出的内容
+        IPage<AdminDeptWebsitVO> adminDeptVOIPage = adminDeptLogic.list(new Page(zfireParam.getPageNum(), zfireParam.getPageSize()), zfireParam);
+        //3.导出
+        FieldUtils.exportData(adminDeptVOIPage.getRecords(), zfireParam.getExportFields(), request, response);
+    }
+
+
+    @PostMapping("/add")
+    @ApiOperation("添加部门")
+    public ResponseHelper add(
+            @RequestBody AdminDept adminDept,
+            HttpServletRequest request
+    ) throws ParseException {
+        adminDeptLogic.add(adminDept);
+        return ResponseHelper.success();
+    }
+
+    @PostMapping("/update")
+    @ApiOperation("修改部门")
+    public ResponseHelper update(
+            @RequestBody AdminDept adminDept,
+            HttpServletRequest request
+    ) throws ParseException {
+        adminDeptLogic.update(adminDept);
+        return ResponseHelper.success();
+    }
+
+    @PostMapping("/del")
+    @ApiOperation("删除部门")
+    public ResponseHelper update(
+            @ApiParam(value = "部门id" , required = true) @RequestParam(required = true) String adminDeptId,
+            HttpServletRequest request
+    ) throws ParseException {
+        adminDeptLogic.del(adminDeptId);
+        return ResponseHelper.success();
+    }
+
+    @PostMapping("/addWebsit")
+    @ApiOperation("添加部门网点")
+    public ResponseHelper addWebsit(
+            @RequestBody AdminDeptWebsit adminDeptWebsit,
+            HttpServletRequest request
+    ) throws ParseException {
+        adminDeptLogic.addWebsit(adminDeptWebsit);
+        return ResponseHelper.success();
+    }
+
+    @PostMapping("/updateWebsit")
+    @ApiOperation("修改部门网点")
+    public ResponseHelper updateWebsit(
+            @RequestBody AdminDeptWebsit adminDeptWebsit,
+            HttpServletRequest request
+    ) throws ParseException {
+        adminDeptLogic.updateWebsit(adminDeptWebsit);
+        return ResponseHelper.success();
+    }
+
+    @PostMapping("/delWebsit")
+    @ApiOperation("删除部门网点")
+    public ResponseHelper delWebsit(
+            @ApiParam(value = "部门网点id" , required = true) @RequestParam(required = true) String adminDeptWebsitId,
+            HttpServletRequest request
+    ) throws ParseException {
+        adminDeptLogic.delWebsit(adminDeptWebsitId);
+        return ResponseHelper.success();
+    }
+
+}

+ 168 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminDeptLogic.java

@@ -0,0 +1,168 @@
+package com.gree.mall.manager.logic.admin;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gree.mall.manager.bean.admin.AdminDeptTree;
+import com.gree.mall.manager.bean.admin.AdminDeptWebsitVO;
+import com.gree.mall.manager.bean.admin.AdminUserCom;
+import com.gree.mall.manager.bean.admin.AdminWebsitTree;
+import com.gree.mall.manager.bean.workorder.IncreVO;
+import com.gree.mall.manager.commonmapper.AdminMapper;
+import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.logic.common.CommonLogic;
+import com.gree.mall.manager.plus.entity.AdminDept;
+import com.gree.mall.manager.plus.entity.AdminDeptWebsit;
+import com.gree.mall.manager.plus.entity.AdminUserWebsitRela;
+import com.gree.mall.manager.plus.entity.AdminWebsit;
+import com.gree.mall.manager.plus.service.AdminDeptService;
+import com.gree.mall.manager.plus.service.AdminDeptWebsitService;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
+import com.gree.mall.manager.zfire.util.FieldUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class AdminDeptLogic {
+
+    @Autowired
+    CommonLogic commonLogic;
+
+    @Autowired
+    AdminDeptService adminDeptService;
+
+    @Autowired
+    AdminMapper adminMapper;
+
+    @Autowired
+    AdminDeptWebsitService adminDeptWebsitService;
+
+
+
+    public List<AdminDeptTree> tree(HttpServletRequest request) {
+
+        AdminUserCom adminUser = commonLogic.getAdminUser(request);
+
+        List<AdminDept> list = adminDeptService.lambdaQuery()
+                .eq(AdminDept::getAdminDeptId,adminUser.getAdminDept().getAdminDeptId())
+                .list();
+        List<AdminDeptTree> trees = new ArrayList<>();
+        for(AdminDept adminDept : list){
+            AdminDeptTree adminDeptTree = new AdminDeptTree();
+            BeanUtils.copyProperties(adminDept,adminDeptTree);
+            trees.add(adminDeptTree);
+        }
+
+        for(AdminDeptTree adminDeptTree:trees){
+            adminDeptTree.setChildren(this.treeModule(adminDeptTree.getAdminDeptId()));
+        }
+        return trees;
+    }
+
+    private List<AdminDeptTree> treeModule(String adminDeptId) {
+
+        //最父级资源树
+
+        List<AdminDept> collect = adminDeptService.lambdaQuery()
+                .eq(AdminDept::getPId,adminDeptId).list();
+
+        if(collect.size() == 0){
+            return null;
+        }
+
+        List<AdminDeptTree> adminDeptTrees = new ArrayList<>();
+
+        for(AdminDept bean : collect){
+            AdminDeptTree adminDeptTree = new AdminDeptTree();
+            BeanUtils.copyProperties(bean,adminDeptTree);
+            adminDeptTree.setChildren(this.treeModule(adminDeptTree.getAdminDeptId()));
+
+            adminDeptTrees.add(adminDeptTree);
+        }
+        return adminDeptTrees;
+    }
+
+    public IPage<AdminDeptWebsitVO> list(Page page, ZfireParamBean zfireParam) {
+
+        //获取当前登录企业id
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        List<String> adminCompanyIds = adminUser.getCompanyWechatIds();
+        //1.组装查询条件
+        zfireParam = FieldUtils.supplyParam(zfireParam, AdminDeptWebsitVO.class);
+
+        IPage<AdminDeptWebsitVO> adminDeptWebsitVOIPage = adminMapper.list(page, zfireParam);
+        return adminDeptWebsitVOIPage;
+    }
+
+    public void add(AdminDept adminDept) {
+        adminDept.insert();
+    }
+
+    public void update(AdminDept adminDept) {
+        adminDept.updateById();
+    }
+
+    public void del(String id) {
+        if (adminDeptWebsitService.lambdaQuery().eq(AdminDeptWebsit::getAdminDeptId,id).count() > 0)
+            throw new RemoteServiceException("存在绑定网点");
+
+        adminDeptService.removeById(id);
+    }
+
+    public void addWebsit(AdminDeptWebsit adminDeptWebsit) {
+        adminDeptWebsit.insert();
+    }
+
+    public void updateWebsit(AdminDeptWebsit adminDeptWebsit) {
+        adminDeptWebsit.updateById();
+    }
+
+    public void delWebsit(String adminDeptWebsitId) {
+        adminDeptWebsitService.removeById(adminDeptWebsitId);
+    }
+
+    public List<AdminDeptTree> treeWebsit(HttpServletRequest request) {
+
+        AdminUserCom adminUser = commonLogic.getAdminUser(request);
+
+        List<AdminDept> list = adminDeptService.lambdaQuery()
+                .eq(AdminDept::getPId,"0")
+                .list();
+        List<AdminDeptTree> trees = new ArrayList<>();
+        for(AdminDept adminDept : list){
+            AdminDeptTree adminDeptTree = new AdminDeptTree();
+            BeanUtils.copyProperties(adminDept,adminDeptTree);
+            trees.add(adminDeptTree);
+        }
+
+        for(AdminDeptTree adminDeptTree:trees){
+            adminDeptTree.setChildren(this.treeModule(adminDeptTree.getAdminDeptId()));
+
+            List<AdminDeptTree> children = adminDeptTree.getChildren();
+            for (AdminDeptTree child : children) {
+                List<AdminDeptWebsit> adminDeptWebsits = adminDeptWebsitService.lambdaQuery().eq(AdminDeptWebsit::getAdminDeptId, child.getAdminDeptId()).list();
+                for (AdminDeptWebsit adminDeptWebsit : adminDeptWebsits) {
+                    AdminDeptTree adminDeptTreeWebsit = new AdminDeptTree();
+                    adminDeptTreeWebsit.setIsWebsit(true);
+                    adminDeptTreeWebsit.setAdminDeptId(adminDeptWebsit.getWebsitId());
+                    adminDeptTreeWebsit.setDeptName(adminDeptWebsit.getWebsitName());
+
+                    child.getChildren().add(adminDeptTreeWebsit);
+
+                }
+            }
+        }
+
+
+        return trees;
+    }
+}

+ 15 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminUserLogic.java

@@ -60,6 +60,11 @@ public class AdminUserLogic {
     AdminMapper adminMapper;
     @Autowired
     BuyCompanyInfoService buyCompanyInfoService;
+    @Autowired
+    AdminUserDeptRelaService adminUserDeptRelaService;
+
+    @Autowired
+    AdminDeptWebsitService adminDeptWebsitService;
 
     @Autowired
     BigLogic bigLogic;
@@ -431,6 +436,16 @@ public class AdminUserLogic {
                 adminUserBean.setAdminWebsitId(collect.get(0));
             }
 
+            AdminUserDeptRela adminUserDeptRela = adminUserDeptRelaService.lambdaQuery()
+                    .eq(AdminUserDeptRela::getAdminUserId, adminUser.getAdminUserId()).last("limit 1").one();
+
+            if (adminUserDeptRela != null){
+                List<AdminDeptWebsit> adminDeptWebsitList = adminDeptWebsitService.lambdaQuery().eq(AdminDeptWebsit::getAdminDeptId, adminUserDeptRela.getAdminDeptId()).list();
+                List<String> collect = adminDeptWebsitList.stream().map(AdminDeptWebsit::getWebsitId).collect(Collectors.toList());
+                adminUserBean.setAdminWebsitIds(collect);
+            }
+
+
             return adminUserBean;
         }
         return adminUserBean;

+ 27 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/common/CommonLogic.java

@@ -82,6 +82,15 @@ public class CommonLogic {
     @Autowired
     OSSUtil ossUtil;
 
+    @Autowired
+    AdminDeptService adminDeptService;
+
+    @Autowired
+    AdminUserDeptRelaService adminUserDeptRelaService;
+
+    @Autowired
+    AdminDeptWebsitService adminDeptWebsitService;
+
     public Map<String, String> getOSSConfig() throws UnsupportedEncodingException {
         return ossUtil.getConfig();
     }
@@ -111,6 +120,10 @@ public class CommonLogic {
             AdminCompanyWechat adminCompanyWechat = adminCompanyWechatService.getById("1");
             adminUserCom.setAdminCompanyWechat(adminCompanyWechat);
             adminUserCom.setJoinCode(adminCompanyWechat.getJoinCode());
+
+            AdminUserDeptRela adminUserDeptRela = adminUserDeptRelaService.lambdaQuery().eq(AdminUserDeptRela::getAdminUserId, admin.getAdminUserId()).last("limit 1").one();
+            adminUserCom.setAdminDept(adminDeptService.getById(adminUserDeptRela.getAdminDeptId()));
+
             return adminUserCom;
         }
         String redisKey = RedisPrefixEnum.TOKEN_MGR.toString() + token;
@@ -137,6 +150,20 @@ public class CommonLogic {
         if(adminCompanyWechat != null){
             adminUserCom.setJoinCode(adminCompanyWechat.getJoinCode());
         }
+
+        AdminUserDeptRela adminUserDeptRela = adminUserDeptRelaService.lambdaQuery().eq(AdminUserDeptRela::getAdminUserId, adminUser.getAdminUserId()).last("limit 1").one();
+        adminUserCom.setAdminDept(adminDeptService.getById(adminUserDeptRela.getAdminDeptId()));
+
+        if (adminUserDeptRela != null){
+            List<AdminDeptWebsit> adminDeptWebsitList = adminDeptWebsitService.lambdaQuery().eq(AdminDeptWebsit::getAdminDeptId, adminUserDeptRela.getAdminDeptId()).list();
+            List<String> collect = adminDeptWebsitList.stream().map(AdminDeptWebsit::getWebsitId).collect(Collectors.toList());
+            if (!CollectionUtils.isEmpty(adminUserCom.getAdminWebsitIds())) {
+                adminUserCom.getAdminWebsitIds().addAll(collect);
+
+            }else {
+                adminUserCom.setAdminWebsitIds(collect);
+            }
+        }
         return adminUserCom;
     }
 

+ 10 - 0
mall-server-api/src/main/resources/mapper/AdminMapper.xml

@@ -105,5 +105,15 @@
         </if>
         ${ex.orderBy}
     </select>
+    <select id="list" resultType="com.gree.mall.manager.bean.admin.AdminDeptWebsitVO">
+        SELECT
+        ${ex.selected}
+        FROM admin_dept_websit a
+        ${ex.query}
+        <if test="ex.orderBy == null or ex.orderBy ==''">
+            ORDER BY a.create_time DESC
+        </if>
+        ${ex.orderBy}
+    </select>
 
 </mapper>