tangzy
2021-07-23 af19c794aa23f76597bf71324ba5e739cc9f3801
1.保安公司信息新增同时添加组织机构
5 files modified
34 ■■■■■ changed files
src/main/java/org/springblade/modules/information/controller/InformationController.java 22 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/DeptMapper.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/IDeptService.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/information/controller/InformationController.java
@@ -21,13 +21,18 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.common.cache.DictCache;
import org.springblade.common.enums.DictEnum;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.support.Kv;
import org.springblade.modules.information.entity.Information;
import org.springblade.modules.information.service.IInformationService;
import org.springblade.modules.information.vo.InformationVO;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.service.IDeptService;
import org.springframework.web.bind.annotation.*;
@@ -36,6 +41,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
/**
 *  控制器
@@ -93,6 +100,21 @@
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入information")
    public R save(@Valid @RequestBody Information information) {
        Dept dept= new Dept();
        Long i = 1413470343230877697L;
        dept.setParentId(i);
        dept.setTenantId("000000");
        dept.setDeptName(information.getEnterprisename());
        dept.setAncestors("0,1413470343230877697");
        dept.setDeptCategory(1);
        if (iDeptService.submit(dept)) {
            CacheUtil.clear(SYS_CACHE);
            // 返回懒加载树更新节点所需字段
            Kv kv = Kv.create().set("id", String.valueOf(dept.getId())).set("tenantId", dept.getTenantId())
                .set("deptCategoryName", DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory()));
            String id = kv.get("id").toString();
            information.setDepartmentid(id);
        }
        return R.status(informationService.save(information));
    }
src/main/java/org/springblade/modules/system/mapper/DeptMapper.java
@@ -94,4 +94,5 @@
     */
    @SqlParser(filter=true)
    List<DeptVO> lazyTreeUser(String tenantId, @Param("parentId") Long parentId);
    Long add(Dept dept);
}
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
@@ -247,4 +247,9 @@
        SELECT id FROM blade_dept WHERE parent_id =#{id} and is_deleted = 0
    </select>
    <insert id="add" parameterType="org.springblade.modules.system.entity.Dept" useGeneratedKeys="true" keyProperty="id">
        insert into blade_dept(tenant_id, parent_id,ancestors,dept_category,dept_name) values(#{tenantId}, #{parentId}, #{ancestors}, #{deptCategory}, #{deptName})
    </insert>
</mapper>
src/main/java/org/springblade/modules/system/service/IDeptService.java
@@ -137,4 +137,5 @@
     * @return
     */
    List<DeptVO> lazyTreeUser(String tenantId, Long parentId);
    Long add(Dept dept);
}
src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java
@@ -211,4 +211,9 @@
        }
        return ForestNodeMerger.merge(baseMapper.lazyTreeUser(tenantId, parentId));
    }
    @Override
    public Long add(Dept dept) {
        return baseMapper.add(dept);
    }
}