From 80a6306e4b7f1fde0a173547f5930b48764de037 Mon Sep 17 00:00:00 2001 From: liuxm <liuxm@fescotech.com> Date: 星期二, 07 五月 2024 13:57:26 +0800 Subject: [PATCH] 产品技术参数 --- pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProParamsMapper.java | 58 ++++++ pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductParams.java | 53 +++++ pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml | 4 pms-parent/pms-global/src/main/resources/mapper/PltProParamsMapper.xml | 155 +++++++++++++++++ pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proParam/ParamCtrl.java | 132 ++++++++++++++ pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proParam/ParamSv.java | 74 ++++++++ pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proParam/QueryVo.java | 14 + 7 files changed, 488 insertions(+), 2 deletions(-) diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProParamsMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProParamsMapper.java new file mode 100644 index 0000000..97a4669 --- /dev/null +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProParamsMapper.java @@ -0,0 +1,58 @@ +package com.dy.pmsGlobal.daoPlt; + +import com.dy.pmsGlobal.pojoPlt.PltProductParams; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +@Mapper +public interface PltProParamsMapper { + /** + * delete by primary key + * @param id primaryKey + * @return deleteCount + */ + int deleteByPrimaryKey(Long id); + + /** + * insert record to table + * @param record the record + * @return insert count + */ + int insert(PltProductParams record); + + /** + * insert record to table selective + * @param record the record + * @return insert count + */ + int insertSelective(PltProductParams record); + + /** + * select by primary key + * @param id primary key + * @return object by primary key + */ + PltProductParams selectByPrimaryKey(Long id); + + /** + * update record selective + * @param record the updated record + * @return update count + */ + int updateByPrimaryKeySelective(PltProductParams record); + + /** + * update record + * @param record the updated record + * @return update count + */ + int updateByPrimaryKey(PltProductParams record); + + int deleteLogicById(Long id); + + Long selectSomeCount(Map<String, Object> params); + + List<PltProductParams> selectSome(Map<String, Object> params); +} \ No newline at end of file diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductParams.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductParams.java new file mode 100644 index 0000000..c5306cf --- /dev/null +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductParams.java @@ -0,0 +1,53 @@ +package com.dy.pmsGlobal.pojoPlt; + +import com.alibaba.fastjson2.annotation.JSONField; +import com.alibaba.fastjson2.writer.ObjectWriterImplToString; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import jakarta.validation.constraints.NotEmpty; +import lombok.*; + +@TableName(value="plt_product_params", autoResultMap = true) +@Data +@Builder +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class PltProductParams { + /** + * 涓婚敭 + */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) + @TableId(value = "id", type = IdType.INPUT) + public Long id; + + /** + * 浜у搧瀹炰綋缂栧彿 + */ + public Long proId; + + /** + * 鎶�鏈弬鏁板悕绉� + */ + @NotEmpty(message = "鎶�鏈弬鏁板悕绉颁笉鑳戒负绌�") + public String paramName; + + /** + * 鎶�鏈弬鏁板�� + */ + @NotEmpty(message = "鎶�鏈弬鏁板�间笉鑳戒负绌�") + public String paramValue; + + /** + * 瀹夎鎵嬪唽缃戞枃 + */ + public Long installManual; + + /** + * 鐢ㄦ埛鎵嬪唽缃戞枃 + */ + public Long userManual; + + public Boolean deleted; +} \ No newline at end of file diff --git a/pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml index d3fb7b3..d395263 100644 --- a/pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml +++ b/pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml @@ -117,10 +117,10 @@ where id = #{id} </update> - <delete id="deleteLogicById" parameterType="java.lang.Long"> + <update id="deleteLogicById" parameterType="java.lang.Long"> update ba_role set deleted = 1 where id = #{id} - </delete> + </update> <select id="selectSomeCount" resultType="java.lang.Long"> select diff --git a/pms-parent/pms-global/src/main/resources/mapper/PltProParamsMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PltProParamsMapper.xml new file mode 100644 index 0000000..967f35f --- /dev/null +++ b/pms-parent/pms-global/src/main/resources/mapper/PltProParamsMapper.xml @@ -0,0 +1,155 @@ +<?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.PltProParamsMapper"> + <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPlt.PltProductParams"> + <!--@mbg.generated--> + <!--@Table plt_product_params--> + <id column="id" jdbcType="BIGINT" property="id" /> + <result column="pro_id" jdbcType="BIGINT" property="proId" /> + <result column="param_name" jdbcType="VARCHAR" property="paramName" /> + <result column="param_value" jdbcType="VARCHAR" property="paramValue" /> + <result column="install_manual" jdbcType="BIGINT" property="installManual" /> + <result column="user_manual" jdbcType="BIGINT" property="userManual" /> + <result column="deleted" property="deleted" typeHandler="com.dy.common.mybatis.BooleanTypeHandler" /> + </resultMap> + <sql id="Base_Column_List"> + <!--@mbg.generated--> + id, pro_id, param_name, param_value, install_manual, user_manual,deleted + </sql> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List" /> + from plt_product_params + where id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <!--@mbg.generated--> + delete from plt_product_params + where id = #{id,jdbcType=BIGINT} + </delete> + <insert id="insert" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductParams"> + <!--@mbg.generated--> + insert into plt_product_params (id, pro_id, param_name, + param_value, install_manual, user_manual,deleted + ) + values (#{id,jdbcType=BIGINT}, #{proId,jdbcType=BIGINT}, #{paramName,jdbcType=VARCHAR}, + #{paramValue,jdbcType=VARCHAR}, #{installManual,jdbcType=BIGINT}, #{userManual,jdbcType=BIGINT},#{deleted,jdbcType=TINYINT} + ) + </insert> + <insert id="insertSelective" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductParams"> + <!--@mbg.generated--> + insert into plt_product_params + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="proId != null"> + pro_id, + </if> + <if test="paramName != null"> + param_name, + </if> + <if test="paramValue != null"> + param_value, + </if> + <if test="installManual != null"> + install_manual, + </if> + <if test="userManual != null"> + user_manual, + </if> + <if test="deleted != null"> + deleted + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=BIGINT}, + </if> + <if test="proId != null"> + #{proId,jdbcType=BIGINT}, + </if> + <if test="paramName != null"> + #{paramName,jdbcType=VARCHAR}, + </if> + <if test="paramValue != null"> + #{paramValue,jdbcType=VARCHAR}, + </if> + <if test="installManual != null"> + #{installManual,jdbcType=BIGINT}, + </if> + <if test="userManual != null"> + #{userManual,jdbcType=BIGINT}, + </if> + <if test="deleted != null"> + #{deleted,jdbcType=TINYINT} + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductParams"> + <!--@mbg.generated--> + update plt_product_params + <set> + <if test="proId != null"> + pro_id = #{proId,jdbcType=BIGINT}, + </if> + <if test="paramName != null"> + param_name = #{paramName,jdbcType=VARCHAR}, + </if> + <if test="paramValue != null"> + param_value = #{paramValue,jdbcType=VARCHAR}, + </if> + <if test="installManual != null"> + install_manual = #{installManual,jdbcType=BIGINT}, + </if> + <if test="userManual != null"> + user_manual = #{userManual,jdbcType=BIGINT}, + </if> + </set> + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKey" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductParams"> + <!--@mbg.generated--> + update plt_product_params + set pro_id = #{proId,jdbcType=BIGINT}, + param_name = #{paramName,jdbcType=VARCHAR}, + param_value = #{paramValue,jdbcType=VARCHAR}, + install_manual = #{installManual,jdbcType=BIGINT}, + user_manual = #{userManual,jdbcType=BIGINT} + where id = #{id,jdbcType=BIGINT} + </update> + + <delete id="deleteLogicById"> + update plt_product_params set deleted = 1 where id = #{id} + </delete> + + <select id="selectSome" resultMap="BaseResultMap"> + select + <include refid="Base_Column_List" /> + from plt_product_params p + where p.deleted!=1 + <trim prefix="and " suffixOverrides="and"> + <if test="paramName != null and paramName != ''"> + p.param_name like concat('%', #{paramName}, '%') and + </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_product_params p + where p.deleted!=1 + <trim prefix="and " suffixOverrides="and"> + <if test="paramName != null and paramName != ''"> + p.param_name like concat('%', #{paramName}, '%') and + </if> + </trim> + </select> +</mapper> \ No newline at end of file diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proParam/ParamCtrl.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proParam/ParamCtrl.java new file mode 100644 index 0000000..0b2ae36 --- /dev/null +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proParam/ParamCtrl.java @@ -0,0 +1,132 @@ +package com.dy.pmsPlatform.proParam; + +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.PltProductParams; +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="param") +@SuppressWarnings("unchecked") +public class ParamCtrl { + private ParamSv sv; + @Autowired + public ParamCtrl(ParamSv sv){ + this.sv = sv; + } + + /** + * 淇濆瓨浜у搧鎶�鏈弬鏁颁俊鎭� + * @param param + * @param bindingResult + * @return + */ + @PostMapping(path="save") + @SsoPowerAop(power = "10100011") + @Log("淇濆瓨浜у搧鎶�鏈弬鏁颁俊鎭�") + public BaseResponse<PltProductParams> save(@RequestBody @Valid PltProductParams param,BindingResult bindingResult){ + try { + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + param.deleted = false; + return BaseResponseUtils.buildSuccess(sv.save(param)); + }catch (Exception e){ + log.error("淇濆瓨浜у搧鎶�鏈弬鏁板紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + + /** + * 鏇存柊浜у搧鎶�鏈弬鏁颁俊鎭� + * @param param + * @param bindingResult + * @return + */ + @PostMapping(path="update") + @SsoPowerAop(power = "10100011") + @Log("鏇存柊浜у搧鎶�鏈弬鏁颁俊鎭�") + public BaseResponse<PltProductParams> update(@RequestBody @Valid PltProductParams param,BindingResult bindingResult){ + try { + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + return BaseResponseUtils.buildSuccess(sv.update(param)); + }catch (Exception e){ + log.error("鏇存柊浜у搧鎶�鏈弬鏁板紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + /** + * 鍒犻櫎浜у搧鎶�鏈弬鏁颁俊鎭� + * @param id + * @return + */ + @GetMapping(path="delete") + @SsoPowerAop(power = "10100011") + @Log("鍒犻櫎浜у搧鎶�鏈弬鏁颁俊鎭�") + public BaseResponse<PltProductParams> 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 = "10100010") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇� + @Log("鏍规嵁ID鏌ヨ浜у搧鎶�鏈弬鏁颁俊鎭�") + public BaseResponse<PltProductParams> one(String id){ + try{ + PltProductParams param=sv.selectById(id); + return BaseResponseUtils.buildSuccess(JSON.toJSON(param)); + }catch (Exception e){ + log.error("鏌ヨ浜у搧鎶�鏈弬鏁板紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + /** + * 鏌ヨ浜у搧鎶�鏈弬鏁颁俊鎭� + * @param vo + * @return + */ + @PostMapping(path="some") + @SsoPowerAop(power = "10100010") + @Log("鏌ヨ浜у搧鎶�鏈弬鏁颁俊鎭�") + public BaseResponse<QueryResultVo<List<PltProductParams>>> some(@RequestBody QueryVo vo){ + try { + QueryResultVo<List<PltProductParams>> list = sv.selectSome(vo) ; + return BaseResponseUtils.buildSuccess(list); + }catch (Exception e){ + log.error("鏌ヨ浜у搧鎶�鏈弬鏁板紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + +} + diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proParam/ParamSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proParam/ParamSv.java new file mode 100644 index 0000000..713b788 --- /dev/null +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proParam/ParamSv.java @@ -0,0 +1,74 @@ +package com.dy.pmsPlatform.proParam; + +import com.dy.common.webUtil.QueryResultVo; +import com.dy.pmsGlobal.daoPlt.PltProParamsMapper; +import com.dy.pmsGlobal.pojoPlt.PltProductParams; +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 ParamSv { + + private PltProParamsMapper dao; + + @Autowired + public void setDao(PltProParamsMapper dao) { + this.dao = dao; + } + + @Transactional + public int save(PltProductParams param) { + int count = dao.insert(param); + return count; + } + + /** + * 閫昏緫鍒犻櫎瀹炰綋 + * @param id 瀹炰綋ID + * @return 褰卞搷璁板綍鏁伴噺 + */ + @Transactional + public int delete(Long id) { + return this.dao.deleteLogicById(id); + } + + + + @Transactional + public int update(PltProductParams param) { + int count = dao.updateByPrimaryKeySelective(param); + return count; + } + + + public PltProductParams selectById(String paramId) { + return dao.selectByPrimaryKey(Long.valueOf(paramId)); + } + + /** + * 鑾峰彇鍙傛暟鍒楄〃 + */ + public QueryResultVo<List<PltProductParams>> selectSome(QueryVo queryVo) { + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); + + //鏌ヨ绗﹀悎鏉′欢鐨勮褰曟�绘暟 + Long itemTotal = this.dao.selectSomeCount(params); + + QueryResultVo<List<PltProductParams>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ; + //璁$畻鍒嗛〉绛変俊鎭� + rsVo.calculateAndSet(itemTotal, params); + + //鏌ヨ绗﹀悎鏉′欢鐨勮褰� + rsVo.obj = this.dao.selectSome(params) ; + return rsVo ; + } + +} + diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proParam/QueryVo.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proParam/QueryVo.java new file mode 100644 index 0000000..e3c0bbe --- /dev/null +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proParam/QueryVo.java @@ -0,0 +1,14 @@ +package com.dy.pmsPlatform.proParam; + +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 paramName; +} -- Gitblit v1.8.0