liujie
2023-05-15 6225c37d2f53adf26daf6b4859af5fb5c6fad088
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
package com.stylefeng.guns.modular.system.controller;
 
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.util.MD5Util;
import com.stylefeng.guns.modular.system.enums.UserFeeSettingEnum;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.ITUserAddressService;
import com.stylefeng.guns.modular.system.service.ITUserFeeSettingService;
import com.stylefeng.guns.modular.system.service.ITUserFileService;
import com.stylefeng.guns.modular.system.utils.EmailUtil;
import com.stylefeng.guns.modular.system.utils.tips.ErrorTip;
import com.stylefeng.guns.modular.system.utils.tips.SuccessTip;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.ui.Model;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.modular.system.service.ITUserService;
 
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
 
/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2023-01-09 09:51:51
 */
@Controller
@Api(tags = "客户")
@RequestMapping("/api/tUser")
public class TUserController extends BaseController {
 
    @Autowired
    private ITUserService tUserService;
 
    /**
     * 获取列表
     */
    @ApiOperation(value = "卡车公司-客户列表",notes="卡车公司-客户列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "name", value = "客户名称", required = false, dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "id", value = "客户id", required = false, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "companyId", value = "卡车公司id", required = true, dataType = "int",paramType = "query"),
    })
    @GetMapping(value = "/list")
    @ResponseBody
    public Object list(String name,Integer id,int pageNumber,int pageSize,int companyId) {
        Page<TUserVo> tUserVoPage = new Page<>(pageNumber, pageSize);
        return new SuccessTip(tUserVoPage.setRecords(tUserService.getList(tUserVoPage,name,id,companyId)));
    }
 
    /**
     * 新增
     */
    @ApiOperation(value = "卡车公司-新增客户-主账号",notes="卡车公司-新增客户-主账号")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    @PostMapping(value = "/add")
    @ResponseBody
    public Object add(@RequestBody TUserDto tUser) {
        try {
            List<TUser> account = tUserService.selectList(new EntityWrapper<TUser>().eq("account", tUser.getAccount()));
            if(account.size()>0){
                return new ErrorTip(501, "该账号已经存在!");
            }
            String encrypt = MD5Util.encrypt(tUser.getPassword());
            tUser.setPassword(encrypt);
            TUser tUser1 = new TUser();
            tUser1.setEmail(tUser.getAccount());
            BeanUtils.copyProperties(tUser,tUser1);
            tUser1.setParentId(0);
            tUser1.setHome(0);
            tUser1.setAccountSettings(0);
            tUser1.setMyRequirement(0);
            tUser1.setMyOrder(0);
            tUser1.setMyBankCard(0);
            tUser1.setMyAddress(0);
            tUser1.setWallet(0);
            tUser1.setBill(0);
            tUser1.setViewDetails(0);
            tUser1.setDelete(0);
            tUser1.setEdit(0);
            tUser1.setCreateTime(new Date());
            tUser1.setStatus(1);
            tUser1.setCompanyId(tUser.getCompanyId());
            tUserService.insert(tUser1);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return  ERROR;
        }
    }
 
    /**
     * 删除
     */
    @ApiOperation(value = "卡车公司-删除客户",notes="卡车公司-删除客户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "tUserId", value = "客户id", required = true, dataType = "int"),
    })
    @DeleteMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer tUserId) {
        TUser tUser = tUserService.selectById(tUserId);
//        if(tUser.getStatus()!=3){
//            return new ErrorTip(502, "删除只能删除冻结的用户!");
//        }
        tUser.setRemove(1);
        tUserService.updateById(tUser);
        return SUCCESS_TIP;
    }
 
    /**
     * 修改
     */
    @ApiOperation(value = "卡车公司-修改客户",notes="卡车公司-修改客户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    @PostMapping(value = "/update")
    @ResponseBody
    public Object update(TUserDto tUser) {
        List<TUser> account = tUserService.selectList(new EntityWrapper<TUser>().eq("account", tUser.getAccount()).ne("id",tUser.getId()));
        if(account.size()>0){
            return new ErrorTip(501, "该账号已经存在!");
        }
        if(tUser.getPassword()!=null && tUser.getPassword()!=""){
            tUser.setPassword(MD5Util.encrypt(tUser.getPassword()));
        }
        TUser user1 = new TUser();
        BeanUtils.copyProperties(tUser,user1);
        tUserService.updateById(user1);
        return SUCCESS_TIP;
    }
 
 
    @ApiOperation(value = "卡车公司-根据客户id获取基本信息",notes="卡车公司-根据客户id获取基本信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "tUserId", value = "客户id", required = true, dataType = "int"),
    })
    @PostMapping(value = "/getBasicInfo")
    @ResponseBody
    public Object getBasicInfo(Integer tUserId) {
        TUserBasicInfo tUser = tUserService.getBasicInfo(tUserId);
        return new SuccessTip(tUser);
    }
 
 
 
    public static void main(String[] args) {
 
        DateTime offset = DateUtil.offset(new Date(), DateField.MINUTE, 30);
        String substring = offset.toString().split(" ")[1].substring(0, 5);
 
        System.out.println(substring);
        String s = offset.toDateStr();
        System.out.println(s);
    }
 
 
 
}