• 0619


    entity:

    package com.meta.hrpz.domain.entity;
    
    import com.alibaba.fastjson.JSON;
    import lombok.Data;
    
    /**
     * 通知领域成员对象 t_notice_service_members
     *
     * @author jingyan
     * @date 2022-06-19
     */
    @Data
    public class NoticeServiceMembers {
    
        /**
         * 领域
         */
        private String service;
    
        /**
         * 员工id
         */
        private String employeeId;
    
        /**
         * 用户名
         */
        private String userName;
    
        @Override
        public String toString() {
            return JSON.toJSONString(this);
        }
    }

    listParam:

    package com.meta.hrpz.domain.vo.req;
    
    import com.alibaba.fastjson.JSON;
    import com.meta.hrpz.domain.entity.NoticeServiceMembers;
    import lombok.Data;
    import org.springframework.beans.BeanUtils;
    
    /**
     * 通知领域成员 listParamVo对象
     *
     * @author zhudong
     * @date 2022-06-19
     */
    @Data
    public class NoticeServiceMembersListParamVo {
    
        /**
         * 页码
         */
        private Integer pageNum = 1;
    
        /**
         * 页数
         */
        private Integer pageSize = 10;
    
        /**
         * 领域
         */
        private String service;
    
        /**
         * 员工id
         */
        private String employeeId;
    
        /**
         * 用户名
         */
        private String userName;
    
        public NoticeServiceMembers toEntity() {
            NoticeServiceMembers entity = new NoticeServiceMembers();
            BeanUtils.copyProperties(this, entity);
            return entity;
        }
    
        @Override
        public String toString() {
            return JSON.toJSONString(this);
        }
    }

    新增参数类:

    package com.meta.hrpz.domain.vo.req;
    
    import com.alibaba.fastjson.JSON;
    import com.meta.hrpz.domain.entity.NoticeServiceMembers;
    import lombok.Data;
    import org.hibernate.validator.constraints.Length;
    import org.springframework.beans.BeanUtils;
    
    import javax.validation.constraints.NotBlank;
    
    /**
     * 保存通知领域成员入参
     *
     * @author zhudong
     * @date 2022-06-19
     */
    @Data
    public class SaveNoticeServiceMembersCmd {
    
        /**
         * 领域
         */
        @NotBlank(message = "领域不能为空")
        @Length(max = 64, message = "领域不能超过64个字符")
        private String service;
    
        /**
         * 员工id
         */
        @NotBlank(message = "员工id不能为空")
        @Length(max = 64, message = "员工id不能超过64个字符")
        private String employeeId;
    
        /**
         * 用户名
         */
        @NotBlank(message = "用户名不能为空")
        @Length(max = 64, message = "用户名不能超过64个字符")
        private String userName;
    
        public NoticeServiceMembers toEntity() {
            NoticeServiceMembers entity = new NoticeServiceMembers();
            BeanUtils.copyProperties(this, entity);
            return entity;
        }
    
        @Override
        public String toString() {
            return JSON.toJSONString(this);
        }
    }

    service:

    package com.meta.hrpz.service;
    
    import com.meta.common.core.domain.ResponseVo;
    import com.meta.common.core.page.TableDataInfo;
    import com.meta.hrpz.domain.entity.NoticeServiceMembers;
    import com.meta.hrpz.domain.vo.req.NoticeServiceMembersListParamVo;
    import com.meta.hrpz.domain.vo.req.SaveNoticeServiceMembersCmd;
    
    /**
     * 通知领域成员Service接口
     *
     * @author jiangyan
     * @date 2022-06-19
     */
    public interface NoticeServiceMembersService {
    
        /**
         * 分页查询列表
         *
         * @param paramVo 参数
         * @return 分页数据
         */
        TableDataInfo<NoticeServiceMembers> list(NoticeServiceMembersListParamVo paramVo);
    
        /**
         * 新增
         */
        ResponseVo<Void> add(SaveNoticeServiceMembersCmd cmd);
    
        /**
         * 删除
         */
        ResponseVo<Void> delete(NoticeServiceMembers param);
    
    }

    serviceImpl:

    package com.meta.hrpz.service.impl;
    
    import com.github.pagehelper.PageHelper;
    import com.github.pagehelper.PageInfo;
    import com.meta.common.core.domain.ResponseVo;
    import com.meta.common.core.page.TableDataInfo;
    import com.meta.hrpz.domain.entity.NoticeServiceMembers;
    import com.meta.hrpz.domain.vo.req.NoticeServiceMembersListParamVo;
    import com.meta.hrpz.domain.vo.req.SaveNoticeServiceMembersCmd;
    import com.meta.hrpz.mapper.NoticeServiceMembersMapper;
    import com.meta.hrpz.service.NoticeServiceMembersService;
    import lombok.extern.slf4j.Slf4j;
    import org.apache.commons.lang3.StringUtils;
    import org.springframework.stereotype.Service;
    
    import javax.annotation.Resource;
    import java.util.List;
    
    /**
     * 通知领域成员Service业务层处理
     *
     * @author jiangyan
     * @date 2022-06-19
     */
    @Service
    @Slf4j
    public class NoticeServiceMembersServiceImpl implements NoticeServiceMembersService {
    
        @Resource
        private NoticeServiceMembersMapper noticeServiceMembersMapper;
    
        /**
         * 分页查询列表
         *
         * @param paramVo 查询参数
         * @return 结果
         */
        @Override
        public TableDataInfo<NoticeServiceMembers> list(NoticeServiceMembersListParamVo paramVo) {
    
            PageHelper.startPage(paramVo.getPageNum(), paramVo.getPageSize());
            List<NoticeServiceMembers> noticeServiceMembersList = noticeServiceMembersMapper.queryListByCondition(paramVo.toEntity());
            PageInfo<NoticeServiceMembers> pageInfo = new PageInfo<>(noticeServiceMembersList);
    
            return new TableDataInfo<>(noticeServiceMembersList, pageInfo.getTotal());
        }
    
        /**
         * 新增通知领域成员
         *
         * @param cmd 参数
         * @return 结果
         */
        @Override
        public ResponseVo<Void> add(SaveNoticeServiceMembersCmd cmd) {
            NoticeServiceMembers existEntity = noticeServiceMembersMapper.queryByServiceAndEmployeeId(cmd.getService(), cmd.getEmployeeId());
            if (existEntity != null) {
                return ResponseVo.error("该数据已存在,请确认后再试");
            }
            int insertCount = noticeServiceMembersMapper.insertSelective(cmd.toEntity());
            log.info("新增通知领域成员,insertCount={}", insertCount);
            return ResponseVo.success();
        }
    
    
        /**
         * 删除通知领域成员
         *
         * @param param 删除
         * @return 结果
         */
        @Override
        public ResponseVo<Void> delete(NoticeServiceMembers param) {
            if (StringUtils.isBlank(param.getService()) || StringUtils.isBlank(param.getEmployeeId())) {
                return ResponseVo.error("service和employeeId不能为空");
            }
            int deleteCount = noticeServiceMembersMapper.deleteByCondition(param);
            log.info("删除通知领域成员,deleteCount={},param={}", deleteCount, param);
            return ResponseVo.success();
        }
    
    }

    mapper:

    package com.meta.hrpz.mapper;
    
    import com.meta.hrpz.domain.entity.NoticeServiceMembers;
    import org.apache.ibatis.annotations.Param;
    import org.springframework.stereotype.Repository;
    
    import java.util.List;
    
    /**
     * 通知领域成员Mapper接口
     *
     * @author jiangyan
     * @date 2022-06-19
     */
    @Repository
    public interface NoticeServiceMembersMapper {
    
        /**
         * 根据service和EmployeeId查询通知领域成员
         */
        NoticeServiceMembers queryByServiceAndEmployeeId(@Param("service") String service, @Param("employeeId") String employeeId);
    
        /**
         * 查询通知领域成员列表
         *
         * @param noticeServiceMembers 参数
         * @return list
         */
        List<NoticeServiceMembers> queryListByCondition(NoticeServiceMembers noticeServiceMembers);
    
        /**
         * 新增通知领域成员
         *
         * @param noticeServiceMembers 通知领域成员
         * @return 新增条数
         */
        int insertSelective(NoticeServiceMembers noticeServiceMembers);
    
        /**
         * 删除通知领域成员
         *
         * @param noticeServiceMembers ro
         * @return 删除条数
         */
        int deleteByCondition(NoticeServiceMembers noticeServiceMembers);
    }

    mapper.xml:

    <?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.meta.hrpz.mapper.NoticeServiceMembersMapper">
    
        <resultMap type="com.meta.hrpz.domain.entity.NoticeServiceMembers" id="BaseResultMap">
            <result property="service" column="service"/>
            <result property="employeeId" column="employeeid"/>
            <result property="userName" column="user_name"/>
        </resultMap>
    
        <sql id="base_column">
            service, employeeid, user_name
        </sql>
    
        <select id="queryListByCondition" parameterType="com.meta.hrpz.domain.entity.NoticeServiceMembers" resultMap="BaseResultMap">
            select
            <include refid="base_column"/>
            from t_notice_service_members
            <where>
                <if test="service != null and service != ''">and service = #{service}</if>
                <if test="employeeId != null and employeeId != ''">and employeeid = #{employeeId}</if>
                <if test="userName != null and userName != ''">and user_name like concat('%', #{userName}, '%')</if>
            </where>
            order by employeeid asc
        </select>
    
        <select id="queryByServiceAndEmployeeId" resultMap="BaseResultMap">
            select
            <include refid="base_column"/>
            from t_notice_service_members
            where service = #{service} and employeeid = #{employeeId}
            limit 1
        </select>
    
        <insert id="insertSelective" parameterType="com.meta.hrpz.domain.entity.NoticeServiceMembers">
            insert into t_notice_service_members
            <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="service != null">service,</if>
                <if test="employeeId != null">employeeid,</if>
                <if test="userName != null">user_name,</if>
            </trim>
            <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="service != null">#{service},</if>
                <if test="employeeId != null">#{employeeId},</if>
                <if test="userName != null">#{userName},</if>
            </trim>
        </insert>
    
        <update id="deleteByCondition" parameterType="com.meta.hrpz.domain.entity.NoticeServiceMembers">
            delete
            from t_notice_service_members
            <where>
                <if test="service != null and service != ''">and service = #{service}</if>
                <if test="employeeId != null and employeeId != ''">and employeeid = #{employeeId}</if>
                <if test="userName != null and userName != ''">and user_name = #{userName}</if>
            </where>
        </update>
    </mapper>

    controller:

    package com.meta.hrpz.controller;
    
    import com.meta.common.core.domain.ResponseVo;
    import com.meta.common.core.page.TableDataInfo;
    import com.meta.hrpz.domain.entity.NoticeServiceMembers;
    import com.meta.hrpz.domain.vo.req.NoticeServiceMembersListParamVo;
    import com.meta.hrpz.domain.vo.req.SaveNoticeServiceMembersCmd;
    import com.meta.hrpz.service.NoticeServiceMembersService;
    import org.springframework.web.bind.annotation.PostMapping;
    import org.springframework.web.bind.annotation.RequestBody;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    
    import javax.annotation.Resource;
    import javax.validation.Valid;
    
    /**
     * 通知领域成员Controller
     *
     * @author jiangyan
     * @date 2022-06-19
     */
    @RestController
    @RequestMapping("/noticeServiceMembers")
    public class NoticeServiceMembersController {
    
        @Resource
        private NoticeServiceMembersService noticeServiceMembersService;
    
        /**
         * 分页查询列表
         */
        @PostMapping("/list")
        public TableDataInfo<NoticeServiceMembers> list(@RequestBody NoticeServiceMembersListParamVo paramVo) {
            return noticeServiceMembersService.list(paramVo);
        }
    
        /**
         * 新增
         */
        @PostMapping("/add")
        public ResponseVo<Void> add(@RequestBody @Valid SaveNoticeServiceMembersCmd cmd) {
            return noticeServiceMembersService.add(cmd);
        }
    
        /**
         * 删除
         */
        @PostMapping("/delete")
        public ResponseVo<Void> delete(@RequestBody NoticeServiceMembers param) {
            return noticeServiceMembersService.delete(param);
        }
    
    }
  • 相关阅读:
    Visual studio之C# 调用系统软键盘(外部"osk.exe")
    Visual studio之C# 重新定义Messbox的显示窗口位置
    Visual studio之C#的一些常见问题
    C8051F340之USB简介
    CentOS 安装 Sun JDK
    配置Tomcat以指定的身份(非root)运行
    CentOS6 root 用户 vi/vim 无法开启高亮
    删除 Mac OS X 中“打开方式”里重复或无用的程序列表
    快速建立Linux c/c++编译环境
    Ubuntu 安装 Sun JDK
  • 原文地址:https://www.cnblogs.com/dong320/p/16391865.html
Copyright © 2020-2023  润新知