pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltStation.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/QueryVo.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java
New file @@ -0,0 +1,38 @@ package com.dy.pmsGlobal.daoPlt; import com.dy.pmsGlobal.pojoPlt.PltStation; import org.apache.ibatis.annotations.Mapper; import java.util.List; import java.util.Map; /** * @author 小明 * @description 针对表【plt_station(工站表)】的数据库操作Mapper * @createDate 2024-05-09 17:13:22 * @Entity com.dy.pmsGlobal.pojoPlt.PltStation */ @Mapper public interface PltStationMapper { int deleteByPrimaryKey(Long id); int insert(PltStation record); int insertSelective(PltStation record); PltStation selectByPrimaryKey(Long id); long selectByCodeId(Long id,String code); int updateByPrimaryKeySelective(PltStation record); int updateByPrimaryKey(PltStation record); Long selectSomeCount(Map<String,Object> params); List<PltStation> selectSome(Map<String,Object> params); int deleteLogicById(Long id); } pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltStation.java
New file @@ -0,0 +1,58 @@ package com.dy.pmsGlobal.pojoPlt; import com.baomidou.mybatisplus.annotation.*; import com.fasterxml.jackson.annotation.JsonFormat; import jakarta.validation.constraints.NotEmpty; import lombok.*; import org.hibernate.validator.constraints.Length; import java.util.Date; /** * 工站表 * @TableName plt_station */ @TableName(value="plt_station", autoResultMap = true) @Data @Builder @ToString @NoArgsConstructor @AllArgsConstructor public class PltStation{ /** * */ @TableId(type = IdType.AUTO) public Long id; /** * 编号 */ @NotEmpty(message = "编号不能为空") @Length(message = "编号必须{max}位数据", min = 4, max = 4) public String code; /** * 名称 */ @NotEmpty(message = "名称不能为空") public String name; /** * 备注 */ public String remark; /** * 创建时间 */ @TableField(value = "dt", fill = FieldFill.INSERT) // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") public Date dt; /** * 是否删除,1是,0否 */ public Boolean deleted; } pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml
New file @@ -0,0 +1,131 @@ <?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.dy.pmsGlobal.daoPlt.PltStationMapper"> <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPlt.PltStation"> <id property="id" column="id" jdbcType="BIGINT"/> <result property="code" column="code" jdbcType="VARCHAR"/> <result property="name" column="name" jdbcType="VARCHAR"/> <result property="remark" column="remark" jdbcType="VARCHAR"/> <result property="dt" column="dt" jdbcType="TIMESTAMP"/> <result property="deleted" column="deleted" jdbcType="TINYINT"/> </resultMap> <sql id="Base_Column_List"> id,code,name, remark,dt,deleted </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from plt_station where id = #{id,jdbcType=BIGINT} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> delete from plt_station where id = #{id,jdbcType=BIGINT} </delete> <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltStation" useGeneratedKeys="true"> insert into plt_station ( id,code,name ,remark,deleted ) values (#{id,jdbcType=BIGINT},#{code,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR} ,#{remark,jdbcType=VARCHAR},#{deleted,jdbcType=TINYINT} ) </insert> <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltStation" useGeneratedKeys="true"> insert into plt_station <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null">id,</if> <if test="code != null">code,</if> <if test="name != null">name,</if> <if test="remark != null">remark,</if> <if test="deleted != null">deleted,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id,jdbcType=BIGINT},</if> <if test="code != null">#{code,jdbcType=VARCHAR},</if> <if test="name != null">#{name,jdbcType=VARCHAR},</if> <if test="remark != null">#{remark,jdbcType=VARCHAR},</if> <if test="deleted != null">#{deleted,jdbcType=TINYINT},</if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoPlt.PltStation"> update plt_station <set> <if test="code != null"> code = #{code,jdbcType=VARCHAR}, </if> <if test="name != null"> name = #{name,jdbcType=VARCHAR}, </if> <if test="remark != null"> remark = #{remark,jdbcType=VARCHAR}, </if> <if test="deleted != null"> deleted = #{deleted,jdbcType=TINYINT}, </if> </set> where id = #{id,jdbcType=BIGINT} </update> <update id="updateByPrimaryKey" parameterType="com.dy.pmsGlobal.pojoPlt.PltStation"> update plt_station set code = #{code,jdbcType=VARCHAR}, name = #{name,jdbcType=VARCHAR}, remark = #{remark,jdbcType=VARCHAR}, deleted = #{deleted,jdbcType=TINYINT} where id = #{id,jdbcType=BIGINT} </update> <select id="selectSome" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from plt_station where deleted!=1 <trim prefix="and" suffixOverrides="and"> <if test="code != null and code !=''"> code = #{code,jdbcType=VARCHAR} and </if> <if test="name != null and name !=''"> name like concat('%', #{name}, '%') </if> </trim> order by id desc <trim prefix="limit " > <if test="start != null and count != null"> #{start}, #{count} </if> </trim> </select> <select id="selectSomeCount" resultType="java.lang.Long"> select count(1) from plt_station where deleted!=1 <trim prefix="and" suffixOverrides="and"> <if test="code != null and code !=''"> code = #{code,jdbcType=VARCHAR} and </if> <if test="name != null and name !=''"> name like concat('%', #{name}, '%') </if> </trim> </select> <select id="selectByCodeId" resultType="java.lang.Long"> select count(1) from plt_station where code = #{code} and deleted!=1 <trim prefix="and" suffixOverrides="and"> <if test="id != null"> id != #{id} </if> </trim> </select> <update id="deleteLogicById" parameterType="java.lang.Long"> update plt_station set deleted = 1 where id = #{id} </update> </mapper> pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/QueryVo.java
New file @@ -0,0 +1,16 @@ package com.dy.pmsPlatform.station; import com.dy.common.webUtil.QueryConditionVo; import lombok.*; @Data @EqualsAndHashCode(callSuper = false) @ToString(callSuper = true) @NoArgsConstructor @AllArgsConstructor @Builder public class QueryVo extends QueryConditionVo { public String name; public String code; } pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java
New file @@ -0,0 +1,132 @@ package com.dy.pmsPlatform.station; import com.alibaba.fastjson2.JSON; import com.dy.common.aop.SsoPowerAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.pmsGlobal.aop.Log; import com.dy.pmsGlobal.pojoPlt.PltStation; import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Objects; /** * 工站 */ @Slf4j @RestController @RequestMapping(path="station") @SuppressWarnings("unchecked") public class StationCtrl { private StationSv sv; @Autowired public StationCtrl(StationSv sv){ this.sv = sv; } /** * 保存 * @param station * @param bindingResult * @return */ @PostMapping(path="save") @SsoPowerAop(power = "10300001") @Log("保存工站") public BaseResponse<PltStation> save(@RequestBody @Valid PltStation station,BindingResult bindingResult){ try { if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } station.deleted = false; return BaseResponseUtils.buildSuccess(sv.save(station)); }catch (Exception e){ log.error("保存工站异常", e); return BaseResponseUtils.buildException(e.getMessage()); } } /** * 更新 * @param station * @param bindingResult * @return */ @PostMapping(path="update") @SsoPowerAop(power = "10300001") @Log("更新工站") public BaseResponse<PltStation> update(@RequestBody @Valid PltStation station,BindingResult bindingResult){ try { if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } return BaseResponseUtils.buildSuccess(sv.update(station)); }catch (Exception e){ log.error("更新工站异常", e); return BaseResponseUtils.buildException(e.getMessage()); } } /** * 删除 * @param id * @return */ @GetMapping(path="delete") @SsoPowerAop(power = "10300001") @Log("删除工站") public BaseResponse<PltStation> delete(String id){ try { return BaseResponseUtils.buildSuccess(sv.delete(Long.parseLong(id))); }catch (Exception e){ log.error("删除工站异常", e); return BaseResponseUtils.buildException(e.getMessage()); } } /** * 根据ID查询 * @return */ @GetMapping(path="one") @SsoPowerAop(power = "10300000") //登录与权限同时验证 @Log("根据ID查询工站") public BaseResponse<PltStation> one(String id){ try{ PltStation param=sv.selectById(id); return BaseResponseUtils.buildSuccess(JSON.toJSON(param)); }catch (Exception e){ log.error("根据ID查询工站异常", e); return BaseResponseUtils.buildException(e.getMessage()); } } /** * 分页查询 * @param vo * @return */ @PostMapping(path="some") @SsoPowerAop(power = "10300000") @Log("分页查询工站") public BaseResponse<QueryResultVo<List<PltStation>>> some(@RequestBody QueryVo vo){ try { QueryResultVo<List<PltStation>> list = sv.selectSome(vo) ; return BaseResponseUtils.buildSuccess(list); }catch (Exception e){ log.error("分页查询工站异常", e); return BaseResponseUtils.buildException(e.getMessage()); } } } pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java
New file @@ -0,0 +1,80 @@ package com.dy.pmsPlatform.station; import com.dy.common.webUtil.QueryResultVo; import com.dy.pmsGlobal.daoPlt.PltStationMapper; import com.dy.pmsGlobal.pojoPlt.PltStation; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Map; @Slf4j @Service public class StationSv { private PltStationMapper dao; @Autowired public void setDao(PltStationMapper dao) { this.dao = dao; } @Transactional public int save(PltStation station) throws Exception { if(dao.selectByCodeId(station.id,station.code)>0){ throw new Exception("工站编号已存在"); } int count = dao.insertSelective(station); return count; } /** * 逻辑删除实体 * @param id 实体ID * @return 影响记录数量 */ @Transactional public int delete(Long id) { return this.dao.deleteLogicById(id); } @Transactional public int update(PltStation station) throws Exception { if(dao.selectByCodeId(station.id,station.code)>0){ throw new Exception("工站编号已存在"); } int count = dao.updateByPrimaryKeySelective(station); return count; } public PltStation selectById(String stationId) { return dao.selectByPrimaryKey(Long.valueOf(stationId)); } /** * 获取列表 */ public QueryResultVo<List<PltStation>> selectSome(QueryVo queryVo) { Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); //查询符合条件的记录总数 Long itemTotal = this.dao.selectSomeCount(params); QueryResultVo<List<PltStation>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ; //计算分页等信息 rsVo.calculateAndSet(itemTotal, params); //查询符合条件的记录 rsVo.obj = this.dao.selectSome(params) ; return rsVo ; } }