Просмотр исходного кода

[会员][修改][导入]

release_toaliyun_real
gongbiao 7 лет назад
Родитель
Сommit
60a1a3b881
3 измененных файлов: 30 добавлений и 21 удалений
  1. +6
    -0
      mallinkService/src/main/java/com/simple/domain/po/WxCUserBasicInfo.java
  2. +20
    -13
      mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java
  3. +4
    -8
      mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml

+ 6
- 0
mallinkService/src/main/java/com/simple/domain/po/WxCUserBasicInfo.java Просмотреть файл

@@ -5,6 +5,7 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@@ -46,17 +47,21 @@ public class WxCUserBasicInfo implements Serializable {
/*微信用户绑定的手机号**/
@Excel(name="手机",width = 20,orderNum = "2")
@io.swagger.annotations.ApiModelProperty(value="微信用户绑定的手机号",name="phone")
@NotNull
private String phone;
/*出生日期**/
@Excel(name="生日",width = 20,format="yyyy-MM-dd",orderNum = "3")
@NotNull
@io.swagger.annotations.ApiModelProperty(value="出生日期",name="birthdate")
private Date birthdate;
/*学历**/
@Excel(name="学历",width = 20,orderNum = "4")
@NotNull
@io.swagger.annotations.ApiModelProperty(value="学历",name="education")
private String education;
/*性别:0:保密 1.男 2女**/
@Excel(name="性别",width = 20,replace = { "保密_0", "男_1","女_2"},orderNum = "2")
@NotNull
@io.swagger.annotations.ApiModelProperty(value="性别:0:保密 1.男 2女",name="sex")
private Integer sex;
/*邮箱**/
@@ -83,6 +88,7 @@ public class WxCUserBasicInfo implements Serializable {

/*用户姓名**/
@Excel(name="姓名",width = 20)
@NotNull
@io.swagger.annotations.ApiModelProperty(value="用户姓名",name="name")
private String name;


+ 20
- 13
mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java Просмотреть файл

@@ -302,29 +302,36 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService {
try {

ImportParams params = new ImportParams();
params.setTitleRows(1);
params.setHeadRows(1);
List<WxCUserBasicInfo> datalist = ExcelImportUtil.importExcel(file.getInputStream(),WxCUserBasicInfo.class, params);
WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo();
wxCUserBasicInfo.setTenantId(tenantId);
List<WxCUserBasicInfo> list = wxCUserBasicInfoMapper.findList(wxCUserBasicInfo);
final IdWorker idWorker = IdWorker.get();
for(WxCUserBasicInfo user:datalist){
WxCUserBasicInfo tempuser = list.stream().filter(u -> u.getPhone().equals(user.getPhone())).findFirst().get();
if(tempuser!=null){
tempuser.setSex(user.getSex());
tempuser.setEducation(user.getEducation());
tempuser.setBirthdate(user.getBirthdate());
tempuser.setName(user.getName());
wxCUserBasicInfoMapper.updateByPrimaryKeySelective(tempuser);
} else {
user.setId(idWorker.nextId());
wxCUserBasicInfoMapper.insertSelective(user);
if(user.getPhone()!=null){
WxCUserBasicInfo tempuser=null;
if(list.size()>0){
tempuser = list.stream().filter(u -> u.getPhone().equals(user.getPhone())).findFirst().get();
}
if(tempuser!=null){
tempuser.setTenantId(tenantId);
tempuser.setSex(user.getSex());
tempuser.setEducation(user.getEducation());
tempuser.setBirthdate(user.getBirthdate());
tempuser.setName(user.getName());
wxCUserBasicInfoMapper.updateByPrimaryKeySelective(tempuser);
} else {
user.setId(idWorker.nextId());
user.setTenantId(tenantId);
wxCUserBasicInfoMapper.insertSelective(user);
}
}
}

} catch (Exception e) {
throw new MallinkException(500,"模板导入失败");
throw new MallinkException(500,"模板导入失败"+e);
}

return new ResultData(Result.SUCCESS,"导入成功");


+ 4
- 8
mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml Просмотреть файл

@@ -32,7 +32,7 @@
</if>

<if test=" null != tenantId ">
and c.`tenant_id` like concat('%', #{tenantId},'%')
and `tenant_id` = #{tenantId}
</if>

<if test=" null != phone ">
@@ -67,20 +67,16 @@
and `tag_id` = #{tagId}
</if>

<if test=" null != cUserId ">
and `c_user_id` = #{cUserId}
</if>

<if test=" null != createDate ">
and c.`create_date` = #{createDate}
and `create_date` = #{createDate}
</if>

<if test=" null != updateDate ">
and c.`update_date` = #{updateDate}
and `update_date` = #{updateDate}
</if>

<if test=" null != name ">
and c.`name` like concat('%', #{name},'%')
and `name` like concat('%', #{name},'%')
</if>
<if test=" null != ids ">
and id in


Загрузка…
Отмена
Сохранить