医院废弃物信息化管理平台
“mitao”
2025-12-25 0242c8ae596f44427cd23d38f637bf987a4de0bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package cn.besteam.modules.medical.controller;
 
import cn.besteam.common.api.vo.Result;
import cn.besteam.common.aspect.annotation.AutoLog;
import cn.besteam.common.constant.ErrorCode;
import cn.besteam.common.dto.IdDTO;
import cn.besteam.common.exception.BusinessException;
import cn.besteam.modules.medical.dto.MwAppVersionDTO;
import cn.besteam.modules.medical.dto.MwAppVersionUpdateDTO;
import cn.besteam.modules.medical.entity.MwAppVersion;
import cn.besteam.modules.medical.service.IMwAppVersionService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * @Title: Controller
 * @Description: APP-版本
 * @author: besteam
 * @date: 2020-04-25
 * @version: V1.0
 */
@RestController
@RequestMapping("/medical/mwAppVersion")
@Slf4j
@Api(description = "APP-版本")
public class MwAppVersionController {
 
    @Autowired
    private IMwAppVersionService mwAppVersionService;
 
    /**
     * 分页列表查询
     *
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/list")
    @ApiOperation(value = "获取APP-版本数据列表", notes = "获取所有APP-版本数据列表", produces = "application/json")
    public Result<IPage<MwAppVersion>> queryPageList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
 
        QueryWrapper<MwAppVersion> queryWrapper = new QueryWrapper<MwAppVersion>();
        queryWrapper.lambda().orderByDesc(MwAppVersion::getVersion);
        Page<MwAppVersion> page = new Page<MwAppVersion>(pageNo, pageSize);
        IPage<MwAppVersion> pageList = mwAppVersionService.page(page, queryWrapper);
        return Result.ok(pageList);
    }
 
    // @GetMapping(value = "/getLatest")
    // @ApiOperation(value = "获取最新版本APK", notes = "获取最新版本APK", produces = "application/json")
    // public Result<MwAppVersion> getLatest() {
    //
    //     List<MwAppVersion> list = mwAppVersionService.list(new QueryWrapper<MwAppVersion>().lambda().orderByDesc(MwAppVersion::getVersion));
    //     if (CollectionUtils.isNotEmpty(list)) {
    //         return Result.ok(list.get(0));
    //     } else {
    //         return Result.ok((MwAppVersion) null);
    //     }
    // }
 
    /**
     * 添加
     *
     * @return
     */
    @PostMapping(value = "/uploadApk")
    @ApiOperation(value = "上传APK", notes = "上传APK", produces = "application/json")
    public Result<Boolean> uploadApk(@Validated MwAppVersionDTO dto) {
 
        return Result.ok(mwAppVersionService.uploadApk(dto));
    }
 
    /**
     * 编辑
     *
     * @param dto
     * @return
     */
    @PostMapping(value = "/edit")
    @ApiOperation(value = "编辑APP-版本", notes = "编辑APP-版本", produces = "application/json")
    public Result<Boolean> edit(@Validated @RequestBody MwAppVersionUpdateDTO dto) {
 
        MwAppVersion mwAppVersionEntity = mwAppVersionService.getById(dto.getId());
        if (mwAppVersionEntity == null) {
            throw new BusinessException(ErrorCode.MW_APK_VERSION_NOT_FOUND);
        }
        if (mwAppVersionService.getOne(new QueryWrapper<MwAppVersion>().lambda().eq(MwAppVersion::getVersion, dto.getVersion()).ne(MwAppVersion::getId, dto.getId())) != null) {
            throw new BusinessException(ErrorCode.MW_APK_VERSION_REPEAT);
        }
        mwAppVersionEntity.setDescription(dto.getDescription());
        mwAppVersionEntity.setVersion(dto.getVersion());
        mwAppVersionEntity.setVersionName(dto.getVersionName());
        return Result.ok(mwAppVersionService.updateById(mwAppVersionEntity));
    }
 
    /**
     * 通过id删除
     *
     * @param dto
     * @return
     */
    @PostMapping(value = "/delete")
    @AutoLog(value = "删除APP-版本")
    @ApiOperation(value = "删除APP-版本", notes = "删除APP-版本", produces = "application/json")
    public Result<MwAppVersion> delete(@Validated @RequestBody IdDTO dto) {
 
        Result<MwAppVersion> result = new Result<MwAppVersion>();
        MwAppVersion mwAppVersion = mwAppVersionService.getById(dto.getId());
        if (mwAppVersion == null) {
            result.error500("未找到对应实体");
        } else {
            boolean ok = mwAppVersionService.removeById(dto.getId());
            if (ok) {
                result.success("删除成功!");
            }
        }
        return result;
    }
 
}