mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
131
132
133
134
135
package com.panzhihua.service_community.service.impl;
 
import java.util.Date;
 
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.dtos.community.easyPhoto.AddEasyPhotoClassifyDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.easyPhoto.ComActEasyPhotoClassifyVO;
import com.panzhihua.service_community.dao.ComActEasyPhotoClassifyMapper;
import com.panzhihua.service_community.model.dos.ComActEasyPhotoClassifyDO;
import com.panzhihua.service_community.service.ComActEasyPhotoClassifyService;
 
import lombok.extern.slf4j.Slf4j;
 
/**
 * @auther lyq
 * @create 2021-08-19 15:50:58
 * @describe 随手拍分类表服务实现类
 */
@Slf4j
@Service
public class ComActEasyPhotoClassifyServiceImpl extends
    ServiceImpl<ComActEasyPhotoClassifyMapper, ComActEasyPhotoClassifyDO> implements ComActEasyPhotoClassifyService {
 
    /**
     * 运营后台-新增随手拍分类
     * 
     * @param addPhotoClassify
     *            请求参数
     * @return 新增结果
     */
    @Override
    public R addPhotoClassify(AddEasyPhotoClassifyDTO addPhotoClassify) {
        ComActEasyPhotoClassifyDO photoClassifyDO =
            this.baseMapper.selectOne(new QueryWrapper<ComActEasyPhotoClassifyDO>().lambda()
                .eq(ComActEasyPhotoClassifyDO::getName, addPhotoClassify.getName()).eq(ComActEasyPhotoClassifyDO::getAreaCode,addPhotoClassify.getAreaCode()));
        if (photoClassifyDO != null) {
            return R.fail("该随手拍分类已存在,请勿重复添加");
        }
        photoClassifyDO = new ComActEasyPhotoClassifyDO();
        BeanUtils.copyProperties(addPhotoClassify, photoClassifyDO);
        photoClassifyDO.setCreateAt(new Date());
        photoClassifyDO.setStatus(ComActEasyPhotoClassifyDO.status.yes);
        if (this.baseMapper.insert(photoClassifyDO) > 0) {
            return R.ok();
        } else {
            return R.fail();
        }
    }
 
    /**
     * 运营后台-编辑随手拍分类
     * 
     * @param addPhotoClassify
     *            请求参数
     * @return 编辑结果
     */
    @Override
    public R editPhotoClassify(AddEasyPhotoClassifyDTO addPhotoClassify) {
        ComActEasyPhotoClassifyDO photoClassifyDO = this.baseMapper.selectById(addPhotoClassify.getId());
        if (photoClassifyDO == null) {
            return R.fail("该随手拍分类不存在");
        }
        BeanUtils.copyProperties(addPhotoClassify, photoClassifyDO);
        photoClassifyDO.setUpdateAt(new Date());
        if (this.baseMapper.updateById(photoClassifyDO) > 0) {
            return R.ok();
        } else {
            return R.fail();
        }
    }
 
    /**
     * 运营后台-随手拍分类详情
     * 
     * @param id
     *            随手拍分类id
     * @return 随手拍分类
     */
    @Override
    public R detailPhotoClassify(Long id) {
        ComActEasyPhotoClassifyVO photoClassifyVO = new ComActEasyPhotoClassifyVO();
        ComActEasyPhotoClassifyDO photoClassifyDO = this.baseMapper.selectById(id);
        if (photoClassifyDO == null) {
            return R.fail("该随手拍分类不存在");
        }
        BeanUtils.copyProperties(photoClassifyDO, photoClassifyVO);
        return R.ok(photoClassifyVO);
    }
 
    /**
     * 运营后台-分页查询随手拍分类
     * 
     * @param addPhotoClassify
     *            请求参数
     * @return 随手拍分类列表
     */
    @Override
    public R pagePhotoClassify(AddEasyPhotoClassifyDTO addPhotoClassify) {
        return R.ok(this.baseMapper.getPhotoClassifyPage(
            new Page(addPhotoClassify.getPageNum(), addPhotoClassify.getPageSize()), addPhotoClassify));
    }
 
    /**
     * 运营后台-查询随手拍分类列表
     * 
     * @return 随手拍分类列表
     */
    @Override
    public R listPhotoClassify(String areaCode) {
        return R.ok(this.baseMapper.getPhotoClassifyList(areaCode));
    }
 
    /**
     * 运营后台-随手拍分类删除
     * 
     * @param id
     *            随手拍分类id
     * @return 删除结果
     */
    @Override
    public R deletePhotoClassify(Long id) {
        if (this.baseMapper.deleteById(id) > 0) {
            return R.ok();
        } else {
            return R.fail();
        }
    }
 
}