浏览代码

Merge remote-tracking branch 'origin/master'

hym 4 年之前
父节点
当前提交
8de08b59e0

+ 154 - 0
user_center/src/main/java/com/huaxu/controller/TenantController.java

@@ -0,0 +1,154 @@
+package com.huaxu.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.huaxu.common.FileUploadUtil;
+import com.huaxu.entity.TenantEntity;
+import com.huaxu.model.AjaxMessage;
+import com.huaxu.model.Pagination;
+import com.huaxu.model.ResultStatus;
+import com.huaxu.service.TenantService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * 租户(Tenant)控制层
+ *
+ * @author makejava
+ * @since 2020-10-20 16:56:39
+ */
+@RestController
+@RequestMapping("/tenant")
+@Api(tags = "租户接口")
+public class TenantController {
+    /**
+     * 租户
+     */
+    @Autowired
+    private TenantService tenantService;
+    @Value("${UMIS.sys_config_path}")
+    private String baseDir;
+
+    /**
+     * 通过主键查询单条数据
+     *
+     * @param id
+     * @return 单条数据
+     */
+    @RequestMapping(value = "get", method = RequestMethod.POST)
+    @ApiOperation(value = "根据id查询租户")
+    public AjaxMessage<TenantEntity> selectOne(
+            @ApiParam(value = "租户信息", required = true) Integer id) {
+        TenantEntity result = tenantService.selectById(id);
+
+        return new AjaxMessage<>(ResultStatus.OK, result);
+    }
+
+    /**
+     * 查询租户信息
+     *
+     * @param tenantEntity 参数对象
+     * @return 多条数据
+     */
+    @RequestMapping(value = "selectList", method = RequestMethod.POST)
+    @ApiOperation(value = "查询租户信息")
+    public AjaxMessage<List<TenantEntity>> selectList(
+            @ApiParam(value = "租户信息", required = true) @RequestBody TenantEntity tenantEntity) {
+        List<TenantEntity> result = tenantService.selectList(tenantEntity);
+
+        return new AjaxMessage<>(ResultStatus.OK, result);
+    }
+
+    /**
+     * 新增
+     */
+    @RequestMapping(value = "addTenantLogo", method = RequestMethod.POST)
+    @ResponseBody
+    @ApiOperation(value = "租户logo")
+    public  AjaxMessage<String>  addUserPhoto(@ApiParam(value = "租户logo", required = true)@RequestParam("avatarfile") MultipartFile file) {
+        String avatar = "";
+        if (!file.isEmpty()) {
+            try {
+                avatar = FileUploadUtil.uploadWeb(baseDir, file);
+            } catch (IOException e) {
+                return new AjaxMessage<>(ResultStatus.ERROR, e.getMessage());
+            }
+        }
+        return new AjaxMessage<>(ResultStatus.OK, avatar);
+    }
+
+    /**
+     * 新增一条数据
+     *
+     * @param tenantEntity 实体类
+     * @return Response对象
+     */
+    @RequestMapping(value = "insert", method = RequestMethod.POST)
+    @ApiOperation(value = "插入租户信息")
+    public AjaxMessage<Integer> insert(@ApiParam(value = "租户信息", required = true) @RequestBody TenantEntity tenantEntity) {
+        int result = tenantService.insert(tenantEntity);
+
+        return new AjaxMessage<>(ResultStatus.OK, result);
+    }
+
+    /**
+     * 修改一条数据
+     *
+     * @param tenantEntity 实体类
+     * @return Response对象
+     */
+    @RequestMapping(value = "update", method = RequestMethod.POST)
+    @ApiOperation(value = "修改租户信息")
+    public AjaxMessage<Integer> update(@ApiParam(value = "租户信息", required = true) @RequestBody TenantEntity tenantEntity) {
+        int result = tenantService.update(tenantEntity);
+        return new AjaxMessage<>(ResultStatus.OK, result);
+
+    }
+
+    /**
+     * 单条删除数据
+     *
+     * @param id
+     * @return Response对象
+     */
+    @RequestMapping(value = "delete", method = RequestMethod.POST)
+    @ApiOperation(value = "删除租户信息")
+    public AjaxMessage<Integer> delete(@ApiParam(value = "租户信息", required = true) Integer id) {
+        int result = tenantService.deleteById(id);
+        return new AjaxMessage<>(ResultStatus.OK, result);
+    }
+
+
+    /**
+     * 分页查询
+     *
+     * @param pageNum  偏移
+     * @param pageSize 条数
+     * @return Response对象
+     */
+    @RequestMapping(value = "selectPage", method = RequestMethod.POST)
+    @ApiOperation(value = "查询租户信息列表")
+    public AjaxMessage<Pagination<TenantEntity>> selectPage(
+            @ApiParam(value = "租户信息", required = true) @RequestBody TenantEntity tenantEntity,
+            @ApiParam(value = "页数,非必传,默认第一页",  defaultValue = "1")  int pageNum,
+            @ApiParam(value = "条数,非必传,默认15条",  defaultValue = "30")  int pageSize
+
+    ) {
+        IPage<TenantEntity> iPage = new Page<>(pageNum, pageSize);
+
+        iPage = tenantService.selectPage(tenantEntity, iPage);
+
+        Pagination<TenantEntity> pages = new Pagination<>(iPage);
+
+        return new AjaxMessage<>(ResultStatus.OK, pages);
+    }
+
+}

+ 83 - 0
user_center/src/main/java/com/huaxu/dao/TenantMapper.java

@@ -0,0 +1,83 @@
+package com.huaxu.dao;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.huaxu.entity.TenantEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2020-10-26 10:05
+ */
+@Mapper
+public interface TenantMapper {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    TenantEntity selectById(Integer id);
+    
+    /**
+     * 查询全部
+     *
+     * @return 对象列表
+     */
+    List<TenantEntity> selectAll();
+
+    /**
+     * 通过实体作为筛选条件查询
+     *
+     * @param TenantEntity 实例对象
+     * @return 对象列表
+     */
+    List<TenantEntity> selectList(TenantEntity TenantEntity);
+
+    /**
+     * 新增数据
+     *
+     * @param TenantEntity 实例对象
+     * @return 影响行数
+     */
+    int insert(TenantEntity TenantEntity);
+
+    /**
+     * 批量新增
+     *
+     * @param tenantEntities 实例对象的集合
+     * @return 影响行数
+     */
+    int batchInsert(List<TenantEntity> tenantEntities);
+
+    /**
+     * 修改数据
+     *
+     * @param TenantEntity 实例对象
+     * @return 影响行数
+     */
+    int update(TenantEntity TenantEntity);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 影响行数
+     */
+    int deleteById(Integer id);
+
+    /**
+     * 查询总数据数
+     *
+     * @return 数据总数
+     */
+    int count();
+
+    IPage<TenantEntity> selectPage(IPage<TenantEntity> page, TenantEntity TenantEntity);
+
+
+
+}

+ 54 - 0
user_center/src/main/java/com/huaxu/entity/TenantEntity.java

@@ -0,0 +1,54 @@
+package com.huaxu.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 租户实体类(uims_tenant)
+ * @description
+ * @auto wangli
+ * @data 2020-10-26 9:43
+ */
+@Data
+@ApiModel("租户信息")
+public class TenantEntity implements Serializable {
+
+
+    private static final long serialVersionUID = -8490493775559730646L;
+
+    @ApiModelProperty(value = "主键id")
+    private Integer id;
+    @ApiModelProperty(value = "租户名称")
+    @NotNull(message = "租户名称不能为空")
+    private String tenantName;
+    @ApiModelProperty(value = "租户标识")
+    @NotNull(message = "租户标识不能为空")
+    private String code;
+    @ApiModelProperty(value = "租户Logo")
+    private String logo;
+    @ApiModelProperty(value = "租户域名")
+    private String webUrl;
+    @ApiModelProperty(value = "租期开始日期")
+    private LocalDateTime startDate;
+    @ApiModelProperty(value = "租期结束日期")
+    private LocalDateTime endDate;
+    @ApiModelProperty(value = "租户状态")
+    private Integer tenantState;
+    @ApiModelProperty(value = "备注")
+    private String remark;
+    @ApiModelProperty(value = "数据删除标识")
+    private Integer status;
+    @ApiModelProperty(value = "创建时间")
+    private LocalDateTime dateCreate;
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+    @ApiModelProperty(value = "更新时间")
+    private LocalDateTime dateUpdate;
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+}

+ 80 - 0
user_center/src/main/java/com/huaxu/service/TenantService.java

@@ -0,0 +1,80 @@
+package com.huaxu.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.huaxu.entity.TenantEntity;
+
+import java.util.List;
+
+/**
+ * 租户(Tenant)表服务接口
+ *
+ * @author makejava
+ * @since 2020-10-20 17:08:13
+ */
+public interface TenantService {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    TenantEntity selectById(Integer id);
+
+
+    /**
+     * 查询全部
+     *
+     * @return 对象列表
+     */
+    List<TenantEntity> selectAll();
+
+    /**
+     * 通过实体作为筛选条件查询
+     *
+     * @param tenantEntity 实例对象
+     * @return 对象列表
+     */
+    List<TenantEntity> selectList(TenantEntity tenantEntity);
+
+    /**
+     * 新增数据
+     *
+     * @param tenantEntity 实例对象
+     * @return 影响行数
+     */
+    int insert(TenantEntity tenantEntity);
+
+    /**
+     * 批量新增
+     *
+     * @param apps 实例对象的集合
+     * @return 影响行数
+     */
+    int batchInsert(List<TenantEntity> apps);
+
+    /**
+     * 修改数据
+     *
+     * @param tenantEntity 实例对象
+     * @return 修改
+     */
+    int update(TenantEntity tenantEntity);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 影响行数
+     */
+    int deleteById(Integer id);
+
+    /**
+     * 查询总数据数
+     *
+     * @return 数据总数
+     */
+    int count();
+
+    IPage<TenantEntity> selectPage(TenantEntity tenantEntity, IPage<TenantEntity> page);
+}

+ 119 - 0
user_center/src/main/java/com/huaxu/service/impl/TenantServiceImpl.java

@@ -0,0 +1,119 @@
+package com.huaxu.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.huaxu.dao.TenantMapper;
+import com.huaxu.entity.TenantEntity;
+import com.huaxu.service.TenantService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 租户(App表)服务实现类
+ *
+ * @author makejava
+ * @since 2020-10-20 17:08:14
+ */
+@Service("tenantService")
+public class TenantServiceImpl implements TenantService {
+    @Autowired
+    private TenantMapper tenantMapper;
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    @Override
+    public TenantEntity selectById(Integer id) {
+        return this.tenantMapper.selectById(id);
+    }
+
+
+    /**
+     * 查询所有
+     *
+     * @return 实例对象的集合
+     */
+    @Override
+    public List<TenantEntity> selectAll() {
+        return this.tenantMapper.selectAll();
+    }
+
+    /**
+     * 根据条件查询
+     *
+     * @return 实例对象的集合
+     */
+    @Override
+    public List<TenantEntity> selectList(TenantEntity tenantEntity) {
+        return this.tenantMapper.selectList(tenantEntity);
+    }
+
+    /**
+     * 新增数据
+     *
+     * @param tenantEntity 实例对象
+     * @return 实例对象
+     */
+    @Override
+    public int insert(TenantEntity tenantEntity) {
+        return this.tenantMapper.insert(tenantEntity);
+    }
+
+    /**
+     * 批量新增
+     *
+     * @param apps 实例对象的集合
+     * @return 生效的条数
+     */
+    @Override
+    public int batchInsert(List<TenantEntity> apps) {
+        return this.tenantMapper.batchInsert(apps);
+    }
+
+    /**
+     * 修改数据
+     *
+     * @param tenantEntity 实例对象
+     * @return 实例对象
+     */
+    @Override
+    public int update(TenantEntity tenantEntity) {
+
+        return this.tenantMapper.update(tenantEntity);
+    }
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 是否成功
+     */
+    @Override
+    public int deleteById(Integer id) {
+        return this.tenantMapper.deleteById(id);
+    }
+
+    /**
+     * 查询总数据数
+     *
+     * @return 数据总数
+     */
+    @Override
+    public int count() {
+        return this.tenantMapper.count();
+    }
+
+    /**
+     * 分页查询
+     *
+     * @return 对象列表
+     */
+    @Override
+    public IPage<TenantEntity> selectPage(TenantEntity tenantEntity, IPage<TenantEntity> page) {
+        return this.tenantMapper.selectPage(page, tenantEntity);
+    }
+}

+ 141 - 0
user_center/src/main/resources/mapper/TenantMapper.xml

@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.huaxu.dao.TenantMapper">
+
+    <resultMap id="TenantMap" type="com.huaxu.entity.TenantEntity" >
+        <result property="id" column="ID" jdbcType="INTEGER"/>
+        <result property="tenantName" column="TENANT_NAME" jdbcType="VARCHAR"/>
+        <result property="code" column="CODE" jdbcType="VARCHAR"/>
+        <result property="logo" column="LOGO" jdbcType="VARCHAR"/>
+        <result property="webUrl" column="WEB_URL" jdbcType="VARCHAR"/>
+        <result property="startDate" column="START_DATE" jdbcType="TIMESTAMP"/>
+        <result property="endDate" column="END_DATE" jdbcType="TIMESTAMP"/>
+        <result property="tenantState" column="TENANT_STATE" jdbcType="INTEGER"/>
+        <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
+        <result property="status" column="STATUS" jdbcType="INTEGER"/>
+        <result property="dateCreate" column="DATE_CREATE" jdbcType="TIMESTAMP"/>
+        <result property="createBy" column="CREATE_BY" jdbcType="VARCHAR"/>
+        <result property="dateUpdate" column="DATE_UPDATE" jdbcType="TIMESTAMP"/>
+        <result property="updateBy" column="UPDATE_BY" jdbcType="VARCHAR"/>
+    </resultMap>
+    <sql id="Base_Column_List">
+        ID ,TENANT_NAME ,CODE ,LOGO ,WEB_URL ,START_DATE ,END_DATE ,TENANT_STATE ,REMARK ,STATUS ,DATE_CREATE ,CREATE_BY ,DATE_UPDATE ,UPDATE_BY
+    </sql>
+
+    <select id="selectById" resultMap="TenantMap">
+        select
+        <include refid="Base_Column_List"/>
+        from uims_tenant
+        where ID = #{id}
+    </select>
+
+    <!-- 查询全部 -->
+    <select id="selectAll" resultMap="TenantMap">
+        select
+        <include refid="Base_Column_List"/>
+        from uims_tenant
+    </select>
+
+    <!--通过实体作为筛选条件查询-->
+    <select id="selectList" resultMap="TenantMap">
+        select
+        <include refid="Base_Column_List"/>
+        from uims_tenant
+        <where>
+            <if test="id != null">
+                and ID = #{id}
+            </if>
+            <if test="tenantName != null and tenantName != ''">
+                and TENANT_NAME like concat('%',#{tenantName},'%')
+            </if>
+            <if test="code != null and code != ''">
+                and CODE = #{code}
+            </if>
+        </where>
+    </select>
+
+    <!-- 新增所有列 -->
+    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
+        insert into uims_tenant(ID ,TENANT_NAME ,CODE ,LOGO ,WEB_URL ,START_DATE ,END_DATE ,TENANT_STATE ,REMARK ,STATUS ,DATE_CREATE ,CREATE_BY ,DATE_UPDATE ,UPDATE_BY)
+        values ( #{id}, #{tenantName}, #{code}, #{logo}, #{webUrl}, #{startDate}, #{endDate}, #{tenantState}, #{remark}, #{status},#{dateCreate},#{createBy},#{dateUpdate},#{updateBy})
+    </insert>
+
+    <!-- 批量新增 -->
+    <insert id="batchInsert">
+        insert into uims_tenant(ID ,TENANT_NAME ,CODE ,LOGO ,WEB_URL ,START_DATE ,END_DATE ,TENANT_STATE ,REMARK ,STATUS ,DATE_CREATE ,CREATE_BY ,DATE_UPDATE ,UPDATE_BY)
+        values
+        <foreach collection="tenants" item="item" index="index" separator=",">
+            (
+            #{item.id}, #{item.tenantName}, #{item.code}, #{item.logo}, #{item.webUrl}, #{item.startDate},#{item.endDate},
+            #{item.tenantState}, #{item.remark}, #{item.status}, #{item.dateCreate}, #{item.createBy}, #{item.dateUpdate}, #{item.updateBy}  )
+        </foreach>
+    </insert>
+
+    <!-- 通过主键修改数据 -->
+    <update id="update">
+        update uims.uims_tenant
+        <set>
+            <if test="tenantName != null and tenantName != ''">
+                TENANT_NAME = #{tenantName},
+            </if>
+            <if test="code != null and code != ''">
+                CODE = #{code},
+            </if>
+            <if test="logo != null and logo != ''">
+                LOGO = #{logo},
+            </if>
+            <if test="webUrl != null and webUrl != ''">
+                WEB_URL = #{webUrl},
+            </if>
+            <if test="startDate != null">
+                START_DATE = #{startDate},
+            </if>
+            <if test="endDate != null ">
+                END_DATE = #{tenantState},
+            </if>
+            <if test="tenantState != null">
+                TENANT_STATE = #{tenantState},
+            </if>
+            <if test="remark != null and remark != ''">
+                REMARK = #{remark},
+            </if>
+            <if test="status != null">
+                STATUS = #{status},
+            </if>
+            <if test="dateUpdate != null">
+                DATE_UPDATE = #{dateUpdate},
+            </if>
+            <if test="updateBy != null and remark != ''">
+                UPDATE_BY = #{updateBy},
+            </if>
+        </set>
+        where ID = #{id}
+    </update>
+
+    <!--通过主键删除-->
+    <delete id="deleteById">
+        delete from uims_tenant where ID = #{id}
+    </delete>
+
+    <!-- 总数 -->
+    <select id="count" resultType="int">
+        select count(*) from uims_tenant
+    </select>
+
+    <select id="selectPage" resultMap="TenantMap">
+        select
+        <include refid="Base_Column_List"/>
+        from uims_tenant
+        <where>
+            <if test="id != null">
+                and ID = #{app.id}
+            </if>
+            <if test="tenantName != null and tenantName != ''">
+                and TENANT_NAME like concat('%',#{app.tenantName},'%')
+            </if>
+            <if test="code != null and code != ''">
+                and CODE = #{app.code}
+            </if>
+        </where>
+    </select>
+</mapper>