Helius
2022-05-27 4351e71d782741143a98f86f6648acd16689165f
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
package com.matrix.system.shopXcx.action;
 
 
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.constance.SystemMessageCode;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.ModelUtils;
import com.matrix.core.tools.StringUtils;
import com.matrix.core.constance.SystemErrorCode;
import com.matrix.core.anotations.RemoveRequestToken;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.shopXcx.api.vo.SalonVO;
import com.matrix.system.shopXcx.bean.ShopActivitiesGroupInfo;
import com.matrix.system.shopXcx.bean.ShopActivitiesSalonRecord;
import com.matrix.system.shopXcx.dao.ShopActivitiesGroupInfoDao;
import com.matrix.system.shopXcx.dao.ShopActivitiesSalonRecordDao;
import org.springframework.stereotype.Controller;
import com.matrix.core.exception.GlobleException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.matrix.core.anotations.SaveRequestToken;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.WebUtil;
import org.springframework.beans.factory.annotation.Autowired;
import com.matrix.system.shopXcx.bean.ShopActivitiesGroupJoin;
import org.springframework.web.servlet.ModelAndView;
 
import java.util.List;
import java.util.Map;
 
/**
 * @author wzy
 * @description 沙
 * @date 2020-03-21 15:26
 */
@Controller
@RequestMapping(value = "admin/shopActivitiesSalon")
public class ShopActivitiesSalonRecordAction {
 
    @Autowired
    private ShopActivitiesSalonRecordDao shopActivitiesSalonRecordDao;
 
    //记录编辑前的值Before_Edit_Value
    public static final String BEV = "ShopActivitiesSalonRecord_BEV";
 
 
    /**
     * 列表显示
     */
    @RequestMapping(value = "/showList")
    public @ResponseBody
    AjaxResult showList(ShopActivitiesSalonRecord shopActivitiesSalonRecord, PaginationVO pageVo) {
        if (pageVo == null) {
            pageVo = new PaginationVO();
        }
        List<ShopActivitiesSalonRecord> dataList = shopActivitiesSalonRecordDao.selectInPage(shopActivitiesSalonRecord, pageVo);
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList,
                shopActivitiesSalonRecordDao.selectTotalRecord(shopActivitiesSalonRecord));
        return result;
    }
 
    /**
     * 新增
     */
    @RemoveRequestToken
    @RequestMapping(value = "/addShopActivitiesSalonRecord")
    public @ResponseBody
    AjaxResult addShopActivitiesSalonRecord(ShopActivitiesSalonRecord shopActivitiesSalonRecord) {
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        shopActivitiesSalonRecord.setCreateBy(user.getSuName());
        shopActivitiesSalonRecord.setUpdateBy(user.getSuName());
        int i = shopActivitiesSalonRecordDao.insert(shopActivitiesSalonRecord);
        if (i > 0) {
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.ADD_SUCCES, "沙");
        } else {
            throw new GlobleException(SystemErrorCode.DATA_ADD_FAIL);
        }
    }
 
 
    /**
     * 修改
     */
    @RemoveRequestToken
    @RequestMapping(value = "/modifyShopActivitiesSalonRecord")
    public @ResponseBody
    AjaxResult modifyShopActivitiesSalonRecord(ShopActivitiesSalonRecord newShopActivitiesSalonRecord) {
        ShopActivitiesSalonRecord oldShopActivitiesSalonRecord = WebUtil.getSessionAttribute(BEV);
        int i = 0;
        Map<String, Object> modifyMap = null;
        try {
            if (!ModelUtils.isModified(oldShopActivitiesSalonRecord, newShopActivitiesSalonRecord)) {
                i = MatrixConstance.DML_SUCCESSS;
            }
            modifyMap = ModelUtils.comparePojo2Map(oldShopActivitiesSalonRecord, newShopActivitiesSalonRecord);
        } catch (Exception e) {
            throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL, e, newShopActivitiesSalonRecord);
        }
        if (modifyMap.size() > 0) {
            modifyMap.put("id", oldShopActivitiesSalonRecord.getId());
            shopActivitiesSalonRecordDao.updateByMap(modifyMap);
        }
        i = MatrixConstance.DML_SUCCESSS;
        WebUtil.removeSessionAttribute(BEV);
        if (i > 0) {
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.UPDATE_SUCCES, "沙");
        } else {
            throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL);
        }
    }
 
 
    /**
     * 进入修改界面
     */
    @SaveRequestToken
    @RequestMapping(value = "/editForm")
    public ModelAndView editForm(Long id) {
        ShopActivitiesSalonRecord shopActivitiesSalonRecord = new ShopActivitiesSalonRecord();
        ModelAndView modelAndView = new ModelAndView("admin/shopActivitiesSalonRecord-form");
        if (id != null) {
            shopActivitiesSalonRecord = shopActivitiesSalonRecordDao.selectById(id);
            WebUtil.setSessionAttribute(BEV, shopActivitiesSalonRecord);
        }
        modelAndView.addObject("obj", shopActivitiesSalonRecord);
        return modelAndView;
    }
 
 
    /**
     * 删除
     */
    @RequestMapping(value = "/del")
    public @ResponseBody
    AjaxResult del(String keys) {
        List<String> ids = StringUtils.strToCollToString(keys, ",");
        int i = shopActivitiesSalonRecordDao.deleteByIds(ids);
        if (i > 0) {
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.DELETE_SUCCES, i);
        } else {
            throw new GlobleException(SystemErrorCode.DATA_DELETE_FAIL);
        }
    }
 
    @RequestMapping(value = "/findSalonRecord")
    @ResponseBody
    public AjaxResult findSalonRecord(@RequestBody SalonVO salonVO) {
        ShopActivitiesSalonRecord record = new ShopActivitiesSalonRecord();
        record.setActId(salonVO.getActId());
        PaginationVO pageVo = new PaginationVO();
        pageVo.setLimit(salonVO.getLimit());
        pageVo.setOffset(salonVO.getOffset());
        List<ShopActivitiesSalonRecord> salonRecords = shopActivitiesSalonRecordDao.selectInPage(record, pageVo);
        int count = shopActivitiesSalonRecordDao.selectTotalRecord(record);
        return AjaxResult.buildSuccessInstance(salonRecords, count);
    }
 
    /**
     * 审核沙龙报名
     *
     * @param id     记录id
     * @param status 审核状态
     * @return
     */
    @RequestMapping(value = "/verifyStatus/{id}/{status}")
    @ResponseBody
    public AjaxResult verifyStatus(@PathVariable("id") Long id, @PathVariable("status") int status) {
        if (status != ShopActivitiesSalonRecord.JOIN_STATUS_Y && status != ShopActivitiesSalonRecord.JOIN_STATUS_N) {
            return AjaxResult.buildSuccessInstance("参数错误");
        }
        ShopActivitiesSalonRecord record = new ShopActivitiesSalonRecord();
        record.setId(id);
        record.setStatus(status);
        int i = shopActivitiesSalonRecordDao.updateByModel(record);
        if (i > 0) {
            return AjaxResult.buildSuccessInstance("审核成功");
        }
        return AjaxResult.buildFailInstance("审核失败");
    }
 
}