hym 4 роки тому
батько
коміт
02ec857340

+ 84 - 0
sms_water/src/main/java/com/huaxu/dao/OrgMapper.java

@@ -0,0 +1,84 @@
+package com.huaxu.dao;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.huaxu.entity.Org;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 组织(Org)表数据库访问层
+ *
+ * @author makejava
+ * @since 2020-11-19 09:55:20
+ */
+@Mapper
+public interface OrgMapper {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    Org selectById(Integer id);
+
+
+    /**
+     * 查询全部
+     *
+     * @return 对象列表
+     */
+    List<Org> selectAll();
+
+    /**
+     * 通过实体作为筛选条件查询
+     *
+     * @param org 实例对象
+     * @return 对象列表
+     */
+    List<Org> selectList(Org org);
+
+    /**
+     * 新增数据
+     *
+     * @param org 实例对象
+     * @return 影响行数
+     */
+    int insert(Org org);
+
+    /**
+     * 批量新增
+     *
+     * @param orgs 实例对象的集合
+     * @return 影响行数
+     */
+    int batchInsert(@Param("orgs") List<Org> orgs);
+
+    /**
+     * 修改数据
+     *
+     * @param org 实例对象
+     * @return 影响行数
+     */
+    int update(Org org);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 影响行数
+     */
+    int deleteById(Integer id);
+
+    /**
+     * 查询总数据数
+     *
+     * @return 数据总数
+     */
+    int count();
+
+    IPage<Org> selectPage(IPage<Org> page, Org org);
+
+}

+ 99 - 0
sms_water/src/main/java/com/huaxu/entity/Org.java

@@ -0,0 +1,99 @@
+package com.huaxu.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 组织(Org)实体类
+ *
+ * @author makejava
+ * @since 2020-11-19 09:55:20
+ */
+@Data
+@ApiModel
+public class Org implements Serializable {
+    private static final long serialVersionUID = 813791045057448389L;
+    /**
+     * 主键
+     */
+    @ApiModelProperty(value = "主键")
+    private Integer id;
+    /**
+     * 租户标识
+     */
+    @ApiModelProperty(value = "租户标识")
+    private String tenantId;
+    /**
+     * 机构类型
+     */
+    @ApiModelProperty(value = "机构类型")
+    private String orgType;
+    /**
+     * 上级机构
+     */
+    @ApiModelProperty(value = "上级机构")
+    private Integer parentOrgId;
+    /**
+     * 机构所在区域
+     */
+    @ApiModelProperty(value = "机构所在区域")
+    private Integer orgAreaId;
+    /**
+     * 机构名称
+     */
+    @ApiModelProperty(value = "机构名称")
+    private String orgName;
+    /**
+     * 机构状态
+     */
+    @ApiModelProperty(value = "机构状态")
+    private Integer orgState;
+    /**
+     * 备注
+     */
+    @ApiModelProperty(value = "备注")
+    private String remark;
+    /**
+     * 机构负责人名称
+     */
+    @ApiModelProperty(value = "机构负责人名称")
+    private String orgLeaderName;
+    /**
+     * 机构负责人手机
+     */
+    @ApiModelProperty(value = "机构负责人手机")
+    private String orgLeaderPhone;
+    /**
+     * 机构负责人邮箱
+     */
+    @ApiModelProperty(value = "机构负责人邮箱")
+    private String orgLeaderEmail;
+    /**
+     * 机构负责人性别
+     */
+    @ApiModelProperty(value = "机构负责人性别")
+    private String orgLeaderSex;
+    /**
+     * 数据删除标记
+     */
+    @ApiModelProperty(value = "数据删除标记")
+    private Integer status;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date dateCreate;
+    /**
+     * 创建人
+     */
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+    @ApiModelProperty(value = "")
+    private Date dateUpdate;
+    @ApiModelProperty(value = "")
+    private String updateBy;
+}

+ 36 - 0
sms_water/src/main/java/com/huaxu/util/OrgInfoUtil.java

@@ -0,0 +1,36 @@
+package com.huaxu.util;
+
+import com.huaxu.dao.OrgMapper;
+import com.huaxu.entity.Org;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class OrgInfoUtil {
+    @Autowired
+    private RedisUtil redisUtil;
+    @Autowired
+    private OrgMapper orgMapper;
+    public  String getOrgName(Integer id){
+
+        String tenantId = UserUtil.getCurrentUser().getTenantId();
+        String key="orgInfo" + tenantId;
+        Map<String, String> keysValues = redisUtil.getKeysValues(key);
+        if(keysValues==null){
+            keysValues=new HashMap<>();
+            Org org=new Org();
+            org.setStatus(1);
+            org.setTenantId(tenantId);
+            List<Org> orgs = orgMapper.selectList(org);
+            for (Org org1 : orgs) {
+                keysValues.put(org1.getId()+"",org1.getOrgName());
+            }
+            redisUtil.putHashValues(key,keysValues);
+        }
+        return keysValues.get(id);
+    };
+}