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 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 account = tUserService.selectList(new EntityWrapper().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 account = tUserService.selectList(new EntityWrapper().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); } }