Browse Source

标准化链接

anderx 1 year ago
parent
commit
2bb2d585e6

+ 85 - 0
src/main/java/com/goafanti/common/dao/StandardPlatformLinkMapper.java

@@ -0,0 +1,85 @@
+package com.goafanti.common.dao;
+
+import com.goafanti.common.model.StandardPlatformLink;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+/**
+ * 标准平台连接(StandardPlatformLink)表数据库访问层
+ *
+ * @author makejava
+ * @since 2024-07-02 09:36:09
+ */
+public interface StandardPlatformLinkMapper {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    StandardPlatformLink queryById(Integer id);
+
+
+    /**
+     * 查询指定行数据
+     *
+     * @param standardPlatformLink 查询条件
+     * @param pageable             分页对象
+     * @return 对象列表
+     */
+    List<StandardPlatformLink> queryAllByLimit(StandardPlatformLink standardPlatformLink, @Param("pageable") Pageable pageable);
+
+    /**
+     * 统计总行数
+     *
+     * @param standardPlatformLink 查询条件
+     * @return 总行数
+     */
+    long count(StandardPlatformLink standardPlatformLink);
+
+    /**
+     * 新增数据
+     *
+     * @param standardPlatformLink 实例对象
+     * @return 影响行数
+     */
+    int insert(StandardPlatformLink standardPlatformLink);
+
+    /**
+     * 批量新增数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<StandardPlatformLink> 实例对象列表
+     * @return 影响行数
+     */
+    int insertBatch(@Param("entities") List<StandardPlatformLink> entities);
+
+    /**
+     * 批量新增或按主键更新数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<StandardPlatformLink> 实例对象列表
+     * @return 影响行数
+     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
+     */
+    int insertOrUpdateBatch(@Param("entities") List<StandardPlatformLink> entities);
+
+    /**
+     * 修改数据
+     *
+     * @param standardPlatformLink 实例对象
+     * @return 影响行数
+     */
+    int update(StandardPlatformLink standardPlatformLink);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 影响行数
+     */
+    int deleteById(Integer id);
+
+}
+

+ 165 - 0
src/main/java/com/goafanti/common/mapper/StandardPlatformLinkMapper.xml

@@ -0,0 +1,165 @@
+<?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.goafanti.standard.dao.StandardPlatformLinkDao">
+
+    <resultMap type="com.goafanti.standard.model.StandardPlatformLink" id="StandardPlatformLinkMap">
+        <result property="id" column="id" jdbcType="INTEGER"/>
+        <result property="name" column="name" jdbcType="VARCHAR"/>
+        <result property="url" column="url" jdbcType="VARCHAR"/>
+        <result property="aid" column="aid" jdbcType="VARCHAR"/>
+        <result property="status" column="status" jdbcType="INTEGER"/>
+        <result property="sort" column="sort" jdbcType="INTEGER"/>
+        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <!--查询单个-->
+    <select id="queryById" resultMap="StandardPlatformLinkMap">
+        select id,
+               name,
+               url,
+               aid,
+               status,
+               sort,
+               create_time,
+               update_time
+        from standard_platform_link
+        where id = #{id}
+    </select>
+
+    <!--查询指定行数据-->
+    <select id="queryAllByLimit" resultMap="StandardPlatformLinkMap">
+        select
+        id, name, url, aid, status, sort, create_time, update_time
+        from standard_platform_link
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="name != null and name != ''">
+                and name = #{name}
+            </if>
+            <if test="url != null and url != ''">
+                and url = #{url}
+            </if>
+            <if test="aid != null and aid != ''">
+                and aid = #{aid}
+            </if>
+            <if test="status != null">
+                and status = #{status}
+            </if>
+            <if test="sort != null">
+                and sort = #{sort}
+            </if>
+            <if test="createTime != null">
+                and create_time = #{createTime}
+            </if>
+            <if test="updateTime != null">
+                and update_time = #{updateTime}
+            </if>
+        </where>
+        limit #{pageable.offset}, #{pageable.pageSize}
+    </select>
+
+    <!--统计总行数-->
+    <select id="count" resultType="java.lang.Long">
+        select count(1)
+        from standard_platform_link
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="name != null and name != ''">
+                and name = #{name}
+            </if>
+            <if test="url != null and url != ''">
+                and url = #{url}
+            </if>
+            <if test="aid != null and aid != ''">
+                and aid = #{aid}
+            </if>
+            <if test="status != null">
+                and status = #{status}
+            </if>
+            <if test="sort != null">
+                and sort = #{sort}
+            </if>
+            <if test="createTime != null">
+                and create_time = #{createTime}
+            </if>
+            <if test="updateTime != null">
+                and update_time = #{updateTime}
+            </if>
+        </where>
+    </select>
+
+    <!--新增所有列-->
+    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
+        insert into standard_platform_link(name, url, aid, status, sort, create_time, update_time)
+        values (#{name}, #{url}, #{aid}, #{status}, #{sort}, #{createTime}, #{updateTime})
+    </insert>
+
+    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
+        insert into standard_platform_link(name, url, aid, status, sort, create_time, update_time)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.name}, #{entity.url}, #{entity.aid}, #{entity.status}, #{entity.sort}, #{entity.createTime},
+            #{entity.updateTime})
+        </foreach>
+    </insert>
+
+    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
+        insert into standard_platform_link(name, url, aid, status, sort, create_time, update_time)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.name}, #{entity.url}, #{entity.aid}, #{entity.status}, #{entity.sort}, #{entity.createTime},
+            #{entity.updateTime})
+        </foreach>
+        on duplicate key update
+        name = values(name),
+        url = values(url),
+        aid = values(aid),
+        status = values(status),
+        sort = values(sort),
+        create_time = values(create_time),
+        update_time = values(update_time)
+    </insert>
+
+    <!--通过主键修改数据-->
+    <update id="update">
+        update standard_platform_link
+        <set>
+            <if test="name != null and name != ''">
+                name = #{name},
+            </if>
+            <if test="url != null and url != ''">
+                url = #{url},
+            </if>
+            <if test="aid != null and aid != ''">
+                aid = #{aid},
+            </if>
+            <if test="status != null">
+                status = #{status},
+            </if>
+            <if test="sort != null">
+                sort = #{sort},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime},
+            </if>
+            <if test="updateTime != null">
+                update_time = #{updateTime},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+
+    <!--通过主键删除-->
+    <delete id="deleteById">
+        delete
+        from standard_platform_link
+        where id = #{id}
+    </delete>
+
+</mapper>
+

+ 112 - 0
src/main/java/com/goafanti/common/model/StandardPlatformLink.java

@@ -0,0 +1,112 @@
+package com.goafanti.common.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * 标准平台连接(StandardPlatformLink)实体类
+ *
+ * @author makejava
+ * @since 2024-07-02 09:36:09
+ */
+public class StandardPlatformLink implements Serializable {
+    private static final long serialVersionUID = 142536552530890370L;
+
+    private Integer id;
+    /**
+     * 标准平台名称
+     */
+    private String name;
+    /**
+     * 平台链接
+     */
+    private String url;
+    /**
+     * 负责人
+     */
+    private String aid;
+    /**
+     * 状态 0=关闭,1=开启
+     */
+    private Integer status;
+    /**
+     * 排序
+     */
+    private Integer sort;
+    /**
+     * 发起时间
+     */
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    private Date updateTime;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getAid() {
+        return aid;
+    }
+
+    public void setAid(String aid) {
+        this.aid = aid;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getSort() {
+        return sort;
+    }
+
+    public void setSort(Integer sort) {
+        this.sort = sort;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+}
+

+ 74 - 0
src/main/java/com/goafanti/standard/controller/StandardPlatformLinkController.java

@@ -0,0 +1,74 @@
+package com.goafanti.standard.controller;
+
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.model.StandardPlatformLink;
+import com.goafanti.standard.service.StandardPlatformLinkService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+/**
+ * 标准平台连接(StandardPlatformLink)表控制层
+ *
+ * @author makejava
+ * @since 2024-07-02 09:36:09
+ */
+@RestController
+@RequestMapping("/standardPlatformLink")
+public class StandardPlatformLinkController {
+    /**
+     * 服务对象
+     */
+    @Resource
+    private StandardPlatformLinkService standardPlatformLinkService;
+
+
+    /**
+     * 通过主键查询单条数据
+     *
+     * @param id 主键
+     * @return 单条数据
+     */
+    @GetMapping("/get")
+    public Result<StandardPlatformLink> queryById(Integer id) {
+        return new Result<>().data(this.standardPlatformLinkService.queryById(id));
+    }
+
+    /**
+     * 新增数据
+     *
+     * @param standardPlatformLink 实体
+     * @return 新增结果
+     */
+    @PostMapping("/add")
+    public Result add(StandardPlatformLink standardPlatformLink) {
+        return new Result<>().data(this.standardPlatformLinkService.insert(standardPlatformLink));
+    }
+
+    /**
+     * 编辑数据
+     *
+     * @param standardPlatformLink 实体
+     * @return 编辑结果
+     */
+    @PostMapping("/update")
+    public Result edit(StandardPlatformLink standardPlatformLink) {
+        return new Result<>().data(this.standardPlatformLinkService.update(standardPlatformLink));
+    }
+
+    /**
+     * 删除数据
+     *
+     * @param id 主键
+     * @return 删除是否成功
+     */
+    @GetMapping("/delete")
+    public Result deleteById(Integer id) {
+        return new Result<>().data(this.standardPlatformLinkService.deleteById(id));
+    }
+
+}
+

+ 46 - 0
src/main/java/com/goafanti/standard/service/StandardPlatformLinkService.java

@@ -0,0 +1,46 @@
+package com.goafanti.standard.service;
+
+import com.goafanti.common.model.StandardPlatformLink;
+
+/**
+ * 标准平台连接(StandardPlatformLink)表服务接口
+ *
+ * @author makejava
+ * @since 2024-07-02 09:36:10
+ */
+public interface StandardPlatformLinkService {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    StandardPlatformLink queryById(Integer id);
+
+
+    /**
+     * 新增数据
+     *
+     * @param standardPlatformLink 实例对象
+     * @return 实例对象
+     */
+    StandardPlatformLink insert(StandardPlatformLink standardPlatformLink);
+
+    /**
+     * 修改数据
+     *
+     * @param standardPlatformLink 实例对象
+     * @return 实例对象
+     */
+    StandardPlatformLink update(StandardPlatformLink standardPlatformLink);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 是否成功
+     */
+    boolean deleteById(Integer id);
+
+}

+ 79 - 0
src/main/java/com/goafanti/standard/service/impl/StandardPlatformLinkServiceImpl.java

@@ -0,0 +1,79 @@
+package com.goafanti.standard.service.impl;
+
+import com.goafanti.common.dao.StandardPlatformLinkMapper;
+import com.goafanti.common.model.StandardPlatformLink;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.standard.service.StandardPlatformLinkService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 标准平台连接(StandardPlatformLink)表服务实现类
+ *
+ * @author makejava
+ * @since 2024-07-02 09:36:10
+ */
+@Service("standardPlatformLinkService")
+public class StandardPlatformLinkServiceImpl extends BaseMybatisDao<StandardPlatformLinkMapper> implements StandardPlatformLinkService {
+    @Resource
+    private StandardPlatformLinkMapper standardPlatformLinkMapper;
+
+
+    public Pagination<StandardPlatformLink> list(StandardPlatformLink standardPlatformLink, Integer pageNo, Integer pageSize) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("in", standardPlatformLink);
+        return (Pagination<StandardPlatformLink>) findPage("findStandardPlatformLinkList",
+                "findStandardPlatformLinkCount", params, pageNo, pageSize);
+    }
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    @Override
+    public StandardPlatformLink queryById(Integer id) {
+        return this.standardPlatformLinkMapper.queryById(id);
+    }
+
+
+    /**
+     * 新增数据
+     *
+     * @param standardPlatformLink 实例对象
+     * @return 实例对象
+     */
+    @Override
+    public StandardPlatformLink insert(StandardPlatformLink standardPlatformLink) {
+        this.standardPlatformLinkMapper.insert(standardPlatformLink);
+        return standardPlatformLink;
+    }
+
+    /**
+     * 修改数据
+     *
+     * @param standardPlatformLink 实例对象
+     * @return 实例对象
+     */
+    @Override
+    public StandardPlatformLink update(StandardPlatformLink standardPlatformLink) {
+        this.standardPlatformLinkMapper.update(standardPlatformLink);
+        return this.queryById(standardPlatformLink.getId());
+    }
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 是否成功
+     */
+    @Override
+    public boolean deleteById(Integer id) {
+        return this.standardPlatformLinkMapper.deleteById(id) > 0;
+    }
+}