5 changed files with 372 additions and 0 deletions
@ -0,0 +1,80 @@ |
|||||
|
package com.qs.serve.modules.biz.controller; |
||||
|
|
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.dto.PageVo; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.util.PageUtil; |
||||
|
import com.qs.serve.modules.biz.entity.BizAppLog; |
||||
|
import com.qs.serve.modules.biz.service.BizAppLogService; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletRequest; |
||||
|
import javax.validation.Valid; |
||||
|
import java.util.*; |
||||
|
|
||||
|
/** |
||||
|
* 业务 APP错误日志 |
||||
|
* @author YenHex |
||||
|
* @since 2023-05-26 |
||||
|
*/ |
||||
|
@Validated |
||||
|
@RequiredArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("/biz/appLog") |
||||
|
public class BizAppLogController { |
||||
|
|
||||
|
private final BizAppLogService bizAppLogService; |
||||
|
|
||||
|
/** |
||||
|
* 列表查询 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/list") |
||||
|
public R<List<BizAppLog>> getList(BizAppLog param) { |
||||
|
List<BizAppLog> list = bizAppLogService.queryList(param); |
||||
|
return R.ok(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 翻页查询 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/page") |
||||
|
public PageVo<BizAppLog> getPage(BizAppLog param) { |
||||
|
PageUtil.startPage(); |
||||
|
List<BizAppLog> list = bizAppLogService.queryList(param); |
||||
|
return R.buildPageHelperList(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* ID查询 |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping(value = "/{id}") |
||||
|
public R<BizAppLog> getById(@PathVariable("id") String id){ |
||||
|
BizAppLog bizAppLog = bizAppLogService.getById(id); |
||||
|
return R.ok(bizAppLog); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping() |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public R<?> save(@RequestBody @Valid BizAppLog param){ |
||||
|
bizAppLogService.save(param); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,149 @@ |
|||||
|
package com.qs.serve.modules.biz.entity; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* 实体类 |
||||
|
* @author YenHex |
||||
|
* @since 2023-05-26 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("biz_app_log") |
||||
|
public class BizAppLog implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
@TableId(type = IdType.AUTO) |
||||
|
private Long id; |
||||
|
|
||||
|
/** user-agent(后端处理) */ |
||||
|
private String userAgent; |
||||
|
|
||||
|
/** 设备号 */ |
||||
|
@Length(max = 255,message = "设备号长度不能超过255字") |
||||
|
private String driveCode; |
||||
|
|
||||
|
/** 错误信息 */ |
||||
|
@Length(max = 2000,message = "错误信息长度不能超过2000字") |
||||
|
private String errorMsg; |
||||
|
|
||||
|
/** 定位信息 */ |
||||
|
@Length(max = 2000,message = "定位信息长度不能超过2000字") |
||||
|
private String localMsg; |
||||
|
|
||||
|
/** 定位类型 */ |
||||
|
@Length(max = 255,message = "定位类型长度不能超过255字") |
||||
|
private String localType; |
||||
|
|
||||
|
/** sdk版本 */ |
||||
|
@Length(max = 255,message = "sdk版本长度不能超过255字") |
||||
|
private String sdkVersion; |
||||
|
|
||||
|
/** 网络信息 */ |
||||
|
@Length(max = 255,message = "网络信息长度不能超过255字") |
||||
|
private String netInfo; |
||||
|
|
||||
|
@Length(max = 255,message = "长度不能超过255字") |
||||
|
private String userId; |
||||
|
|
||||
|
@Length(max = 255,message = "长度不能超过255字") |
||||
|
private String userCode; |
||||
|
|
||||
|
@Length(max = 255,message = "长度不能超过255字") |
||||
|
private String userName; |
||||
|
|
||||
|
/** 拓展字段1 */ |
||||
|
@Length(max = 255,message = "拓展字段1长度不能超过255字") |
||||
|
private String sp1; |
||||
|
|
||||
|
/** 拓展字段2 */ |
||||
|
@Length(max = 255,message = "拓展字段2长度不能超过255字") |
||||
|
private String sp2; |
||||
|
|
||||
|
/** 拓展字段3 */ |
||||
|
@Length(max = 255,message = "拓展字段3长度不能超过255字") |
||||
|
private String sp3; |
||||
|
|
||||
|
/** 拓展字段4 */ |
||||
|
@Length(max = 255,message = "拓展字段4长度不能超过255字") |
||||
|
private String sp4; |
||||
|
|
||||
|
/** 备注 */ |
||||
|
@Length(max = 255,message = "备注长度不能超过255字") |
||||
|
private String remark; |
||||
|
|
||||
|
/** 创建时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
/** 最后更新时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private LocalDateTime updateTime; |
||||
|
|
||||
|
/** 所属租户 */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String tenantId; |
||||
|
|
||||
|
/** 逻辑删除标记(0:显示;1:隐藏) */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String delFlag; |
||||
|
|
||||
|
/** 创建人 */ |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private String createBy; |
||||
|
|
||||
|
/** 更新人 */ |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private String updateBy; |
||||
|
|
||||
|
|
||||
|
public static BizAppLog toNewObject(BizAppLog source){ |
||||
|
BizAppLog appLog = new BizAppLog(); |
||||
|
appLog.setId(source.getId()); |
||||
|
appLog.setUserAgent(source.getUserAgent()); |
||||
|
appLog.setDriveCode(source.getDriveCode()); |
||||
|
appLog.setErrorMsg(source.getErrorMsg()); |
||||
|
appLog.setLocalMsg(source.getLocalMsg()); |
||||
|
appLog.setLocalType(source.getLocalType()); |
||||
|
appLog.setSdkVersion(source.getSdkVersion()); |
||||
|
appLog.setNetInfo(source.getNetInfo()); |
||||
|
appLog.setUserId(source.getUserId()); |
||||
|
appLog.setUserCode(source.getUserCode()); |
||||
|
appLog.setUserName(source.getUserName()); |
||||
|
appLog.setSp1(source.getSp1()); |
||||
|
appLog.setSp2(source.getSp2()); |
||||
|
appLog.setSp3(source.getSp3()); |
||||
|
appLog.setSp4(source.getSp4()); |
||||
|
appLog.setRemark(source.getRemark()); |
||||
|
appLog.setCreateTime(source.getCreateTime()); |
||||
|
appLog.setUpdateTime(source.getUpdateTime()); |
||||
|
appLog.setTenantId(source.getTenantId()); |
||||
|
appLog.setDelFlag(source.getDelFlag()); |
||||
|
appLog.setCreateBy(source.getCreateBy()); |
||||
|
appLog.setUpdateBy(source.getUpdateBy()); |
||||
|
return appLog; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,14 @@ |
|||||
|
package com.qs.serve.modules.biz.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.qs.serve.modules.biz.entity.BizAppLog; |
||||
|
|
||||
|
/** |
||||
|
* Mapper |
||||
|
* @author YenHex |
||||
|
* @since 2023-05-26 |
||||
|
*/ |
||||
|
public interface BizAppLogMapper extends BaseMapper<BizAppLog> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,36 @@ |
|||||
|
package com.qs.serve.modules.biz.service; |
||||
|
|
||||
|
|
||||
|
import com.qs.serve.common.model.dto.PageVo; |
||||
|
import com.qs.serve.modules.biz.entity.BizAppLog; |
||||
|
|
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 服务接口 |
||||
|
* @author YenHex |
||||
|
* @since 2023-05-26 |
||||
|
*/ |
||||
|
public interface BizAppLogService{ |
||||
|
|
||||
|
/** 新增 */ |
||||
|
BizAppLog getById(String id); |
||||
|
|
||||
|
/** 翻页查询 */ |
||||
|
//PageVo<BizAppLog> queryPage(BizAppLog param, PageQuery pageQuery);
|
||||
|
|
||||
|
/** 列表查询 */ |
||||
|
List<BizAppLog> queryList(BizAppLog param); |
||||
|
|
||||
|
/** 新增 */ |
||||
|
Boolean save(BizAppLog param); |
||||
|
|
||||
|
/** 修改 */ |
||||
|
Boolean updateById(BizAppLog param); |
||||
|
|
||||
|
/** 删除 */ |
||||
|
Boolean removeByIds(Collection<String> ids); |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,93 @@ |
|||||
|
package com.qs.serve.modules.biz.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.qs.serve.common.model.dto.PageVo; |
||||
|
import com.qs.serve.common.util.AuthContextUtils; |
||||
|
import com.qs.serve.common.util.ServletUtils; |
||||
|
import com.qs.serve.modules.biz.entity.BizAppLog; |
||||
|
import com.qs.serve.modules.biz.mapper.BizAppLogMapper; |
||||
|
import com.qs.serve.modules.biz.service.BizAppLogService; |
||||
|
import com.qs.serve.modules.sys.entity.SysUser; |
||||
|
import com.qs.serve.modules.sys.mapper.SysUserMapper; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import java.util.*; |
||||
|
|
||||
|
/** |
||||
|
* 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2023-05-26 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class BizAppLogServiceImpl implements BizAppLogService { |
||||
|
|
||||
|
private final BizAppLogMapper bizAppLogMapper; |
||||
|
private final SysUserMapper sysUserMapper; |
||||
|
|
||||
|
@Override |
||||
|
public BizAppLog getById(String id){ |
||||
|
return bizAppLogMapper.selectById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<BizAppLog> queryList(BizAppLog param) { |
||||
|
LambdaQueryWrapper<BizAppLog> lqw = new LambdaQueryWrapper<>(param); |
||||
|
return bizAppLogMapper.selectList(lqw); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Boolean save(BizAppLog param) { |
||||
|
BizAppLog appLog = new BizAppLog(); |
||||
|
String agentString = ServletUtils.getHeader("User-Agent"); |
||||
|
param.setUserAgent(agentString); |
||||
|
SysUser sysUser = sysUserMapper.selectById(AuthContextUtils.getSysUserId()); |
||||
|
appLog.setUserId(sysUser.getId()); |
||||
|
appLog.setUserName(sysUser.getName()); |
||||
|
appLog.setUserCode(sysUser.getCode()); |
||||
|
appLog.setUserAgent(param.getUserAgent()); |
||||
|
appLog.setDriveCode(param.getDriveCode()); |
||||
|
appLog.setErrorMsg(param.getErrorMsg()); |
||||
|
appLog.setLocalMsg(param.getLocalMsg()); |
||||
|
appLog.setLocalType(param.getLocalType()); |
||||
|
appLog.setSdkVersion(param.getSdkVersion()); |
||||
|
appLog.setNetInfo(param.getNetInfo()); |
||||
|
appLog.setSp1(param.getSp1()); |
||||
|
appLog.setSp2(param.getSp2()); |
||||
|
appLog.setSp3(param.getSp3()); |
||||
|
appLog.setSp4(param.getSp4()); |
||||
|
boolean flag = bizAppLogMapper.insert(appLog) > 0; |
||||
|
if (flag) { |
||||
|
param.setId(appLog.getId()); |
||||
|
} |
||||
|
return flag; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Boolean updateById(BizAppLog param) { |
||||
|
BizAppLog appLog = new BizAppLog(); |
||||
|
appLog.setId(param.getId()); |
||||
|
appLog.setUserAgent(param.getUserAgent()); |
||||
|
appLog.setDriveCode(param.getDriveCode()); |
||||
|
appLog.setErrorMsg(param.getErrorMsg()); |
||||
|
appLog.setLocalMsg(param.getLocalMsg()); |
||||
|
appLog.setLocalType(param.getLocalType()); |
||||
|
appLog.setSdkVersion(param.getSdkVersion()); |
||||
|
appLog.setNetInfo(param.getNetInfo()); |
||||
|
appLog.setSp1(param.getSp1()); |
||||
|
appLog.setSp2(param.getSp2()); |
||||
|
appLog.setSp3(param.getSp3()); |
||||
|
appLog.setSp4(param.getSp4()); |
||||
|
return bizAppLogMapper.updateById(appLog) > 0; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Boolean removeByIds(Collection<String> ids) { |
||||
|
return bizAppLogMapper.deleteBatchIds(ids) > 0; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
Loading…
Reference in new issue