1821349743@qq.com
2023-02-20 146b951e36b7529f4aa9671035a657f651762edc
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
package com.product.administration.controller;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import com.product.administration.config.CmnConst;
import com.product.administration.config.SystemCode;
import com.product.administration.service.WorkAttendanceLocationService;
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
import com.product.module.sys.version.ApiVersion;
 
@RequestMapping("/api/attendance-location")
@RestController
public class WorkAttendanceLocationController extends AbstractBaseController{
 
    @Autowired
    WorkAttendanceLocationService workAttendanceLocationService;
    
    /**
     *     考勤地点查询
     *
     * @param response
     * @param request
     * @return
     */
    @RequestMapping(value = "/list-location/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String listAttendanceLocationInfoByUser(HttpServletResponse response, HttpServletRequest request) {
        try {
            //获取参数
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            //判断参数是否为空
            if (bean == null || fse == null) {
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            //判断表名是否正常
            if (!CmnConst.PRODUCT_OA_PUNCH_SITE.equals(fse.getTableName())) {
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            FieldSetEntity fseData=new FieldSetEntity();
            fseData.setTableName(CmnConst.PRODUCT_OA_PUNCH_SITE);
            DataTableEntity dt = workAttendanceLocationService.listAttendanceLocationInfoByUser();
            fseData.addSubDataTable(dt);
            return OK_List(dt);
        } catch (BaseException e) {
            e.printStackTrace();
            return this.error(e.getCode(), e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return this.error(SystemCode.ATTENDANCE_LOCATION_LIST_FAIL.getValue(), SystemCode.ATTENDANCE_LOCATION_LIST_FAIL.getText() + e.getMessage());
        }
    }
    
    /**
     *     考勤地点保存
     *
     * @param response
     * @param request
     * @return
     */
    @RequestMapping(value = "/save-location/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String saveAttendanceLocationInfoByUser(HttpServletResponse response, HttpServletRequest request) {
        try {
            //获取参数
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            //判断参数是否为空
            if (bean == null || fse == null) {
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            //判断表名是否正常
            if (!CmnConst.PRODUCT_OA_PUNCH_SITE.equals(fse.getTableName())) {
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            boolean succ = workAttendanceLocationService.saveAttendanceLocationInfoByUser(fse.getSubDataTable(CmnConst.PRODUCT_OA_PUNCH_SITE));
            if (succ) {
                return OK();
            }
            return this.error(SystemCode.ATTENDANCE_LOCATION_SAVE_FAIL.getValue(), SystemCode.ATTENDANCE_LOCATION_SAVE_FAIL.getText());
        } catch (BaseException e) {
            e.printStackTrace();
            return this.error(e.getCode(), e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return this.error(SystemCode.ATTENDANCE_LOCATION_SAVE_FAIL.getValue(), SystemCode.ATTENDANCE_LOCATION_SAVE_FAIL.getText() + e.getMessage());
        }
    }
}