提交 e0d6536d authored 作者: 宋文杰's avatar 宋文杰

feat(info information): add save info information

上级 0e110f94
...@@ -2,11 +2,13 @@ package com.elephant.framework.galaxy.aroad.module.info.controller; ...@@ -2,11 +2,13 @@ package com.elephant.framework.galaxy.aroad.module.info.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.elephant.framework.galaxy.aroad.module.info.dto.InfoInformationsDto;
import com.elephant.framework.galaxy.aroad.response.R; import com.elephant.framework.galaxy.aroad.response.R;
import com.elephant.framework.galaxy.aroad.module.common.annotation.SysLog; import com.elephant.framework.galaxy.aroad.module.common.annotation.SysLog;
import com.elephant.framework.galaxy.aroad.module.info.entity.InfoInformations; import com.elephant.framework.galaxy.aroad.module.info.entity.InfoInformations;
import com.elephant.framework.galaxy.aroad.module.info.service.InfoInformationsService; import com.elephant.framework.galaxy.aroad.module.info.service.InfoInformationsService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.elephant.framework.galaxy.aroad.module.common.controller.BaseController; import com.elephant.framework.galaxy.aroad.module.common.controller.BaseController;
...@@ -46,27 +48,19 @@ public class InfoInformationsController extends BaseController { ...@@ -46,27 +48,19 @@ public class InfoInformationsController extends BaseController {
return new R<>(infoInformationsService.getById(infoId)); return new R<>(infoInformationsService.getById(infoId));
} }
/**
* 新增信息表 /**
* @param infoInformations 信息表 * @Description: 新增上报信息
* @return R * @Param: [info]
*/ * @return: com.elephant.framework.galaxy.aroad.response.R
@SysLog("新增信息表") * @Author: songwenjie
* @Date: 2019/5/5
*/
@PostMapping @PostMapping
public R save(@RequestBody InfoInformations infoInformations){ public R saveInformations(@RequestBody InfoInformationsDto info){
return new R<>(infoInformationsService.save(infoInformations)); return new R<>(infoInformationsService.saveInformations(info));
} }
/**
* 修改信息表
* @param infoInformations 信息表
* @return R
*/
@SysLog("修改信息表")
@PutMapping
public R updateById(@RequestBody InfoInformations infoInformations){
return new R<>(infoInformationsService.updateById(infoInformations));
}
/** /**
* 通过id删除信息表 * 通过id删除信息表
......
package com.elephant.framework.galaxy.aroad.module.info.entity; package com.elephant.framework.galaxy.aroad.module.info.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model; import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data; import lombok.*;
import lombok.EqualsAndHashCode;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
/** /**
* 信息表 * 信息表
...@@ -15,15 +17,18 @@ import java.time.LocalDateTime; ...@@ -15,15 +17,18 @@ import java.time.LocalDateTime;
* @date 2019-04-28 10:34:46 * @date 2019-04-28 10:34:46
*/ */
@Data @Data
@Builder
@TableName("info_informations") @TableName("info_informations")
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class InfoInformations extends Model<InfoInformations> { public class InfoInformations extends Model<InfoInformations> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 信息id * 信息id
*/ */
@TableId @TableId(type = IdType.AUTO)
private Integer infoId; private Integer infoId;
/** /**
* 模板id * 模板id
...@@ -48,6 +53,6 @@ private static final long serialVersionUID = 1L; ...@@ -48,6 +53,6 @@ private static final long serialVersionUID = 1L;
/** /**
* 上报时间 * 上报时间
*/ */
private LocalDateTime reportingTime; private Date reportingTime;
} }
...@@ -10,5 +10,12 @@ import com.elephant.framework.galaxy.aroad.module.info.entity.InfoInformations; ...@@ -10,5 +10,12 @@ import com.elephant.framework.galaxy.aroad.module.info.entity.InfoInformations;
* @date 2019-04-28 10:34:46 * @date 2019-04-28 10:34:46
*/ */
public interface InfoInformationsMapper extends BaseMapper<InfoInformations> { public interface InfoInformationsMapper extends BaseMapper<InfoInformations> {
/**
* @Description: 新增上报信息
* @Param: [informations]
* @return: java.lang.Boolean
* @Author: songwenjie
* @Date: 2019/5/5
*/
Boolean saveInformations(InfoInformations informations);
} }
package com.elephant.framework.galaxy.aroad.module.info.service; package com.elephant.framework.galaxy.aroad.module.info.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.elephant.framework.galaxy.aroad.module.info.dto.InfoInformationsDto;
import com.elephant.framework.galaxy.aroad.module.info.entity.InfoInformations; import com.elephant.framework.galaxy.aroad.module.info.entity.InfoInformations;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 信息表 * 信息表
...@@ -11,4 +13,12 @@ import com.elephant.framework.galaxy.aroad.module.info.entity.InfoInformations; ...@@ -11,4 +13,12 @@ import com.elephant.framework.galaxy.aroad.module.info.entity.InfoInformations;
*/ */
public interface InfoInformationsService extends IService<InfoInformations> { public interface InfoInformationsService extends IService<InfoInformations> {
/**
* @Description: 新增上报信息
* @Param: [info]
* @return: java.lang.Boolean
* @Author: songwenjie
* @Date: 2019/5/5
*/
Boolean saveInformations(InfoInformationsDto info);
} }
package com.elephant.framework.galaxy.aroad.module.info.service.impl; package com.elephant.framework.galaxy.aroad.module.info.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.elephant.framework.galaxy.aroad.module.info.dto.InfoInformationsDto;
import com.elephant.framework.galaxy.aroad.module.info.entity.InfoInformations; import com.elephant.framework.galaxy.aroad.module.info.entity.InfoInformations;
import com.elephant.framework.galaxy.aroad.module.info.entity.InfoReceivers;
import com.elephant.framework.galaxy.aroad.module.info.mapper.InfoInformationsMapper; import com.elephant.framework.galaxy.aroad.module.info.mapper.InfoInformationsMapper;
import com.elephant.framework.galaxy.aroad.module.info.service.InfoInformationsService; import com.elephant.framework.galaxy.aroad.module.info.service.InfoInformationsService;
import com.elephant.framework.galaxy.aroad.module.info.service.InfoReceiversService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/** /**
* 信息表 * 信息表
...@@ -15,4 +23,36 @@ import org.springframework.stereotype.Service; ...@@ -15,4 +23,36 @@ import org.springframework.stereotype.Service;
@Service @Service
public class InfoInformationsServiceImpl extends ServiceImpl<InfoInformationsMapper, InfoInformations> implements InfoInformationsService { public class InfoInformationsServiceImpl extends ServiceImpl<InfoInformationsMapper, InfoInformations> implements InfoInformationsService {
@Autowired
private InfoReceiversService infoReceiversService;
/**
* @Description: 新增上报信息
* @Param: [info]
* @return: java.lang.Boolean
* @Author: songwenjie
* @Date: 2019/5/5
*/
@Transactional
public Boolean saveInformations(InfoInformationsDto info){
InfoInformations information = InfoInformations.builder()
.templateId(info.getTemplateId())
.infoTitle(info.getInfoTitle())
.infoContent(info.getInfoContent())
.infoRemark(info.getInfoRemark())
.reporterId(info.getReporterId())
.reportingTime(info.getReportingTime())
.build();
baseMapper.saveInformations(information);
List<InfoReceivers> receivers = new ArrayList<>();
info.getReceiverIds().forEach(r->{
receivers.add(InfoReceivers.builder()
.infoId(information.getInfoId())
.deptId(info.getDeptId())
.receiverId(r)
.build());
});
return infoReceiversService.saveBatch(receivers);
}
} }
...@@ -13,4 +13,11 @@ ...@@ -13,4 +13,11 @@
<result property="reporterId" column="reporter_id"/> <result property="reporterId" column="reporter_id"/>
<result property="reportingTime" column="reporting_time"/> <result property="reportingTime" column="reporting_time"/>
</resultMap> </resultMap>
<insert id="saveInformations" useGeneratedKeys="true" keyProperty="infoId">
insert into
info_informations(template_id, info_title,info_content,info_remark,reporter_id,reporting_time)
values
(#{templateId}, #{infoTitle},#{infoContent},#{infoRemark},#{reporterId},#{reportingTime})
</insert>
</mapper> </mapper>
...@@ -18,4 +18,6 @@ ...@@ -18,4 +18,6 @@
select * from info_templates select * from info_templates
where create_dept_id = #{createDeptId} where create_dept_id = #{createDeptId}
</select> </select>
</mapper> </mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论