Add technology stack management
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.app.domain;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 项目定制技术栈对象 app_tech_stack。
|
||||
*/
|
||||
public class AppTechStack extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
private Integer sort;
|
||||
/** 0启用 1停用 */
|
||||
private String status;
|
||||
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public Integer getSort() { return sort; }
|
||||
public void setSort(Integer sort) { this.sort = sort; }
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ruoyi.app.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.app.domain.AppTechStack;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface AppTechStackMapper
|
||||
{
|
||||
AppTechStack selectAppTechStackById(Long id);
|
||||
|
||||
AppTechStack selectAppTechStackByName(@Param("name") String name, @Param("excludeId") Long excludeId);
|
||||
|
||||
List<AppTechStack> selectAppTechStackList(AppTechStack techStack);
|
||||
|
||||
List<AppTechStack> selectEnabledAppTechStackList();
|
||||
|
||||
int insertAppTechStack(AppTechStack techStack);
|
||||
|
||||
int updateAppTechStack(AppTechStack techStack);
|
||||
|
||||
int deleteAppTechStackByIds(Long[] ids);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ruoyi.app.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.app.domain.AppTechStack;
|
||||
|
||||
public interface IAppTechStackService
|
||||
{
|
||||
AppTechStack selectAppTechStackById(Long id);
|
||||
|
||||
List<AppTechStack> selectAppTechStackList(AppTechStack techStack);
|
||||
|
||||
List<AppTechStack> selectEnabledAppTechStackList();
|
||||
|
||||
int insertAppTechStack(AppTechStack techStack);
|
||||
|
||||
int updateAppTechStack(AppTechStack techStack);
|
||||
|
||||
int deleteAppTechStackByIds(Long[] ids);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.ruoyi.app.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.app.domain.AppTechStack;
|
||||
import com.ruoyi.app.mapper.AppTechStackMapper;
|
||||
import com.ruoyi.app.service.IAppTechStackService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AppTechStackServiceImpl implements IAppTechStackService
|
||||
{
|
||||
@Autowired
|
||||
private AppTechStackMapper techStackMapper;
|
||||
|
||||
@Override
|
||||
public AppTechStack selectAppTechStackById(Long id)
|
||||
{
|
||||
return techStackMapper.selectAppTechStackById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppTechStack> selectAppTechStackList(AppTechStack techStack)
|
||||
{
|
||||
return techStackMapper.selectAppTechStackList(techStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppTechStack> selectEnabledAppTechStackList()
|
||||
{
|
||||
return techStackMapper.selectEnabledAppTechStackList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertAppTechStack(AppTechStack techStack)
|
||||
{
|
||||
normalizeAndValidate(techStack);
|
||||
techStack.setCreateTime(DateUtils.getNowDate());
|
||||
techStack.setUpdateTime(DateUtils.getNowDate());
|
||||
return techStackMapper.insertAppTechStack(techStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateAppTechStack(AppTechStack techStack)
|
||||
{
|
||||
if (techStack.getId() == null)
|
||||
{
|
||||
throw new ServiceException("技术栈不存在");
|
||||
}
|
||||
normalizeAndValidate(techStack);
|
||||
techStack.setUpdateTime(DateUtils.getNowDate());
|
||||
return techStackMapper.updateAppTechStack(techStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAppTechStackByIds(Long[] ids)
|
||||
{
|
||||
return techStackMapper.deleteAppTechStackByIds(ids);
|
||||
}
|
||||
|
||||
private void normalizeAndValidate(AppTechStack techStack)
|
||||
{
|
||||
String name = StringUtils.trim(techStack.getName());
|
||||
if (StringUtils.isEmpty(name) || name.length() > 50)
|
||||
{
|
||||
throw new ServiceException("技术栈名称需填写1至50个字");
|
||||
}
|
||||
if (techStackMapper.selectAppTechStackByName(name, techStack.getId()) != null)
|
||||
{
|
||||
throw new ServiceException("技术栈名称已存在");
|
||||
}
|
||||
techStack.setName(name);
|
||||
if (techStack.getSort() == null || techStack.getSort() < 0)
|
||||
{
|
||||
techStack.setSort(0);
|
||||
}
|
||||
if (!"1".equals(techStack.getStatus()))
|
||||
{
|
||||
techStack.setStatus("0");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?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.ruoyi.app.mapper.AppTechStackMapper">
|
||||
|
||||
<resultMap type="AppTechStack" id="AppTechStackResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="sort" column="sort" />
|
||||
<result property="status" column="status" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAppTechStackVo">
|
||||
select id, name, sort, status, remark, create_by, create_time, update_by, update_time
|
||||
from app_tech_stack
|
||||
</sql>
|
||||
|
||||
<select id="selectAppTechStackById" parameterType="Long" resultMap="AppTechStackResult">
|
||||
<include refid="selectAppTechStackVo" /> where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectAppTechStackByName" resultMap="AppTechStackResult">
|
||||
<include refid="selectAppTechStackVo" />
|
||||
where name = #{name}
|
||||
<if test="excludeId != null">and id != #{excludeId}</if>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectAppTechStackList" parameterType="AppTechStack" resultMap="AppTechStackResult">
|
||||
<include refid="selectAppTechStackVo" />
|
||||
<where>
|
||||
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
|
||||
<if test="status != null and status != ''">and status = #{status}</if>
|
||||
</where>
|
||||
order by sort asc, id asc
|
||||
</select>
|
||||
|
||||
<select id="selectEnabledAppTechStackList" resultMap="AppTechStackResult">
|
||||
<include refid="selectAppTechStackVo" />
|
||||
where status = '0'
|
||||
order by sort asc, id asc
|
||||
</select>
|
||||
|
||||
<insert id="insertAppTechStack" parameterType="AppTechStack" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into app_tech_stack (name, sort, status, remark, create_by, create_time, update_by, update_time)
|
||||
values (#{name}, #{sort}, #{status}, #{remark}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime})
|
||||
</insert>
|
||||
|
||||
<update id="updateAppTechStack" parameterType="AppTechStack">
|
||||
update app_tech_stack
|
||||
<set>
|
||||
name = #{name}, sort = #{sort}, status = #{status},
|
||||
remark = #{remark}, update_by = #{updateBy}, update_time = #{updateTime}
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAppTechStackByIds" parameterType="Long">
|
||||
delete from app_tech_stack where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user