Browse Source

add
头像管理

lifang 3 tháng trước cách đây
mục cha
commit
8eaeb8f172

+ 41 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/app/controller/AppAvatarController.java

@@ -0,0 +1,41 @@
+package cn.tr.module.smart.app.controller;
+
+import cn.tr.core.pojo.CommonResult;
+import cn.tr.module.smart.common.dto.BizAvatarDTO;
+import cn.tr.module.smart.common.dto.BizAvatarQueryDTO;
+import cn.tr.module.smart.common.enums.AvatarTypeEnum;
+import cn.tr.module.smart.common.service.IBizAvatarService;
+import cn.tr.plugin.mybatis.base.BaseController;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 头像控制器
+ *
+ * @author lf
+ * @date  2025/09/01 11:36
+ */
+@Api(tags = "医生端头像管理")
+@RestController
+@RequestMapping("/app/avatar")
+@AllArgsConstructor
+public class AppAvatarController extends BaseController{
+
+    private final IBizAvatarService bizAvatarService;
+
+    @ApiOperationSupport(author = "lf",order = 1)
+    @ApiOperation(value="根据条件查询头像(不分页)",notes = "权限: 无")
+    @PostMapping("/query/list")
+    public CommonResult<List<BizAvatarDTO>> selectList() {
+        BizAvatarQueryDTO query = new BizAvatarQueryDTO();
+        query.setType(AvatarTypeEnum.DOCTOR_AVATAR);
+        return CommonResult.success(bizAvatarService.selectBizAvatarList(query));
+    }
+}

+ 36 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/dto/BizAvatarDTO.java

@@ -0,0 +1,36 @@
+package cn.tr.module.smart.common.dto;
+
+import cn.tr.plugin.mybatis.pojo.BaseDTO;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import cn.tr.core.validation.Insert;
+import cn.tr.core.validation.Update;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import javax.validation.constraints.*;
+import java.util.*;
+/**
+ * 头像传输对象
+ *
+ * @author lf
+ * @date  2025/09/01 11:36
+ **/
+@Data
+@ApiModel("头像传输对象")
+@EqualsAndHashCode(callSuper = true)
+@ToString
+public class BizAvatarDTO extends BaseDTO  {
+    private static final long serialVersionUID = 1L;
+    @ApiModelProperty(value = "id", position = 1)
+     @NotBlank  (message = "主键不能为空",groups = {Update.class})
+    private String id;
+
+    @ApiModelProperty(value = "头像类型", position = 2)
+    @NotBlank  (message = "头像类型不能为空",groups = {Insert.class,Update.class})
+    private String type;
+
+    @ApiModelProperty(value = "头像链接", position = 4)
+    private String url;
+
+}

+ 24 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/dto/BizAvatarQueryDTO.java

@@ -0,0 +1,24 @@
+package cn.tr.module.smart.common.dto;
+
+import lombok.ToString;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.util.*;
+/**
+ * 头像查询参数
+ *
+ * @author lf
+ * @date  2025/09/01 11:36
+ **/
+@Data
+@ApiModel("头像查询参数")
+@ToString
+public class BizAvatarQueryDTO  {
+    private static final long serialVersionUID = 1L;
+
+    @NotBlank(message = "头像类型不能为空")
+    private String type;
+}

+ 16 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/enums/AvatarTypeEnum.java

@@ -0,0 +1,16 @@
+package cn.tr.module.smart.common.enums;
+
+/**
+ * 头像类型
+ */
+public interface AvatarTypeEnum {
+    /**
+     * 患者头像
+     */
+    String PATIENT_AVATAR = "patient_avatar";
+
+    /**
+     * 医生头像
+     */
+    String DOCTOR_AVATAR="doctor_avatar";
+}

+ 28 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/mapper/BizAvatarMapper.java

@@ -0,0 +1,28 @@
+package cn.tr.module.smart.common.mapper;
+
+import cn.tr.module.smart.common.po.BizAvatarPO;
+import cn.tr.module.smart.common.dto.BizAvatarDTO;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+
+/**
+* 头像映射工具
+*
+* @author lf
+* @date  2025/09/01 11:36
+**/
+@Mapper
+public interface BizAvatarMapper {
+    BizAvatarMapper INSTANCE = Mappers.getMapper(BizAvatarMapper.class);
+
+    BizAvatarPO convertPO(BizAvatarDTO source);
+
+    BizAvatarDTO convertDto(BizAvatarPO source);
+
+    List<BizAvatarDTO> convertDtoList(List<BizAvatarPO> source);
+
+    List<BizAvatarPO> convertPOList(List<BizAvatarDTO> source);
+
+}

+ 40 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/po/BizAvatarPO.java

@@ -0,0 +1,40 @@
+package cn.tr.module.smart.common.po;
+
+
+import cn.tr.module.smart.common.enums.AvatarTypeEnum;
+import cn.tr.plugin.mybatis.pojo.BasePO;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+/**
+ * 头像实体
+ *
+ * @author lf
+ * @date  2025/09/01 11:36
+ **/
+@Data
+@TableName(value="biz_avatar",autoResultMap = true)
+@EqualsAndHashCode(callSuper = true)
+@ToString
+public class BizAvatarPO extends BasePO {
+
+    /** id */
+    @TableId
+    @ApiModelProperty(value = "id", position = 1)
+    private String id;
+
+    /**
+     * {@link  AvatarTypeEnum}
+     * 头像类型
+     * */
+    @ApiModelProperty(value = "头像类型", position = 2)
+    private String type;
+
+    /** 头像链接 */
+    @ApiModelProperty(value = "头像链接", position = 4)
+    private String url;
+
+}

+ 16 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/repository/BizAvatarRepository.java

@@ -0,0 +1,16 @@
+package cn.tr.module.smart.common.repository;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+import cn.tr.module.smart.common.po.BizAvatarPO;
+/**
+ * 头像Mapper接口
+ *
+ * @author lf
+ * @date  2025/09/01 11:36
+ **/
+@Repository
+@Mapper
+public interface BizAvatarRepository extends BaseMapper<BizAvatarPO> {
+}

+ 54 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/service/IBizAvatarService.java

@@ -0,0 +1,54 @@
+package cn.tr.module.smart.common.service;
+
+import cn.tr.module.smart.common.dto.BizAvatarDTO;
+import cn.tr.module.smart.common.dto.BizAvatarQueryDTO;
+import java.util.*;
+
+/**
+ * 头像Service接口
+ *
+ * @author lf
+ * @date  2025/09/01 11:36
+ **/
+public interface IBizAvatarService{
+
+    /**
+     * 根据条件查询头像
+     * @param    query 查询参数
+     * @author   lf
+     * @date      2025/09/01 11:36
+     */
+    List<BizAvatarDTO> selectBizAvatarList(BizAvatarQueryDTO query);
+
+    /**
+     * 根据id查询头像
+     * @param    id 主键id
+     * @author   lf
+     * @date      2025/09/01 11:36
+     */
+    BizAvatarDTO selectBizAvatarById(String id);
+
+    /**
+     * 编辑头像
+     * @param   source 编辑实体类
+     * @author  lf
+     * @date     2025/09/01 11:36
+     */
+    boolean updateBizAvatarById(BizAvatarDTO source);
+
+    /**
+     * 新增头像
+     * @param   source 新增实体类
+     * @author lf
+     * @date  2025/09/01 11:36
+     */
+    boolean insertBizAvatar(BizAvatarDTO source);
+
+    /**
+     * 删除头像详情
+     * @param  ids 删除主键集合
+     * @author lf
+     * @date    2025/09/01 11:36
+     */
+    int removeBizAvatarByIds(Collection<String> ids);
+}

+ 92 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/service/impl/BizAvatarServiceImpl.java

@@ -0,0 +1,92 @@
+package cn.tr.module.smart.common.service.impl;
+
+import cn.tr.core.exception.TRExcCode;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import cn.hutool.core.collection.CollectionUtil;
+import org.springframework.transaction.annotation.Transactional;
+import cn.tr.core.exception.ServiceException;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import cn.tr.module.smart.common.repository.BizAvatarRepository;
+import cn.tr.module.smart.common.po.BizAvatarPO;
+import cn.tr.module.smart.common.dto.BizAvatarDTO;
+import cn.tr.module.smart.common.dto.BizAvatarQueryDTO;
+import java.util.*;
+import cn.tr.module.smart.common.service.IBizAvatarService;
+import cn.tr.module.smart.common.mapper.BizAvatarMapper;
+/**
+ * 头像Service接口实现类
+ *
+ * @author lf
+ * @date  2025/09/01 11:36
+ **/
+@Service
+public class BizAvatarServiceImpl implements IBizAvatarService {
+    @Autowired
+    private BizAvatarRepository baseRepository;
+
+
+    /**
+    * 根据条件查询头像
+    * @param    query 查询参数
+    * @author   lf
+    * @date      2025/09/01 11:36
+    */
+    @Override
+    public List<BizAvatarDTO> selectBizAvatarList(BizAvatarQueryDTO query){
+        return BizAvatarMapper.INSTANCE.convertDtoList(
+                baseRepository.selectList(new LambdaQueryWrapper<BizAvatarPO>()
+                )
+        );
+    };
+
+    /**
+    * 根据id查询头像
+    * @param    id 主键id
+    * @author   lf
+    * @date      2025/09/01 11:36
+    */
+    @Override
+    public BizAvatarDTO selectBizAvatarById(String id){
+        return BizAvatarMapper.INSTANCE.convertDto(baseRepository.selectById(id));
+    };
+
+    /**
+    * 编辑头像
+    * @param   source 编辑实体类
+    * @author  lf
+    * @date     2025/09/01 11:36
+    */
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public boolean updateBizAvatarById(BizAvatarDTO source){
+            return baseRepository.updateById(BizAvatarMapper.INSTANCE.convertPO(source))!=0;
+    };
+
+    /**
+    * 新增头像
+    * @param   source 新增实体类
+    * @author lf
+    * @date  2025/09/01 11:36
+    */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean insertBizAvatar(BizAvatarDTO source){
+        return baseRepository.insert(BizAvatarMapper.INSTANCE.convertPO(source))!=0;
+    };
+
+    /**
+    * 删除头像详情
+    * @param  ids 删除主键集合
+    * @author lf
+    * @date    2025/09/01 11:36
+    */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int removeBizAvatarByIds(Collection<String> ids){
+        if(CollectionUtil.isEmpty(ids)){
+            throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"请选择要删除的数据");
+        }
+        return baseRepository.deleteBatchIds(ids);
+    };
+}

+ 56 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/web/controller/BizAvatarController.java

@@ -0,0 +1,56 @@
+package cn.tr.module.smart.web.controller;
+
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.tr.core.validation.Insert;
+import cn.tr.core.pojo.CommonResult;
+import lombok.AllArgsConstructor;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+import cn.tr.module.smart.common.dto.BizAvatarDTO;
+import cn.tr.module.smart.common.service.IBizAvatarService;
+import cn.tr.module.smart.common.dto.BizAvatarQueryDTO;
+import java.util.*;
+import cn.tr.plugin.mybatis.base.BaseController;
+import org.springframework.web.bind.annotation.*;
+/**
+ * 头像控制器
+ *
+ * @author lf
+ * @date  2025/09/01 11:36
+ */
+@Api(tags = "头像管理")
+@RestController
+@RequestMapping("/web/avatar")
+@AllArgsConstructor
+public class BizAvatarController extends BaseController{
+
+    private final IBizAvatarService bizAvatarService;
+
+    @ApiOperationSupport(author = "lf",order = 1)
+    @ApiOperation(value="根据条件查询头像(不分页)",notes = "权限: 无")
+    @PostMapping("/query/list")
+    public CommonResult<List<BizAvatarDTO>> selectList(@RequestBody@Validated BizAvatarQueryDTO query) {
+        return CommonResult.success(bizAvatarService.selectBizAvatarList(query));
+    }
+
+    @ApiOperationSupport(author = "lf",order = 2)
+    @ApiOperation(value="添加头像",notes = "权限: common:avatar:add")
+    @PostMapping("/add")
+    @SaCheckPermission("common:avatar:add")
+    public CommonResult<Boolean> add(@RequestBody@Validated(Insert.class) BizAvatarDTO source) {
+        return CommonResult.success(bizAvatarService.insertBizAvatar(source));
+    }
+
+    @ApiOperationSupport(author = "lf",order = 3)
+    @ApiOperation(value="删除头像",notes = "权限: common:avatar:remove")
+    @PostMapping("/removeByIds")
+    @SaCheckPermission("common:avatar:remove")
+    public CommonResult<Integer> delete(@RequestBody Collection<String> ids) {
+        return CommonResult.success(bizAvatarService.removeBizAvatarByIds(ids));
+    }
+}

+ 1 - 0
tr-test/src/main/resources/application.yml

@@ -100,6 +100,7 @@ tr:
       - im_msg_send
       - biz_infusion_clinic
       - biz_wx_user
+      - biz_avatar
     ignore-urls:
       - /oauth2/psw/token
       - /sys/log/**