持久化API
持久化API(不用写SQL,用的普通写法,不是Crud写法)
Controller层
import com.egoo.vl.crm.baselog.domain.history.summary.HistorySummary; import com.egoo.vl.crm.baselog.service.history.summary.InteractionSummaryService; @Autowired private InteractionSummaryService interactionSummaryService; @ApiOperation(value = "根据多个sessionid获取小结信息", notes = "根据url的tenantId以及SessionIds来获取小结详细信息") @RequestMapping(method = RequestMethod.GET, value = "/summaryBySessionids/{tenantId}/{sessionId}/{agentId}") public @ResponseBody DBResponse findSummaryBySessionIds(@ApiParam(value = "租户ID", required = true) @PathVariable("tenantId") String tenantId, @ApiParam(value = "会话ID", required = true) @PathVariable("sessionId") List<String> sessionIds, @ApiParam(value = "座席ID", required = true) @PathVariable("agentId") String agentId) { if (log.isInfoEnabled()) { log.info("rest request : 获取小结信息: " + tenantId + ", sessionIds: " + sessionIds + ", agentId: " + agentId); } DBResponse dbResponse = new DBResponse(StatusCode.RET_ERROR, "数据库查询失败"); try { Map<String, Object> params = new HashMap<>(); params.put("tenantId",tenantId); params.put("agentId",agentId); params.put("createTime",null); //List<Map<String, Object>> summary = interactionSummaryService.listByIds(sessionIds); Collection<HistorySummary> summaries = interactionSummaryService.listByIds(sessionIds); List<HistorySummary> list= new ArrayList<>(); for (HistorySummary summary : summaries) { if (summary.getAgentId().equals(agentId) && summary.getTenantId().equals(tenantId)){ list.add(summary); } } Map<String, Object> data = new HashMap<>(); int total = list.size(); data.put("list",list); data.put("total",total); log.info("rest response summary: " + data); if (list != null) { dbResponse.setRetCode(StatusCode.RET_SUCCESS); dbResponse.setMsg("数据库查询成功"); dbResponse.setData(data); } } catch (Exception e) { log.error("rest request : 获取小结信息,message:{}.e:{}", e.getMessage(), e); } return dbResponse; }
Dao(Mapper)层
package com.egoo.vl.crm.baselog.dao.history.history; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.egoo.vl.crm.baselog.domain.history.summary.HistorySummary; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; /** * Created by IntelliJ IDEA. * User: 42404 * Date: 2022/7/11 */ @Mapper @Repository public interface InteractionSummaryMapper extends BaseMapper<HistorySummary> { }
Entity层
package com.egoo.vl.crm.baselog.domain.history.summary; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; /** * com.egoo.mcc.dbsrv.domain.history.summary * * 交互小结 * @author jie liu * @date 2017/12、8 */ @Data @TableName("history_summary") @ApiModel("小结") public class HistorySummary implements Serializable { private String id; @ApiModelProperty(name = "租户ID") private String tenantId; @ApiModelProperty(name = "是否解决") private String handled; @ApiModelProperty(name = "电话号码") private String phoneNumber; @ApiModelProperty(name = "会话ID") @TableId private String sessionId; @ApiModelProperty(name = "业务类型") private String bizValueList; @ApiModelProperty("业务列表详情") private String bizValueListDetail; @ApiModelProperty("业务列表标签") @TableField(exist = false) private String bizTypeLabel; @ApiModelProperty(name = "座席ID") private String agentId; @ApiModelProperty(name = "客户姓名") private String customerName; @ApiModelProperty(name = "小结内容") private String content; @ApiModelProperty(name = "创建时间") private String createTime; @ApiModelProperty(name = "客户号") private String customerId; @ApiModelProperty(name = "地区") private String area; @ApiModelProperty("渠道") private String channelType; //voice,message,chat @ApiModelProperty(name = "是否主小结") private String master; @ApiModelProperty("模板id") private String templateId; @ApiModelProperty("自定义字段") private String userDefine; }
Service层
package com.egoo.vl.crm.baselog.service.history.summary; import com.baomidou.mybatisplus.extension.service.IService; import com.egoo.vl.crm.baselog.domain.history.summary.HistorySummary; /** * com.egoo.mcc.dbsrv.service.history * * @author zuowenxia * @date 2017/7/12. */ public interface InteractionSummaryService extends IService<HistorySummary> { }
ServiceImpl层
package com.egoo.vl.crm.baselog.service.history.summary.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.egoo.vl.crm.baselog.dao.history.history.InteractionSummaryMapper; import com.egoo.vl.crm.baselog.domain.history.summary.HistorySummary; import com.egoo.vl.crm.baselog.service.history.summary.InteractionSummaryService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; /** * @author zhangjun */ @Slf4j @Service public class InteractionSummaryServiceImpl extends ServiceImpl<InteractionSummaryMapper, HistorySummary> implements InteractionSummaryService { }
持久化API(CRUD写法,批量导出功能)
Controller层
package com.egoo.eeip.idp.server.controller; import com.egoo.eeip.eeif.starter.mybatis.controller.base.BaseCrudController; import com.egoo.eeip.idp.server.Entity.RecordInfo; import com.egoo.eeip.idp.server.mapper.RecordInfoMapperSingle; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * Created by IntelliJ IDEA. * User: 42404 * Date: 2022/7/21 * @author 42404 */ @RestController @RequestMapping(value = "/v1/record", produces = "application/json") @Api(value="工作类型接口", tags="工作类型接口") @Slf4j public class RecordInfoControllerSingle extends BaseCrudController<RecordInfoMapperSingle, RecordInfo> { }
Entity层
package com.egoo.eeip.idp.server.Entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.egoo.eeip.eeif.starter.mybatis.entity.BaseEntity; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; /** * 实体类 * * @author Chill */ @Data @TableName("record_info") @ApiModel(value = "RecordInfo对象", description = "RecordInfo对象") public class RecordInfo extends BaseEntity implements Serializable { private static final long serialVersionUID = 1L; /** * 租户ID */ @ApiModelProperty(value = "租户ID") @TableField("tenant_id") private String tenantId; /** * 坐席id */ @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty(value = "坐席id") @TableField("agent_id") private String agentId; /** * 分机号码 */ @ApiModelProperty(value = "dn号码") @TableField("dn") private String dn; /** * 通话id */ @ApiModelProperty(value = "通话标识id") @TableField("call_uuid") private String callUUID; /** * 录音id */ @ApiModelProperty(value = "录音id") @TableField("record_id") private String recordId; /** * 录音call_id */ @ApiModelProperty(value = "通话标识id") @TableField("call_id") private String callID; /** * 主叫 */ @ApiModelProperty(value = "主叫") @TableField("ani") private String ani; /** * 被叫 */ @ApiModelProperty(value = "被叫") @TableField("dnis") private String dnis; /** * 开始时间 */ @ApiModelProperty(value = "开始时间") @TableField("BEGIN_TIME") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Long beginTime; /** * 结束时间 */ @ApiModelProperty(value = "结束时间") @TableField("END_TIME") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private String endTime; /** * 位置 */ @ApiModelProperty(value = "位置") @TableField("is_location") private int isLocation; /** * 状态 */ @ApiModelProperty(value = "状态") @TableField("trade_status") private int tradeStatus; /** * 录音url */ @ApiModelProperty(value = "录音url2") @TableField("record_url2") private String recordURL2; /** * 录音url */ @ApiModelProperty(value = "录音url") @TableField("record_url") private String recordURL; /** * 录频url */ @ApiModelProperty(value = "录屏url") @TableField("screen_url") private String ScreenURL; /** * 录音文件排序 */ @ApiModelProperty(value = "录音文件排序") @TableField("record_file_index") private String recordFileIndex; /** * 录音或录频类型 */ @ApiModelProperty(value = "录音或录频类型") @TableField("type") private String type; }
DAO(Mapper)层
package com.egoo.eeip.idp.server.mapper; import com.egoo.eeip.eeif.starter.mybatis.dao.base.BaseCrudMapper; import com.egoo.eeip.idp.server.Entity.RecordInfo; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; /** * Created by IntelliJ IDEA. * User: 42404 * Date: 2022/7/21 */ @Mapper @Repository public interface RecordInfoMapperSingle extends BaseCrudMapper<RecordInfo> { }
Service层
package com.egoo.eeip.idp.server.service; import com.baomidou.mybatisplus.extension.service.IService; import com.egoo.eeip.idp.server.Entity.RecordInfo; /** * 服务类 * * @author Chill */ public interface IRecordInfoService extends IService<RecordInfo> { }
ServiceImpl层
package com.egoo.eeip.idp.server.service.impl; import com.egoo.eeip.eeif.starter.mybatis.service.BaseCrudService; import com.egoo.eeip.idp.server.Entity.RecordInfo; import com.egoo.eeip.idp.server.mapper.RecordInfoMapperSingle; import com.egoo.eeip.idp.server.service.IRecordInfoService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.*; /** * 服务实现类 * @author LRF */ @Service @Slf4j public class RecordInfoServiceImpl extends BaseCrudService<RecordInfoMapperSingle, RecordInfo> implements IRecordInfoService { @Override public String getExportFiled(String strategy) { return "ANI,DNIS,BEGIN_TIME,END_TIME,DN,CALL_UUID"; } @Override public String getExportFileName(String strategy) { return "录音信息"; } @Override public List<List<String>> getExportHead() { List<List<String>> head = new ArrayList<>(); head.add(Arrays.asList("主叫号码")); head.add(Arrays.asList("被叫号码")); head.add(Arrays.asList("录音开始时间")); head.add(Arrays.asList("录音结束时间")); head.add(Arrays.asList("分机号")); head.add(Arrays.asList("通话标识")); return head; } // 注意 @Override public Map<String, String> getSpelExpression() { Map<String, String> expression = new HashMap<>(1); expression.put("beginTime", "T(com.egoo.eeip.eeif.framework.base.util.date.DateUtil).transTimestampToStr((T(Long).parseLong(#beginTime)*1000))"); expression.put("endTime", "T(com.egoo.eeip.eeif.framework.base.util.date.DateUtil).transTimestampToStr((T(Long).parseLong(#endTime)*1000))"); return expression; } //使用java方法处理掩码 //expression.put("id","T(Long).toString(#id).substring(0,5).concat('xxxxxxxx')"); // // @Override // public void formatter(Map<String, Object> objectMap) { // super.formatter(objectMap); // } }