package com.controller;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.HuashiEntity;
import com.entity.view.HuashiView;
import com.service.HuashiService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
import java.io.IOException;
import com.service.StoreupService;
import com.entity.StoreupEntity;
/**
* 画师
* 后端接口
* @author
* @email
* @date 2023-02-24 12:24:29
*/
@RestController
@RequestMapping("/huashi")
public class HuashiController {
@Autowired
private HuashiService huashiService;
@Autowired
private StoreupService storeupService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
HuashiEntity u = huashiService.selectOne(new EntityWrapper<HuashiEntity>().eq("huashizhanghao", username));
if(u==null || !u.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(u.getId(), username,"huashi", "画师" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody HuashiEntity huashi){
//ValidatorUtils.validateEntity(huashi);
HuashiEntity u = huashiService.selectOne(new EntityWrapper<HuashiEntity>().eq("huashizhanghao", huashi.getHuashizhanghao()));
if(u!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
huashi.setId(uId);
huashiService.insert(huashi);
return R.ok();
}
/**
* 退出
*/
@RequestMapping("/logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
HuashiEntity u = huashiService.selectById(id);
return R.ok().put("data", u);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
HuashiEntity u = huashiService.selectOne(new EntityWrapper<HuashiEntity>().eq("huashizhanghao", username));
if(u==null) {
return R.error("账号不存在");
}
u.setMima("123456");
huashiService.updateById(u);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuashiEntity huashi,
HttpServletRequest request){
EntityWrapper<HuashiEntity> ew = new EntityWrapper<HuashiEntity>();
PageUtils page = huashiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huashi), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuashiEntity huashi,
HttpServletRequest request){
EntityWrapper<HuashiEntity> ew = new EntityWrapper<HuashiEntity>();
PageUtils page = huashiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huashi), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( HuashiEntity huashi){
EntityWrapper<HuashiEntity> ew = new EntityWrapper<HuashiEntity>();
ew.allEq(MPUtil.allEQMapPre( huashi, "huashi"));
return R.ok().put("data", huashiService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(HuashiEntity huashi){
EntityWrapper< HuashiEntity> ew = new EntityWrapper< HuashiEntity>();
ew.allEq(MPUtil.allEQMapPre( huashi, "huashi"));
HuashiView huashiView = huashiService.selectView(ew);
return R.ok("查询画师成功").put("data", huashiView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
HuashiEntity huashi = huashiService.selectById(id);
huashi.setClicknum(huashi.getClicknum()+1);
huashi.setClicktime(new Date());
huashiService.updateById(huashi);
return R.ok().put("data", huashi);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
HuashiEntity huashi = huashiService.selectById(id);
huashi.setClicknum(huashi.getClicknum()+1);
huashi.setClicktime(new Date());
huashiService.updateById(huashi);
return R.ok().put("data", huashi);
}
/**
* 赞或踩
*/
@RequestMapping("/thumbsup/{id}")
public R vote(@PathVariable("id") String id,String type){
HuashiEntity huashi = huashiService.selectById(id);
if(type.equals("1")) {
huashi.setThumbsupnum(huashi.getThumbsupnum()+1);
} else {
huashi.setCrazilynum(huashi.getCrazilynum()+1);
}
huashiService.updateById(huashi);
return R.ok("投票成功");
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody HuashiEntity huashi, HttpServletRequest request){
huashi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huashi);
HuashiEntity u = huashiService.selectOne(new EntityWrapper<HuashiEntity>().eq("huashizhanghao", huashi.getHuashizhanghao()));
if(u!=null) {
return R.error("用户已存在");
}
huashi.setId(new Date().getTime());
huashiService.insert(huashi);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody HuashiEntity huashi, HttpServletRequest request){
huashi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huashi);
HuashiEntity u = huashiService.selectOne(new EntityWrapper<HuashiEntity>().eq("huashizhanghao", huashi.getHuashizhanghao()));
if(u!=null) {
return R.error("用户已存在");
}
huashi.setId(new Date().getTime());
huashiService.insert(huashi);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody HuashiEntity huashi, HttpServletRequest request){
//ValidatorUtils.validateEntity(huashi);
huashiService.updateById(huashi);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于Vue的艺术家委托平台.js+SpringBoot+MySQL开发,高分成品毕业设计, (619个子文件)
update-password.vue.bak 3KB
main.js.bak 2KB
IndexMain.vue.bak 2KB
IndexAsideStatic.vue.bak 2KB
BreadCrumbs.vue.bak 2KB
IndexHeader.vue.bak 1KB
3-build.bat 15B
2-run.bat 14B
build.bat 14B
run.bat 14B
1-install.bat 12B
install.bat 12B
mvnw.cmd 6KB
app.0713d0e8.css 343KB
chunk-vendors.957ca5cd.css 242KB
app.0939083e.css 125KB
chunk-vendors.a72b0961.css 37KB
swiper.min.css 13KB
swiper.min.css 13KB
iconfont.css 599B
canvas-bg-1.css 379B
canvas-bg-1.css 379B
canvas-bg-2.css 79B
canvas-bg-2.css 79B
canvas-bg-4.css 57B
canvas-bg-5.css 57B
canvas-bg-3.css 57B
canvas-bg-3.css 57B
springboot5wy19数据库文档.doc 1.22MB
1677213171878.doc 91KB
.gitignore 333B
index.html 1KB
index.html 968B
index.html 792B
index.html 602B
favicon.ico 4KB
favicon.ico 4KB
favicon.ico 4KB
favicon.ico 4KB
maven-wrapper.jar 50KB
HuashiController.java 10KB
HuashizuopinController.java 9KB
YonghuController.java 8KB
CommonController.java 7KB
BaiduUtil.java 7KB
GaojianzuopinController.java 7KB
YuegaoxinxiController.java 7KB
DiscusshuashizuopinController.java 7KB
StoreupController.java 7KB
DiscusshuashiController.java 7KB
ZuopinleixingController.java 7KB
SystemintroController.java 6KB
AboutusController.java 6KB
NewsController.java 6KB
GaojianzuopinEntity.java 5KB
HuashiEntity.java 5KB
UsersController.java 5KB
MPUtil.java 5KB
YuegaoxinxiEntity.java 5KB
MavenWrapperDownloader.java 5KB
HuashizuopinEntity.java 5KB
FileController.java 4KB
CommonUtil.java 4KB
GaojianzuopinModel.java 4KB
HuashiModel.java 4KB
GaojianzuopinVO.java 4KB
HuashiVO.java 4KB
YuegaoxinxiModel.java 4KB
YuegaoxinxiVO.java 4KB
HuashizuopinModel.java 4KB
StoreupEntity.java 4KB
HuashizuopinVO.java 3KB
AuthorizationInterceptor.java 3KB
DiscusshuashizuopinEntity.java 3KB
ConfigController.java 3KB
YonghuEntity.java 3KB
DiscusshuashiEntity.java 3KB
SystemintroEntity.java 3KB
AboutusEntity.java 3KB
NewsEntity.java 3KB
Query.java 3KB
StoreupModel.java 2KB
StoreupVO.java 2KB
TokenServiceImpl.java 2KB
DiscusshuashizuopinServiceImpl.java 2KB
TokenEntity.java 2KB
ZuopinleixingEntity.java 2KB
DiscusshuashizuopinModel.java 2KB
DiscusshuashiServiceImpl.java 2KB
GaojianzuopinServiceImpl.java 2KB
ZuopinleixingServiceImpl.java 2KB
DiscusshuashiModel.java 2KB
SystemintroModel.java 2KB
AboutusModel.java 2KB
YonghuModel.java 2KB
HuashizuopinServiceImpl.java 2KB
YuegaoxinxiServiceImpl.java 2KB
SystemintroServiceImpl.java 2KB
PageUtils.java 2KB
DiscusshuashizuopinVO.java 2KB
共 619 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
普通网友
- 粉丝: 1127
- 资源: 5292
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功