Browse Source
feat(WxUtil): 优化企业微信access_token缓存处理逻辑支持解析JSON格式的缓存数据,同时兼容旧版纯字符串格式。当缓存中存在 access_token时,优先使用缓存值并直接调用用户信息获取方法。若缓存 解析失败,则降级使用原值以保证功能可用性。此外,调整了日志输出内容,使其更符合调试需求,并在重新获取token 时将完整的API响应缓存至Redis,与其他模块保持一致性。```dev
58 changed files with 1591 additions and 1243 deletions
File diff suppressed because it is too large
@ -0,0 +1,120 @@ |
|||
package com.gxwebsoft.oa.controller; |
|||
|
|||
import com.gxwebsoft.common.core.web.BaseController; |
|||
import com.gxwebsoft.common.system.entity.User; |
|||
import com.gxwebsoft.oa.service.OaTaskRecordService; |
|||
import com.gxwebsoft.oa.entity.OaTaskRecord; |
|||
import com.gxwebsoft.oa.param.OaTaskRecordParam; |
|||
import com.gxwebsoft.common.core.web.ApiResult; |
|||
import com.gxwebsoft.common.core.web.PageResult; |
|||
import com.gxwebsoft.common.core.web.PageParam; |
|||
import com.gxwebsoft.common.core.web.BatchParam; |
|||
import com.gxwebsoft.common.core.annotation.OperationLog; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import org.springframework.security.access.prepost.PreAuthorize; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 工单回复记录表控制器 |
|||
* |
|||
* @author 科技小王子 |
|||
* @since 2024-09-10 20:57:42 |
|||
*/ |
|||
@Tag(name = "工单回复记录表管理") |
|||
@RestController |
|||
@RequestMapping("/api/oa/oa-task-record") |
|||
public class OaTaskRecordController extends BaseController { |
|||
@Resource |
|||
private OaTaskRecordService oaTaskRecordService; |
|||
|
|||
@Operation(summary = "分页查询工单回复记录表") |
|||
@GetMapping("/page") |
|||
public ApiResult<PageResult<OaTaskRecord>> page(OaTaskRecordParam param) { |
|||
// 使用关联查询
|
|||
return success(oaTaskRecordService.pageRel(param)); |
|||
} |
|||
|
|||
@Operation(summary = "查询全部工单回复记录表") |
|||
@GetMapping() |
|||
public ApiResult<List<OaTaskRecord>> list(OaTaskRecordParam param) { |
|||
PageParam<OaTaskRecord, OaTaskRecordParam> page = new PageParam<>(param); |
|||
page.setDefaultOrder("create_time desc"); |
|||
return success(oaTaskRecordService.list(page.getOrderWrapper())); |
|||
// 使用关联查询
|
|||
//return success(oaTaskRecordService.listRel(param));
|
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('oa:oaTaskRecord:list')") |
|||
@OperationLog |
|||
@Operation(summary = "根据id查询工单回复记录表") |
|||
@GetMapping("/{id}") |
|||
public ApiResult<OaTaskRecord> get(@PathVariable("id") Integer id) { |
|||
return success(oaTaskRecordService.getById(id)); |
|||
// 使用关联查询
|
|||
//return success(oaTaskRecordService.getByIdRel(id));
|
|||
} |
|||
|
|||
@Operation(summary = "添加工单回复记录表") |
|||
@PostMapping() |
|||
public ApiResult<?> save(@RequestBody OaTaskRecord oaTaskRecord) { |
|||
// 记录当前登录用户id
|
|||
User loginUser = getLoginUser(); |
|||
if (loginUser != null) { |
|||
oaTaskRecord.setUserId(loginUser.getUserId()); |
|||
} |
|||
if (oaTaskRecordService.save(oaTaskRecord)) { |
|||
return success("添加成功"); |
|||
} |
|||
return fail("添加失败"); |
|||
} |
|||
|
|||
@Operation(summary = "修改工单回复记录表") |
|||
@PutMapping() |
|||
public ApiResult<?> update(@RequestBody OaTaskRecord oaTaskRecord) { |
|||
if (oaTaskRecordService.updateById(oaTaskRecord)) { |
|||
return success("修改成功"); |
|||
} |
|||
return fail("修改失败"); |
|||
} |
|||
|
|||
@Operation(summary = "删除工单回复记录表") |
|||
@DeleteMapping("/{id}") |
|||
public ApiResult<?> remove(@PathVariable("id") Integer id) { |
|||
if (oaTaskRecordService.removeById(id)) { |
|||
return success("删除成功"); |
|||
} |
|||
return fail("删除失败"); |
|||
} |
|||
|
|||
@Operation(summary = "批量添加工单回复记录表") |
|||
@PostMapping("/batch") |
|||
public ApiResult<?> saveBatch(@RequestBody List<OaTaskRecord> list) { |
|||
if (oaTaskRecordService.saveBatch(list)) { |
|||
return success("添加成功"); |
|||
} |
|||
return fail("添加失败"); |
|||
} |
|||
|
|||
@Operation(summary = "批量修改工单回复记录表") |
|||
@PutMapping("/batch") |
|||
public ApiResult<?> removeBatch(@RequestBody BatchParam<OaTaskRecord> batchParam) { |
|||
if (batchParam.update(oaTaskRecordService, "task_record_id")) { |
|||
return success("修改成功"); |
|||
} |
|||
return fail("修改失败"); |
|||
} |
|||
|
|||
@Operation(summary = "批量删除工单回复记录表") |
|||
@DeleteMapping("/batch") |
|||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) { |
|||
if (oaTaskRecordService.removeByIds(ids)) { |
|||
return success("删除成功"); |
|||
} |
|||
return fail("删除失败"); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,72 @@ |
|||
package com.gxwebsoft.oa.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import java.util.Date; |
|||
import com.baomidou.mybatisplus.annotation.TableLogic; |
|||
import java.io.Serializable; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 工单回复记录表 |
|||
* |
|||
* @author 科技小王子 |
|||
* @since 2024-09-10 20:57:42 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = false) |
|||
@Schema(name = "OaTaskRecord对象", description = "工单回复记录表") |
|||
public class OaTaskRecord implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "回复ID") |
|||
@TableId(value = "task_record_id", type = IdType.AUTO) |
|||
private Integer taskRecordId; |
|||
|
|||
@Schema(description = "上级id, 0是顶级") |
|||
private Integer parentId; |
|||
|
|||
@Schema(description = "工单ID") |
|||
private Integer taskId; |
|||
|
|||
@Schema(description = "内容") |
|||
private String content; |
|||
|
|||
@Schema(description = "机密信息") |
|||
private String confidential; |
|||
|
|||
@Schema(description = "联系电话") |
|||
private String phone; |
|||
|
|||
@Schema(description = "工单附件") |
|||
private String files; |
|||
|
|||
@Schema(description = "用户ID") |
|||
private Integer userId; |
|||
|
|||
@Schema(description = "排序(数字越小越靠前)") |
|||
private Integer sortNumber; |
|||
|
|||
@Schema(description = "备注") |
|||
private String comments; |
|||
|
|||
@Schema(description = "状态, 0待处理, 1已完成") |
|||
private Integer status; |
|||
|
|||
@Schema(description = "是否删除, 0否, 1是") |
|||
@TableLogic |
|||
private Integer deleted; |
|||
|
|||
@Schema(description = "租户id") |
|||
private Integer tenantId; |
|||
|
|||
@Schema(description = "创建时间") |
|||
private Date createTime; |
|||
|
|||
@Schema(description = "修改时间") |
|||
private Date updateTime; |
|||
|
|||
} |
@ -0,0 +1,37 @@ |
|||
package com.gxwebsoft.oa.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.gxwebsoft.oa.entity.OaTaskRecord; |
|||
import com.gxwebsoft.oa.param.OaTaskRecordParam; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 工单回复记录表Mapper |
|||
* |
|||
* @author 科技小王子 |
|||
* @since 2024-09-10 20:57:42 |
|||
*/ |
|||
public interface OaTaskRecordMapper extends BaseMapper<OaTaskRecord> { |
|||
|
|||
/** |
|||
* 分页查询 |
|||
* |
|||
* @param page 分页对象 |
|||
* @param param 查询参数 |
|||
* @return List<OaTaskRecord> |
|||
*/ |
|||
List<OaTaskRecord> selectPageRel(@Param("page") IPage<OaTaskRecord> page, |
|||
@Param("param") OaTaskRecordParam param); |
|||
|
|||
/** |
|||
* 查询全部 |
|||
* |
|||
* @param param 查询参数 |
|||
* @return List<User> |
|||
*/ |
|||
List<OaTaskRecord> selectListRel(@Param("param") OaTaskRecordParam param); |
|||
|
|||
} |
@ -0,0 +1,70 @@ |
|||
<?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="com.gxwebsoft.oa.mapper.OaAppRenewMapper"> |
|||
|
|||
<!-- 关联查询sql --> |
|||
<sql id="selectSql"> |
|||
SELECT a.*, |
|||
b.company_name,b.short_name,b.company_logo, |
|||
c.app_name |
|||
FROM oa_app_renew a |
|||
LEFT JOIN oa_company b ON a.company_id = b.company_id |
|||
LEFT JOIN oa_app c ON a.app_id = c.app_id |
|||
<where> |
|||
<if test="param.appRenewId != null"> |
|||
AND a.app_renew_id = #{param.appRenewId} |
|||
</if> |
|||
<if test="param.money != null"> |
|||
AND a.money = #{param.money} |
|||
</if> |
|||
<if test="param.comments != null"> |
|||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%') |
|||
</if> |
|||
<if test="param.startTime != null"> |
|||
AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%') |
|||
</if> |
|||
<if test="param.endTime != null"> |
|||
AND a.end_time LIKE CONCAT('%', #{param.endTime}, '%') |
|||
</if> |
|||
<if test="param.userId != null"> |
|||
AND a.user_id = #{param.userId} |
|||
</if> |
|||
<if test="param.appId != null"> |
|||
AND a.app_id = #{param.appId} |
|||
</if> |
|||
<if test="param.companyId != null"> |
|||
AND a.company_id = #{param.companyId} |
|||
</if> |
|||
|
|||
<if test="param.status != null"> |
|||
AND a.status = #{param.status} |
|||
</if> |
|||
<if test="param.createTimeStart != null"> |
|||
AND a.create_time >= #{param.createTimeStart} |
|||
</if> |
|||
<if test="param.createTimeEnd != null"> |
|||
AND a.create_time <= #{param.createTimeEnd} |
|||
</if> |
|||
</where> |
|||
</sql> |
|||
|
|||
<!-- 分页查询 --> |
|||
<select id="selectPageRel" resultType="com.gxwebsoft.oa.entity.OaAppRenew"> |
|||
<include refid="selectSql"></include> |
|||
</select> |
|||
|
|||
<!-- 查询全部 --> |
|||
<select id="selectListRel" resultType="com.gxwebsoft.oa.entity.OaAppRenew"> |
|||
<include refid="selectSql"></include> |
|||
</select> |
|||
|
|||
<!-- 统计金额总和 --> |
|||
<select id="selectSumMoney" resultType="java.math.BigDecimal"> |
|||
SELECT COALESCE(SUM(money), 0) as total_money |
|||
FROM oa_app_renew |
|||
<if test="ew != null"> |
|||
${ew.customSqlSegment} |
|||
</if> |
|||
</select> |
|||
|
|||
</mapper> |
@ -0,0 +1,68 @@ |
|||
<?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="com.gxwebsoft.oa.mapper.OaTaskRecordMapper"> |
|||
|
|||
<!-- 关联查询sql --> |
|||
<sql id="selectSql"> |
|||
SELECT a.* |
|||
FROM oa_task_record a |
|||
<where> |
|||
<if test="param.taskRecordId != null"> |
|||
AND a.task_record_id = #{param.taskRecordId} |
|||
</if> |
|||
<if test="param.parentId != null"> |
|||
AND a.parent_id = #{param.parentId} |
|||
</if> |
|||
<if test="param.taskId != null"> |
|||
AND a.task_id = #{param.taskId} |
|||
</if> |
|||
<if test="param.content != null"> |
|||
AND a.content LIKE CONCAT('%', #{param.content}, '%') |
|||
</if> |
|||
<if test="param.confidential != null"> |
|||
AND a.confidential LIKE CONCAT('%', #{param.confidential}, '%') |
|||
</if> |
|||
<if test="param.phone != null"> |
|||
AND a.phone LIKE CONCAT('%', #{param.phone}, '%') |
|||
</if> |
|||
<if test="param.files != null"> |
|||
AND a.files LIKE CONCAT('%', #{param.files}, '%') |
|||
</if> |
|||
<if test="param.userId != null"> |
|||
AND a.user_id = #{param.userId} |
|||
</if> |
|||
<if test="param.sortNumber != null"> |
|||
AND a.sort_number = #{param.sortNumber} |
|||
</if> |
|||
<if test="param.comments != null"> |
|||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%') |
|||
</if> |
|||
<if test="param.status != null"> |
|||
AND a.status = #{param.status} |
|||
</if> |
|||
<if test="param.deleted != null"> |
|||
AND a.deleted = #{param.deleted} |
|||
</if> |
|||
<if test="param.deleted == null"> |
|||
AND a.deleted = 0 |
|||
</if> |
|||
<if test="param.createTimeStart != null"> |
|||
AND a.create_time >= #{param.createTimeStart} |
|||
</if> |
|||
<if test="param.createTimeEnd != null"> |
|||
AND a.create_time <= #{param.createTimeEnd} |
|||
</if> |
|||
</where> |
|||
</sql> |
|||
|
|||
<!-- 分页查询 --> |
|||
<select id="selectPageRel" resultType="com.gxwebsoft.oa.entity.OaTaskRecord"> |
|||
<include refid="selectSql"></include> |
|||
</select> |
|||
|
|||
<!-- 查询全部 --> |
|||
<select id="selectListRel" resultType="com.gxwebsoft.oa.entity.OaTaskRecord"> |
|||
<include refid="selectSql"></include> |
|||
</select> |
|||
|
|||
</mapper> |
@ -0,0 +1,42 @@ |
|||
package com.gxwebsoft.oa.service; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.gxwebsoft.common.core.web.PageResult; |
|||
import com.gxwebsoft.oa.entity.OaTaskRecord; |
|||
import com.gxwebsoft.oa.param.OaTaskRecordParam; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 工单回复记录表Service |
|||
* |
|||
* @author 科技小王子 |
|||
* @since 2024-09-10 20:57:42 |
|||
*/ |
|||
public interface OaTaskRecordService extends IService<OaTaskRecord> { |
|||
|
|||
/** |
|||
* 分页关联查询 |
|||
* |
|||
* @param param 查询参数 |
|||
* @return PageResult<OaTaskRecord> |
|||
*/ |
|||
PageResult<OaTaskRecord> pageRel(OaTaskRecordParam param); |
|||
|
|||
/** |
|||
* 关联查询全部 |
|||
* |
|||
* @param param 查询参数 |
|||
* @return List<OaTaskRecord> |
|||
*/ |
|||
List<OaTaskRecord> listRel(OaTaskRecordParam param); |
|||
|
|||
/** |
|||
* 根据id查询 |
|||
* |
|||
* @param taskRecordId 回复ID |
|||
* @return OaTaskRecord |
|||
*/ |
|||
OaTaskRecord getByIdRel(Integer taskRecordId); |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.gxwebsoft.oa.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.gxwebsoft.oa.mapper.OaTaskRecordMapper; |
|||
import com.gxwebsoft.oa.service.OaTaskRecordService; |
|||
import com.gxwebsoft.oa.entity.OaTaskRecord; |
|||
import com.gxwebsoft.oa.param.OaTaskRecordParam; |
|||
import com.gxwebsoft.common.core.web.PageParam; |
|||
import com.gxwebsoft.common.core.web.PageResult; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 工单回复记录表Service实现 |
|||
* |
|||
* @author 科技小王子 |
|||
* @since 2024-09-10 20:57:42 |
|||
*/ |
|||
@Service |
|||
public class OaTaskRecordServiceImpl extends ServiceImpl<OaTaskRecordMapper, OaTaskRecord> implements OaTaskRecordService { |
|||
|
|||
@Override |
|||
public PageResult<OaTaskRecord> pageRel(OaTaskRecordParam param) { |
|||
PageParam<OaTaskRecord, OaTaskRecordParam> page = new PageParam<>(param); |
|||
page.setDefaultOrder("create_time desc"); |
|||
List<OaTaskRecord> list = baseMapper.selectPageRel(page, param); |
|||
return new PageResult<>(list, page.getTotal()); |
|||
} |
|||
|
|||
@Override |
|||
public List<OaTaskRecord> listRel(OaTaskRecordParam param) { |
|||
List<OaTaskRecord> list = baseMapper.selectListRel(param); |
|||
// 排序
|
|||
PageParam<OaTaskRecord, OaTaskRecordParam> page = new PageParam<>(); |
|||
page.setDefaultOrder("create_time desc"); |
|||
return page.sortRecords(list); |
|||
} |
|||
|
|||
@Override |
|||
public OaTaskRecord getByIdRel(Integer taskRecordId) { |
|||
OaTaskRecordParam param = new OaTaskRecordParam(); |
|||
param.setTaskRecordId(taskRecordId); |
|||
return param.getOne(baseMapper.selectListRel(param)); |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue