pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaDistrictMapper.java
@@ -10,34 +10,6 @@ @Mapper public interface BaDistrictMapper extends BaseMapper<BaPrivilege> { /** * delete by primary key * @param id primaryKey * @return deleteCount */ int deleteByPrimaryKey(Long id); /** * 逻辑删除 * @param id primaryKey * @return update count */ int deleteLogicById(Long id); /** * insert record to table * @param record the record * @return insert count */ int insert(BaDistrict record); /** * insert record to table selective * @param record the record * @return insert count */ int insertSelective(BaDistrict record); /** * select by primary key * @param id primary key * @return object by primary key @@ -59,6 +31,21 @@ List<BaDistrict> selectBySupperId(Long supperId) ; /** * insert record to table * @param record the record * @return insert count */ int insert(BaDistrict record); /** * insert record to table selective * @param record the record * @return insert count */ int insertSelective(BaDistrict record); /** * update record selective * @param record the updated record * @return update count @@ -71,4 +58,19 @@ * @return update count */ int updateByPrimaryKey(BaDistrict record); /** * delete by primary key * @param id primaryKey * @return deleteCount */ int deleteByPrimaryKey(Long id); /** * 逻辑删除 * @param id primaryKey * @return update count */ int deleteLogicById(Long id); } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaUserMapper.java
@@ -1,7 +1,6 @@ package com.dy.pipIrrGlobal.daoBa; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dy.pipIrrGlobal.pojoBa.BaBlock; import com.dy.pipIrrGlobal.pojoBa.BaUser; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -36,39 +35,46 @@ List<BaUser> selectSome(Map<?, ?> params) ; // // /** // * 插入一条记录 // * @param userPo // * @return // */ // long insertSelective(BaUser userPo); // // /** // * 插入一条记录,如果唯一键冲突则更新 // * @param userPo // * @return // */ // long insertOnDuplicateUpdate(BaUser userPo); // // /** // * 更新一条记录 // * @param userPo // * @return // */ // int updateSelective(BaUser userPo); // // /** // * 批量插入 // * @param userPoList // * @return // */ // int batchInsert(List<BaUser> userPoList); // // /** // * 批量更新 // * @param userPoList // * @return // */ // int batchUpdate(List<BaUser> userPoList); /** * insert record to table * @param record the record * @return insert count */ int insert(BaUser record); /** * insert record to table selective * @param record the record * @return insert count */ int insertSelective(BaUser record); /** * update record selective * @param record the updated record * @return update count */ int updateByPrimaryKeySelective(BaUser record); /** * update record * @param record the updated record * @return update count */ int updateByPrimaryKey(BaUser record); /** * delete by primary key * @param id primaryKey * @return deleteCount */ int deleteByPrimaryKey(Long id); /** * 逻辑删除 * @param id primaryKey * @return update count */ int deleteLogicById(Long id); } pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaDistrictMapper.xml
@@ -35,16 +35,6 @@ from ba_district where supperId = #{supperId,jdbcType=BIGINT} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> <!--@mbg.generated--> delete from ba_district where id = #{id,jdbcType=BIGINT} </delete> <delete id="deleteLogicById" parameterType="java.lang.Long"> <!--@mbg.generated--> update ba_district set deleted = 1 where id = #{id,jdbcType=BIGINT} </delete> <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoBa.BaDistrict"> <!--@mbg.generated--> insert into ba_district (id, supperId, `name`, `level`, deleted) @@ -121,4 +111,14 @@ deleted = #{deleted,jdbcType=TINYINT} where id = #{id,jdbcType=BIGINT} </update> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> <!--@mbg.generated--> delete from ba_district where id = #{id,jdbcType=BIGINT} </delete> <delete id="deleteLogicById" parameterType="java.lang.Long"> <!--@mbg.generated--> update ba_district set deleted = 1 where id = #{id,jdbcType=BIGINT} </delete> </mapper> pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserMapper.xml
@@ -90,74 +90,26 @@ </if> </trim> </select> <!-- <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUser"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long" id="selectKey"> SELECT LAST_INSERT_ID() </selectKey> insert into ba_user <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="name != null"> name, </if> <if test="phone != null"> phone, </if> <if test="password != null"> password, </if> <if test="orgTag != null"> orgTag, </if> <if test="supperAdmin != null"> supperAdmin, </if> <if test="disabled != null"> disabled, </if> <if test="deleted != null"> deleted, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> #{id, jdbcType=BIGINT}, </if> <if test="name != null"> #{name, jdbcType=VARCHAR}, </if> <if test="phone != null"> #{phone, jdbcType=VARCHAR}, </if> <if test="password != null"> #{password, jdbcType=VARCHAR}, </if> <if test="orgTag != null"> #{orgTag, jdbcType=VARCHAR}, </if> <if test="supperAdmin != null"> #{supperAdmin, jdbcType=SMALLINT}, </if> <if test="disabled != null"> #{disabled, jdbcType=SMALLINT}, </if> <if test="deleted != null"> #{deleted, jdbcType=SMALLINT}, </if> </trim> <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUser"> insert into ba_user (<include refid="Base_Column_List" />) values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{orgTag,jdbcType=VARCHAR}, #{supperAdmin,jdbcType=TINYINT}, #{disabled,jdbcType=TINYINT}, #{deleted,jdbcType=TINYINT} ) </insert> <insert id="insertOnDuplicateUpdate" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUser"> <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUser"> insert into ba_user <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="name != null"> name, `name`, </if> <if test="phone != null"> phone, @@ -171,109 +123,77 @@ <if test="supperAdmin != null"> supperAdmin, </if> <if test="disabled != null"> disabled, <if test="disabled != null"> disabled, </if> <if test="deleted != null"> <if test="deleted != null"> deleted, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> #{id, jdbcType=BIGINT}, #{id,jdbcType=BIGINT}, </if> <if test="name != null"> #{name, jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, </if> <if test="phone != null"> #{phone, jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, </if> <if test="password != null"> #{password, jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, </if> <if test="orgTag != null"> #{orgTag, jdbcType=VARCHAR}, #{orgTag,jdbcType=VARCHAR}, </if> <if test="supperAdmin != null"> #{supperAdmin, jdbcType=SMALLINT}, #{supperAdmin,jdbcType=TINYINT}, </if> <if test="disabled != null"> #{disabled, jdbcType=SMALLINT}, #{disabled,jdbcType=TINYINT}, </if> <if test="deleted != null"> #{deleted, jdbcType=SMALLINT}, </if> </trim> ON DUPLICATE KEY UPDATE <trim suffixOverrides="," > <if test="id != null" > id = #{id, jdbcType=BIGINT}, #{deleted,jdbcType=TINYINT}, </if> </trim> </insert> <update id="updateSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUser" > UPDATE ba_user <set > <if test="name != null" > name = #{name, jdbcType=VARCHAR}, <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUser"> update ba_user <set> <if test="name != null"> `name` = #{name,jdbcType=VARCHAR}, </if> <if test="phone != null" > phone = #{phone, jdbcType=VARCHAR}, <if test="phone != null"> phone = #{phone,jdbcType=VARCHAR}, </if> <if test="password != null" > phone = #{password, jdbcType=VARCHAR}, <if test="password != null"> password = #{password,jdbcType=VARCHAR}, </if> <if test="disabled != null"> disabled = #{disabled,jdbcType=TINYINT}, </if> <if test="deleted != null"> deleted = #{deleted,jdbcType=TINYINT}, </if> </set> WHERE <trim prefixOverrides="and | or"> <if test="id != null"> AND id = #{id,jdbcType=BIGINT} </if> </trim> where id = #{id,jdbcType=BIGINT} </update> <insert id="batchInsert" parameterType="java.util.List"> <selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER" id="batchInsert"> SELECT LAST_INSERT_ID() </selectKey> INSERT INTO ba_user(id, name, phone, password, orgTag, supperAdmin, disabled, deleted) VALUES <foreach collection="list" item="it" index="index" separator=","> ( #{it.id, jdbcType=BIGINT}, #{it.name, jdbcType=VARCHAR}, #{it.phone, jdbcType=VARCHAR}, #{it.password, jdbcType=VARCHAR}, #{it.orgTag, jdbcType=VARCHAR}, #{it.supperAdmin, jdbcType=SMALLINT}, #{it.disabled, jdbcType=SMALLINT}, #{it.deleted, jdbcType=SMALLINT} ) </foreach> </insert> <update id="batchUpdate" parameterType="java.util.List"> <foreach collection="list" item="it" separator=";"> UPDATE ba_user <set > <if test="it.name != null" > name = #{it.name, jdbcType=VARCHAR}, </if> <if test="it.phone != null" > phone = #{it.phone, jdbcType=VARCHAR}, </if> <if test="it.password != null" > phone = #{it.password, jdbcType=VARCHAR}, </if> </set> WHERE <trim prefixOverrides="and | or"> <if test="it.id != null"> AND id = #{it.id,jdbcType=BIGINT} </if> </trim> </foreach> <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUser"> update ba_user set `name` = #{name,jdbcType=VARCHAR}, phone = #{phone,jdbcType=VARCHAR}, password = #{password,jdbcType=VARCHAR}, disabled = #{disabled,jdbcType=TINYINT}, deleted = #{deleted,jdbcType=TINYINT} where id = #{id,jdbcType=BIGINT} </update> --> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> delete from ba_user where id = #{id,jdbcType=BIGINT} </delete> <delete id="deleteLogicById" parameterType="java.lang.Long"> update ba_user set deleted = 1 where id = #{id,jdbcType=BIGINT} </delete> </mapper> pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/block/BlockCtrl.java
@@ -54,6 +54,7 @@ ) }) @PostMapping(path = "some") @SsoAop("-1") public BaseResponse<QueryResultVo<List<BaBlock>>> some(QueryVo vo){ try { QueryResultVo<List<BaBlock>> res = this.sv.selectSome(vo) ; @@ -78,6 +79,7 @@ ) }) @GetMapping(path = "one") @SsoAop("-1") public BaseResponse<BaBlock> one(@Parameter(description = "实体id", required = true) Long id){ return BaseResponseUtils.buildSuccess(this.sv.selectById(id)); } pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/block/BlockSv.java
@@ -7,6 +7,8 @@ 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.Map; import java.util.List; @@ -54,6 +56,7 @@ * @param po 实体 * @return 数量 */ @Transactional public int save(BaBlock po){ return this.dao.insert(po) ; } @@ -63,6 +66,7 @@ * @param po 实体 * @return 数量 */ @Transactional public int update(BaBlock po){ return this.dao.updateByPrimaryKeySelective(po) ; } @@ -72,6 +76,7 @@ * @param id 实体ID * @return 数量 */ @Transactional public int delete(Long id){ return this.dao.deleteLogicById(id) ; } pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java
@@ -74,6 +74,7 @@ ) }) @GetMapping(path = "all") @SsoAop("-1") public BaseResponse<List<BaDistrict>> all(){ List<BaDistrict> list = this.sv.selectAllByLevel(DistrictLevel.City.code) ; return BaseResponseUtils.buildSuccess(list); @@ -93,6 +94,7 @@ ) }) @GetMapping(path = "one") @SsoAop("-1") public BaseResponse<BaDistrict> one(@Parameter(description = "实体id", required = true) Long id){ return BaseResponseUtils.buildSuccess(this.sv.selectById(id)); } pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java
@@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -17,33 +18,6 @@ @Autowired private void setDao(BaDistrictMapper dao){ this.dao = dao; } /** * 保存实体 * @param po 实体 * @return 数量 */ public int save(BaDistrict po){ return this.dao.insert(po) ; } /** * 保存修改实体 * @param po 实体 * @return 数量 */ public int update(BaDistrict po){ return this.dao.updateByPrimaryKeySelective(po) ; } /** * 保存修改实体 * @param id 实体ID * @return 数量 */ public int delete(Long id){ return this.dao.deleteLogicById(id) ; } /** @@ -71,6 +45,36 @@ } /** * 保存实体 * @param po 实体 * @return 数量 */ @Transactional public int save(BaDistrict po){ return this.dao.insert(po) ; } /** * 保存修改实体 * @param po 实体 * @return 数量 */ @Transactional public int update(BaDistrict po){ return this.dao.updateByPrimaryKeySelective(po) ; } /** * 保存修改实体 * @param id 实体ID * @return 数量 */ @Transactional public int delete(Long id){ return this.dao.deleteLogicById(id) ; } /** * 得到下级行政区划 * @param po 上级行政区划 */ pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserCtrl.java
@@ -1,5 +1,6 @@ package com.dy.pipIrrBase.user; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; @@ -12,15 +13,18 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.validation.BindingResult; 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 java.util.List; import java.util.Objects; @Slf4j @Tag(name = "用户管理", description = "用户增删改查等操作") @@ -50,6 +54,7 @@ ) }) @PostMapping(path = "some") @SsoAop("-1") public BaseResponse<QueryResultVo<List<BaUser>>> some(QueryVo vo){ try { QueryResultVo<List<BaUser>> res = this.sv.selectSome(vo) ; @@ -74,8 +79,115 @@ ) }) @GetMapping(path = "one") @SsoAop("-1") public BaseResponse<BaUser> one(@Parameter(description = "实体id", required = true) Long id){ return BaseResponseUtils.buildSuccess(this.sv.selectById(id)); } /** * 保存用户 * @param po 保存用户form表单对象 * @return 是否成功 */ @Operation(summary = "保存用户", description = "提交用户数据(form表单),进行保存") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "save", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @SsoAop("-1")//@SsoAop(power = "-1") public BaseResponse<Boolean> save(@Parameter(description = "form表单数据", required = true) @Valid BaUser po, @Parameter(hidden = true) BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } po.id = null ; int count; try { count = this.sv.save(po); } catch (Exception e) { log.error("保存用户异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } } /** * 编辑修改用户 * @param po 保存用户form表单对象 * @return 是否成功 */ @Operation(summary = "编辑修改用户", description = "提交用户数据(form表单),进行修改") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "update", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @SsoAop("-1")//@SsoAop(power = "-1") public BaseResponse<Boolean> update(@Parameter(description = "form表单数据", required = true) @Valid BaUser po, @Parameter(hidden = true) BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } if(po.id == null){ return BaseResponseUtils.buildFail("无数据实体ID") ; } int count; try { count = this.sv.update(po); } catch (Exception e) { log.error("保存用户异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } } /** * 删除用户 * @param id 用户ID * @return 是否成功 */ @Operation(summary = "删除用户", description = "提交用户ID,进行逻辑删除") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @GetMapping(path = "delete", consumes = MediaType.TEXT_PLAIN_VALUE) @SsoAop("-1")//@SsoAop(power = "-1") public BaseResponse<Boolean> delete(@Parameter(description = "实体id", required = true) Long id){ if(id == null){ return BaseResponseUtils.buildFail("id不能为空") ; } int count; try { count = this.sv.delete(id); } catch (Exception e) { log.error("保存用户异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } } } pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java
@@ -3,6 +3,7 @@ import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.daoBa.BaUserMapper; import com.dy.pipIrrGlobal.pojoBa.BaDistrict; import com.dy.pipIrrGlobal.pojoBa.BaUser; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -12,6 +13,7 @@ import java.util.Map; import org.apache.dubbo.common.utils.PojoUtils ; import org.springframework.transaction.annotation.Transactional; @Slf4j @Service @@ -53,4 +55,34 @@ return rsVo ; } /** * 保存实体 * @param po 实体 * @return 数量 */ @Transactional public int save(BaUser po){ return this.dao.insert(po) ; } /** * 保存修改实体 * @param po 实体 * @return 数量 */ @Transactional public int update(BaUser po){ return this.dao.updateByPrimaryKeySelective(po) ; } /** * 保存修改实体 * @param id 实体ID * @return 数量 */ @Transactional public int delete(Long id){ return this.dao.deleteLogicById(id) ; } }