20 changed files with 638 additions and 274 deletions
@ -0,0 +1,41 @@ |
|||
package com.dreamchaser.depository_manage.entity; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 施工单位 |
|||
*/ |
|||
@Data |
|||
public class ConstructionUnit { |
|||
/** |
|||
* id |
|||
*/ |
|||
private Integer id; |
|||
/** |
|||
* 状态 1启用2禁用3删除 |
|||
*/ |
|||
private Integer state; |
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Long createTime; |
|||
|
|||
|
|||
|
|||
/** |
|||
* 创建时间(展示) |
|||
*/ |
|||
private String showCreateTime; |
|||
/** |
|||
* 施工单位名称 |
|||
*/ |
|||
private String name; |
|||
/** |
|||
* 施工单位介绍 |
|||
*/ |
|||
private String introduce; |
|||
/** |
|||
* 施工单位地址 |
|||
*/ |
|||
private String address; |
|||
} |
|||
@ -0,0 +1,90 @@ |
|||
package com.dreamchaser.depository_manage.mapper; |
|||
|
|||
import com.dreamchaser.depository_manage.entity.ConstructionUnit; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Mapper |
|||
@Repository |
|||
public interface ConstructionUnitMapper { |
|||
|
|||
/** |
|||
* 创建施工单位 |
|||
* |
|||
* @param map 待创建数据 |
|||
* @return |
|||
*/ |
|||
Integer addConstructionUnit(Map<String, Object> map); |
|||
|
|||
/** |
|||
* 查询所有施工单位 |
|||
* |
|||
* @return |
|||
*/ |
|||
List<ConstructionUnit> findConstructionUnitAll(); |
|||
|
|||
|
|||
/** |
|||
* 根据条件查询施工单位 |
|||
* |
|||
* @param map 查询条件 |
|||
* @return |
|||
*/ |
|||
List<ConstructionUnit> findConstructionUnitByCondition(Map<String, Object> map); |
|||
|
|||
|
|||
/** |
|||
* 根据条件查询施工单位数量 |
|||
* |
|||
* @param map 查询条件 |
|||
* @return |
|||
*/ |
|||
Integer findConstructionUnitCountByCondition(Map<String, Object> map); |
|||
|
|||
/** |
|||
* 通过主键查询施工单位 |
|||
* |
|||
* @param id 待查询主键 |
|||
* @return |
|||
*/ |
|||
ConstructionUnit findConstructionUnitById(Integer id); |
|||
|
|||
/** |
|||
* 修改施工单位状态 |
|||
* |
|||
* @param map 修改条件 |
|||
* @return |
|||
*/ |
|||
Integer updateConstructionUnitState(Map<String, Object> map); |
|||
|
|||
|
|||
/** |
|||
* 修改施工单位信息 |
|||
* |
|||
* @param map 修改数据 |
|||
* @return |
|||
*/ |
|||
Integer updateConstructionUnit(Map<String, Object> map); |
|||
|
|||
|
|||
/** |
|||
* 根据主键id删除施工单位 |
|||
* |
|||
* @param id 待删除id |
|||
* @return |
|||
*/ |
|||
Integer deleteConstructionUnitById(Integer id); |
|||
|
|||
/** |
|||
* 根据主键id批量删除施工单位 |
|||
* |
|||
* @param list 待删除id列表 |
|||
* @return |
|||
*/ |
|||
Integer deleteConstructionUnitByIds(List<Integer> list); |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,129 @@ |
|||
<?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.dreamchaser.depository_manage.mapper.ConstructionUnitMapper"> |
|||
<resultMap id="constructionUnitMap" type="com.dreamchaser.depository_manage.entity.ConstructionUnit"> |
|||
<id column="id" property="id" jdbcType="INTEGER" /> |
|||
<result column="name" property="name" jdbcType="VARCHAR" /> |
|||
<result column="state" property="state" jdbcType="INTEGER" /> |
|||
<result column="introduce" property="introduce" jdbcType="VARCHAR" /> |
|||
<result column="address" property="address" jdbcType="VARCHAR" /> |
|||
<result column="createTime" property="createTime" jdbcType="INTEGER" /> |
|||
</resultMap> |
|||
<sql id="allColumns"> |
|||
id,`name`,state,introduce,address,createTime |
|||
</sql> |
|||
|
|||
<insert id="addConstructionUnit"> |
|||
insert into constructionunit(id,`name`,state,introduce,address,createTime) |
|||
values ( |
|||
#{id}, |
|||
#{name}, |
|||
#{state}, |
|||
#{introduce}, |
|||
#{address}, |
|||
#{createTime} |
|||
) |
|||
</insert> |
|||
|
|||
<select id="findConstructionUnitAll" resultMap="constructionUnitMap"> |
|||
select |
|||
<include refid="allColumns"/> |
|||
from constructionunit |
|||
</select> |
|||
|
|||
<select id="findConstructionUnitByCondition" parameterType="map" resultMap="constructionUnitMap"> |
|||
select |
|||
<include refid="allColumns"/> |
|||
from constructionunit |
|||
where 1 = 1 |
|||
<if test="name != null and name != ''"> |
|||
and `name` like CONCAT('%',#{name},'%') |
|||
</if> |
|||
<if test="state != null and state != ''"> |
|||
and state = #{state} |
|||
</if> |
|||
<if test="introduce != null and introduce != ''"> |
|||
and introduce like concat('%',#{introduce},'%') |
|||
</if> |
|||
<if test="address != null and address != ''"> |
|||
and address like concat('%',#{address},'%') |
|||
</if> |
|||
<if test="begin != null and size != null"> |
|||
LIMIT #{begin},#{size} |
|||
</if> |
|||
</select> |
|||
|
|||
|
|||
<select id="findConstructionUnitCountByCondition" parameterType="map" resultType="int"> |
|||
select |
|||
COUNT(*) |
|||
from constructionunit |
|||
where 1 = 1 |
|||
<if test="name != null and name != ''"> |
|||
and `name` like CONCAT('%',#{name},'%') |
|||
</if> |
|||
<if test="state != null and state != ''"> |
|||
and state = #{state} |
|||
</if> |
|||
<if test="introduce != null and introduce != ''"> |
|||
and introduce like concat('%',#{introduce},'%') |
|||
</if> |
|||
<if test="address != null and address != ''"> |
|||
and address like concat('%',#{address},'%') |
|||
</if> |
|||
</select> |
|||
|
|||
|
|||
<select id="findConstructionUnitById" resultMap="constructionUnitMap" parameterType="int"> |
|||
select |
|||
<include refid="allColumns"/> |
|||
from constructionunit |
|||
where id = #{id} |
|||
</select> |
|||
|
|||
<update id="updateConstructionUnit"> |
|||
update constructionunit |
|||
<set> |
|||
<if test="name != null and name != ''"> |
|||
namd = #{name}, |
|||
</if> |
|||
<if test="state != null and state != ''"> |
|||
state = #{state}, |
|||
</if> |
|||
<if test="introduce != null and introduce != ''"> |
|||
introduce = #{introduce}, |
|||
</if> |
|||
<if test="address != null and address != ''"> |
|||
address = #{address} |
|||
</if> |
|||
</set> |
|||
where id = #{id} |
|||
</update> |
|||
|
|||
|
|||
<update id="updateConstructionUnitState"> |
|||
update constructionunit |
|||
<set> |
|||
<if test="state != null and state != ''"> |
|||
state = #{state}, |
|||
</if> |
|||
</set> |
|||
where id = #{id} |
|||
</update> |
|||
|
|||
<delete id="deleteConstructionUnitById" parameterType="int"> |
|||
delete from constructionunit where id = #{id} |
|||
</delete> |
|||
|
|||
<delete id="deleteConstructionUnitByIds" parameterType="list"> |
|||
delete from constructionunit where id in |
|||
<foreach collection="list" item="id" index="index" open="(" separator="," close=")"> |
|||
#{id} |
|||
</foreach> |
|||
</delete> |
|||
|
|||
|
|||
|
|||
|
|||
</mapper> |
|||
@ -0,0 +1,85 @@ |
|||
package com.dreamchaser.depository_manage.service; |
|||
|
|||
|
|||
import com.dreamchaser.depository_manage.entity.ConstructionUnit; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface ConstructionUnitService { |
|||
/** |
|||
* 创建施工单位 |
|||
* |
|||
* @param map 待创建数据 |
|||
* @return |
|||
*/ |
|||
Integer addConstructionUnit(Map<String, Object> map); |
|||
|
|||
/** |
|||
* 查询所有施工单位 |
|||
* |
|||
* @return |
|||
*/ |
|||
List<ConstructionUnit> findConstructionUnitAll(); |
|||
|
|||
|
|||
/** |
|||
* 根据条件查询施工单位 |
|||
* |
|||
* @param map 查询条件 |
|||
* @return |
|||
*/ |
|||
List<ConstructionUnit> findConstructionUnitByCondition(Map<String, Object> map); |
|||
|
|||
|
|||
/** |
|||
* 根据条件查询施工单位数量 |
|||
* |
|||
* @param map 查询条件 |
|||
* @return |
|||
*/ |
|||
Integer findConstructionUnitCountByCondition(Map<String, Object> map); |
|||
|
|||
/** |
|||
* 通过主键查询施工单位 |
|||
* |
|||
* @param id 待查询主键 |
|||
* @return |
|||
*/ |
|||
ConstructionUnit findConstructionUnitById(Integer id); |
|||
|
|||
/** |
|||
* 修改施工单位状态 |
|||
* |
|||
* @param map 修改条件 |
|||
* @return |
|||
*/ |
|||
Integer updateConstructionUnitState(Map<String, Object> map); |
|||
|
|||
|
|||
/** |
|||
* 修改施工单位信息 |
|||
* |
|||
* @param map 修改数据 |
|||
* @return |
|||
*/ |
|||
Integer updateConstructionUnit(Map<String, Object> map); |
|||
|
|||
|
|||
/** |
|||
* 根据主键id删除施工单位 |
|||
* |
|||
* @param id 待删除id |
|||
* @return |
|||
*/ |
|||
Integer deleteConstructionUnitById(Integer id); |
|||
|
|||
/** |
|||
* 根据主键id批量删除施工单位 |
|||
* |
|||
* @param list 待删除id列表 |
|||
* @return |
|||
*/ |
|||
Integer deleteConstructionUnitByIds(List<Integer> list); |
|||
} |
|||
@ -0,0 +1,148 @@ |
|||
package com.dreamchaser.depository_manage.service.impl; |
|||
|
|||
import com.dreamchaser.depository_manage.entity.ConstructionUnit; |
|||
import com.dreamchaser.depository_manage.mapper.ConstructionUnitMapper; |
|||
import com.dreamchaser.depository_manage.service.ConstructionUnitService; |
|||
import com.dreamchaser.depository_manage.utils.DateUtil; |
|||
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class ConstructionUnitServiceImpl implements ConstructionUnitService { |
|||
|
|||
@Autowired |
|||
ConstructionUnitMapper constructionUnitMapper; |
|||
|
|||
/** |
|||
* 创建施工单位 |
|||
* @param map 待创建数据 |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public Integer addConstructionUnit(Map<String, Object> map) { |
|||
map.put("createTime",System.currentTimeMillis()); |
|||
map.put("state",1); |
|||
return constructionUnitMapper.addConstructionUnit(map); |
|||
} |
|||
|
|||
/** |
|||
* 查询所有施工单位 |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public List<ConstructionUnit> findConstructionUnitAll() { |
|||
List<ConstructionUnit> constructionUnitAll = constructionUnitMapper.findConstructionUnitAll(); |
|||
for (ConstructionUnit constructionUnit: constructionUnitAll |
|||
) { |
|||
constructionUnit.setShowCreateTime(DateUtil.TimeStampToDateTime(constructionUnit.getCreateTime())); |
|||
} |
|||
return constructionUnitAll; |
|||
} |
|||
|
|||
/** |
|||
* 根据条件查询施工单位 |
|||
* |
|||
* @param map 查询条件 |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public List<ConstructionUnit> findConstructionUnitByCondition(Map<String, Object> map) { |
|||
Integer size = 10, page = 1; |
|||
if (map.containsKey("size")) { |
|||
size = ObjectFormatUtil.toInteger(map.get("size")); |
|||
map.put("size", size); |
|||
} |
|||
if (map.containsKey("page")) { |
|||
page = ObjectFormatUtil.toInteger(map.get("page")); |
|||
map.put("begin", (page - 1) * size); |
|||
} |
|||
Object state = 1; |
|||
if (map.containsKey("state")) { |
|||
state = map.get("state"); |
|||
} |
|||
map.put("state", state); |
|||
List<ConstructionUnit> constructionUnitByCondition = constructionUnitMapper.findConstructionUnitByCondition(map); |
|||
for (ConstructionUnit constructionUnit:constructionUnitByCondition |
|||
) { |
|||
constructionUnit.setShowCreateTime(DateUtil.TimeStampToDateTime(constructionUnit.getCreateTime())); |
|||
|
|||
} |
|||
return constructionUnitByCondition; |
|||
} |
|||
|
|||
/** |
|||
* 根据条件查询施工单位数量 |
|||
* |
|||
* @param map 查询条件 |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public Integer findConstructionUnitCountByCondition(Map<String, Object> map) { |
|||
Object state = 1; |
|||
if (map.containsKey("state")) { |
|||
state = map.get("state"); |
|||
} |
|||
map.put("state", state); |
|||
return constructionUnitMapper.findConstructionUnitCountByCondition(map); |
|||
} |
|||
|
|||
/** |
|||
* 通过主键查询施工单位 |
|||
* @param id 待查询主键 |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public ConstructionUnit findConstructionUnitById(Integer id) { |
|||
ConstructionUnit constructionUnitById = constructionUnitMapper.findConstructionUnitById(id); |
|||
constructionUnitById.setShowCreateTime(DateUtil.TimeStampToDateTime(constructionUnitById.getCreateTime())); |
|||
return constructionUnitById; |
|||
} |
|||
|
|||
/** |
|||
* 修改施工单位状态 |
|||
* |
|||
* @param map 修改条件 |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public Integer updateConstructionUnitState(Map<String, Object> map) { |
|||
return constructionUnitMapper.updateConstructionUnitState(map); |
|||
} |
|||
|
|||
/** |
|||
* 修改施工单位信息 |
|||
* |
|||
* @param map 修改数据 |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public Integer updateConstructionUnit(Map<String, Object> map) { |
|||
return constructionUnitMapper.updateConstructionUnit(map); |
|||
} |
|||
|
|||
/** |
|||
* 根据主键id删除施工单位 |
|||
* |
|||
* @param id 待删除id |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public Integer deleteConstructionUnitById(Integer id) { |
|||
return constructionUnitMapper.deleteConstructionUnitById(id); |
|||
} |
|||
|
|||
/** |
|||
* 根据主键id批量删除施工单位 |
|||
* |
|||
* @param list 待删除id列表 |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public Integer deleteConstructionUnitByIds(List<Integer> list) { |
|||
return constructionUnitMapper.deleteConstructionUnitByIds(list); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue