|
|
|
@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
|
|
import com.tamguo.common.utils.DateUtils;
|
|
|
|
@ -29,21 +28,51 @@ import com.tamguo.config.redis.CacheService;
|
|
|
|
|
import com.tamguo.modules.member.service.IMemberService;
|
|
|
|
|
import com.tamguo.utils.ShiroUtils;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* AccountController 类,处理账户相关的请求
|
|
|
|
|
*/
|
|
|
|
|
@Controller
|
|
|
|
|
public class AccountController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 文件存储路径配置项
|
|
|
|
|
*/
|
|
|
|
|
@Value("${file.storage.path}")
|
|
|
|
|
String fileStoragePath;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 域名配置项
|
|
|
|
|
*/
|
|
|
|
|
@Value("${tamguo.domain.name}")
|
|
|
|
|
String tamguoDomainName;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 注入会员服务
|
|
|
|
|
*/
|
|
|
|
|
@Autowired
|
|
|
|
|
IMemberService iMemberService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 注入缓存服务
|
|
|
|
|
*/
|
|
|
|
|
@Autowired
|
|
|
|
|
CacheService cacheService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 头像编号无格式字符串
|
|
|
|
|
*/
|
|
|
|
|
private static final String AVATOR_NO_FORMAT = "00000";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 头像前缀
|
|
|
|
|
*/
|
|
|
|
|
private static final String AVATOR_PREFIX = "MTX";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理 "account.html" 请求,返回账户页面视图和会员信息
|
|
|
|
|
* @param model 模型视图对象
|
|
|
|
|
* @return 模型视图对象
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value = {"account.html"}, method = RequestMethod.GET)
|
|
|
|
|
public ModelAndView list(ModelAndView model) {
|
|
|
|
|
model.setViewName("account");
|
|
|
|
@ -51,15 +80,26 @@ public class AccountController {
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取当前会员信息的请求处理
|
|
|
|
|
* @return 结果对象,包含会员信息和状态信息
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value = {"getCurrentMember"}, method = RequestMethod.GET)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Result getCurrentMember() {
|
|
|
|
|
return Result.result(0, iMemberService.findByUid(ShiroUtils.getMemberId()), "success");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理文件上传请求
|
|
|
|
|
* @param file 上传的文件
|
|
|
|
|
* @param request HTTP 请求对象
|
|
|
|
|
* @return 文件上传消息对象
|
|
|
|
|
* @throws IOException 文件操作异常
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value = "uploadFile", method = RequestMethod.POST)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public UploaderMessage uploadFileHandler(@RequestParam("file") MultipartFile file,HttpServletRequest request) throws IOException {
|
|
|
|
|
public UploaderMessage uploadFileHandler(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws IOException {
|
|
|
|
|
|
|
|
|
|
if (!file.isEmpty()) {
|
|
|
|
|
InputStream in = null;
|
|
|
|
@ -93,12 +133,12 @@ public class AccountController {
|
|
|
|
|
msg.setError("File upload file");
|
|
|
|
|
return msg;
|
|
|
|
|
} finally {
|
|
|
|
|
if (out != null) {
|
|
|
|
|
if (out!= null) {
|
|
|
|
|
out.close();
|
|
|
|
|
out = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (in != null) {
|
|
|
|
|
if (in!= null) {
|
|
|
|
|
in.close();
|
|
|
|
|
in = null;
|
|
|
|
|
}
|
|
|
|
@ -111,6 +151,10 @@ public class AccountController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取头像编号的方法
|
|
|
|
|
* @return 头像编号
|
|
|
|
|
*/
|
|
|
|
|
private String getAvatorNo() {
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
|
|
|
|
|
String format = sdf.format(new Date());
|
|
|
|
|