tangzy
2021-08-23 51ab5429b0fa5b1bf7122753a1eb5b87dfc4fba8
1.社保
10 files added
636 ■■■■■ changed files
src/main/java/org/springblade/modules/social/controller/SocialController.java 154 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/social/dto/SocialDTO.java 34 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/social/entity/Social.java 113 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/social/excel/SocialExcel.java 81 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/social/excel/SocialImporter.java 42 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/social/mapper/SocialMapper.java 43 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/social/mapper/SocialMapper.xml 27 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/social/service/ISocialService.java 51 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/social/service/impl/SocialServiceImpl.java 55 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/social/vo/SocialVO.java 36 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/social/controller/SocialController.java
New file
@@ -0,0 +1,154 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.social.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.social.entity.Social;
import org.springblade.modules.social.excel.SocialExcel;
import org.springblade.modules.social.excel.SocialImporter;
import org.springblade.modules.social.service.ISocialService;
import org.springblade.modules.social.vo.SocialVO;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
/**
 *  控制器
 *
 * @author BladeX
 * @since 2021-07-16
 */
@RestController
@AllArgsConstructor
@RequestMapping("/social")
@Api(value = "", tags = "接口")
public class SocialController extends BladeController {
    private final ISocialService socialService;
    /**
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "详情", notes = "传入social")
    public R<Social> detail(Social social) {
        Social detail = socialService.getOne(Condition.getQueryWrapper(social));
        return R.data(detail);
    }
    /**
     * 分页
     */
    @GetMapping("/list")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入social")
    public R<IPage<Social>> list(Social social, Query query) {
        IPage<Social> pages = socialService.page(Condition.getPage(query), Condition.getQueryWrapper(social));
        return R.data(pages);
    }
    /**
     * 自定义分页
     */
    @GetMapping("/page")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "传入social")
    public R<IPage<SocialVO>> page(SocialVO social, Query query) {
        IPage<SocialVO> pages = socialService.selectSocialPage(Condition.getPage(query), social);
        return R.data(pages);
    }
    /**
     * 新增
     */
    @PostMapping("/save")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入social")
    public R save(@Valid @RequestBody Social social) {
        return R.status(socialService.save(social));
    }
    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "修改", notes = "传入social")
    public R update(@Valid @RequestBody Social social) {
        return R.status(socialService.updateById(social));
    }
    /**
     * 新增或修改
     */
    @PostMapping("/submit")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "新增或修改", notes = "传入social")
    public R submit(@Valid @RequestBody Social social) {
        return R.status(socialService.saveOrUpdate(social));
    }
    /**
     * 删除
     */
    @PostMapping("/remove")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "删除", notes = "传入ids")
    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return R.status(socialService.removeByIds(Func.toLongList(ids)));
    }
    /**
     * 导入社保
     */
    @PostMapping("import-user")
    @ApiOperationSupport(order = 12)
    public R importUser(MultipartFile file, Integer isCovered,String deptid) {
        SocialImporter socialImporter = new SocialImporter(socialService, isCovered == 0,deptid);
        ExcelUtil.save(file, socialImporter, SocialExcel.class);
        return R.success("操作成功");
    }
    /**
     * 导出模板
     */
    @GetMapping("export-template")
    @ApiOperationSupport(order = 14)
    @ApiOperation(value = "导出模板")
    public void exportUser(HttpServletResponse response) {
        List<SocialExcel> list = new ArrayList<>();
        ExcelUtil.export(response, "社保数据模板", "社保数据模板", list, SocialExcel.class);
    }
}
src/main/java/org/springblade/modules/social/dto/SocialDTO.java
New file
@@ -0,0 +1,34 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.social.dto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.social.entity.Social;
/**
 * 数据传输对象实体类
 *
 * @author BladeX
 * @since 2021-07-16
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SocialDTO extends Social {
    private static final long serialVersionUID = 1L;
}
src/main/java/org/springblade/modules/social/entity/Social.java
New file
@@ -0,0 +1,113 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.social.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
 * 实体类
 *
 * @author BladeX
 * @since 2021-07-16
 */
@Data
@TableName("sys_socil")
@ApiModel(value = "Social对象", description = "Social对象")
public class Social implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
    * 姓名
    */
        @ApiModelProperty(value = "姓名")
        private String namb;
    /**
    * 性别
    */
        @ApiModelProperty(value = "性别")
        private String sex;
    /**
    * 民族
    */
        @ApiModelProperty(value = "民族")
        private String nation;
    /**
    * 出生日期
    */
        @ApiModelProperty(value = "出生日期")
        @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
        @DateTimeFormat(pattern = "yyyy-MM-dd")
        private Date birthday;
    /**
    * 联系电话
    */
        @ApiModelProperty(value = "联系电话")
        private String telephone;
    /**
    * 身份证号
    */
        @ApiModelProperty(value = "身份证号")
        private String cardid;
    /**
    * 户籍所在地址
    */
        @ApiModelProperty(value = "户籍所在地址")
        private String residence;
    /**
    * 居住地址
    */
        @ApiModelProperty(value = "居住地址  ")
        private String address;
    /**
    * 户籍性质
    */
        @ApiModelProperty(value = "户籍性质")
        private String nature;
    /**
    * 个人缴费额
    */
        @ApiModelProperty(value = "个人缴费额")
        private float amount ;
    /**
    * 参保时间
    */
        @ApiModelProperty(value = "参保时间")
        @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
        @DateTimeFormat(pattern = "yyyy-MM-dd")
        private Date insuredtime;
    /**
    * 单位id
    */
        @ApiModelProperty(value = "单位id")
        private String deptid;
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
}
src/main/java/org/springblade/modules/social/excel/SocialExcel.java
New file
@@ -0,0 +1,81 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.social.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * UserExcel
 *
 * @author Chill
 */
@Data
@ColumnWidth(25)
@HeadRowHeight(20)
@ContentRowHeight(18)
public class SocialExcel implements Serializable {
    private static final long serialVersionUID = 1L;
    @ColumnWidth(15)
    @ExcelProperty("姓名")
    private String namb;
    @ColumnWidth(10)
    @ExcelProperty("性别")
    private String sex;
    @ColumnWidth(15)
    @ExcelProperty("民族")
    private String nation;
    @ColumnWidth(15)
    @ExcelProperty("出生日期")
    private Date birthday;
    @ColumnWidth(15)
    @ExcelProperty("联系电话")
    private String telephone;
    @ExcelProperty("身份证号")
    private String cardid;
    @ColumnWidth(15)
    @ExcelProperty("户籍所在地")
    private String residence;
    @ExcelProperty("地址")
    private String address;
    @ExcelProperty("户籍性质")
    private String nature;
    @ExcelProperty("个人缴费")
    private String amount ;
    @ExcelProperty("参保时间")
    private Date insuredtime;
}
src/main/java/org/springblade/modules/social/excel/SocialImporter.java
New file
@@ -0,0 +1,42 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.social.excel;
import lombok.RequiredArgsConstructor;
import org.springblade.core.excel.support.ExcelImporter;
import org.springblade.modules.social.service.ISocialService;
import java.util.List;
/**
 * 用户数据导入类
 *
 * @author Chill
 */
@RequiredArgsConstructor
public class SocialImporter implements ExcelImporter<SocialExcel> {
    private final ISocialService iSocialService;
    private final Boolean isCovered;
    private final String deptid;
    @Override
    public void save(List<SocialExcel> data) {
        iSocialService.importUser(data, isCovered,deptid);
    }
}
src/main/java/org/springblade/modules/social/mapper/SocialMapper.java
New file
@@ -0,0 +1,43 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.social.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.social.entity.Social;
import org.springblade.modules.social.vo.SocialVO;
import java.util.List;
/**
 *  Mapper 接口
 *
 * @author BladeX
 * @since 2021-07-16
 */
public interface SocialMapper extends BaseMapper<Social> {
    /**
     * 自定义分页
     *
     * @param page
     * @param social
     * @return
     */
    List<SocialVO> selectSocialPage(IPage page, SocialVO social);
}
src/main/java/org/springblade/modules/social/mapper/SocialMapper.xml
New file
@@ -0,0 +1,27 @@
<?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="org.springblade.modules.social.mapper.SocialMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="socialResultMap" type="org.springblade.modules.social.entity.Social">
        <id column="id" property="id"/>
        <result column="namb" property="namb"/>
        <result column="sex" property="sex"/>
        <result column="nation" property="nation"/>
        <result column="birthday" property="birthday"/>
        <result column="telephone" property="telephone"/>
        <result column="cardid" property="cardid"/>
        <result column="residence" property="residence"/>
        <result column="address" property="address"/>
        <result column="nature" property="nature"/>
        <result column="amount" property="amount"/>
        <result column="insuredtime" property="insuredtime"/>
        <result column="deptid" property="deptid"/>
    </resultMap>
    <select id="selectSocialPage" resultMap="socialResultMap">
        select * from sys_social
    </select>
</mapper>
src/main/java/org/springblade/modules/social/service/ISocialService.java
New file
@@ -0,0 +1,51 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.social.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.social.entity.Social;
import org.springblade.modules.social.excel.SocialExcel;
import org.springblade.modules.social.vo.SocialVO;
import java.util.List;
/**
 *  服务类
 *
 * @author BladeX
 * @since 2021-07-16
 */
public interface ISocialService extends IService<Social> {
    /**
     * 自定义分页
     *
     * @param page
     * @param social
     * @return
     */
    IPage<SocialVO> selectSocialPage(IPage<SocialVO> page, SocialVO social);
    /**
     * 导入用户数据
     *
     * @param data
     * @param isCovered
     * @return
     */
    void importUser(List<SocialExcel> data, Boolean isCovered,String deptid);
}
src/main/java/org/springblade/modules/social/service/impl/SocialServiceImpl.java
New file
@@ -0,0 +1,55 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.social.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.modules.social.entity.Social;
import org.springblade.modules.social.excel.SocialExcel;
import org.springblade.modules.social.mapper.SocialMapper;
import org.springblade.modules.social.service.ISocialService;
import org.springblade.modules.social.vo.SocialVO;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
/**
 *  服务实现类
 *
 * @author BladeX
 * @since 2021-07-16
 */
@Service
public class SocialServiceImpl extends ServiceImpl<SocialMapper, Social> implements ISocialService {
    @Override
    public IPage<SocialVO> selectSocialPage(IPage<SocialVO> page, SocialVO social) {
        return page.setRecords(baseMapper.selectSocialPage(page, social));
    }
    @Override
    public void importUser(List<SocialExcel> data, Boolean isCovered,String deptid) {
        data.forEach(SocialExcel -> {
            Social social = Objects.requireNonNull(BeanUtil.copy(SocialExcel, Social.class));
            social.setDeptid(deptid);
            this.save(social);
        });
    }
}
src/main/java/org/springblade/modules/social/vo/SocialVO.java
New file
@@ -0,0 +1,36 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.social.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.social.entity.Social;
/**
 * 视图实体类
 *
 * @author BladeX
 * @since 2021-07-16
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "SocialVO对象", description = "SocialVO对象")
public class SocialVO extends Social {
    private static final long serialVersionUID = 1L;
}