feat: 一些调整
This commit is contained in:
parent
15850ea094
commit
425e1d810f
|
|
@ -3,6 +3,8 @@ package com.nflg.mobilebroken.admin.controller;
|
|||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.nflg.mobilebroken.admin.annotation.ApiMark;
|
||||
import com.nflg.mobilebroken.common.constant.AppUserApplyforType;
|
||||
import com.nflg.mobilebroken.common.constant.STATE;
|
||||
import com.nflg.mobilebroken.common.exception.NflgException;
|
||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||
import com.nflg.mobilebroken.common.pojo.request.*;
|
||||
|
|
@ -16,11 +18,13 @@ import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
|
|||
import com.nflg.mobilebroken.starter.service.EmailService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
|
@ -203,4 +207,25 @@ public class AppUserController extends ControllerBase {
|
|||
appUserService.enable(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送重置密码邮件
|
||||
* @param ids 用户id列表
|
||||
**/
|
||||
@Transactional
|
||||
@PostMapping("sendResetPasswordEmail")
|
||||
//@SaUserCheckRole("primary")
|
||||
public ApiResult<Void> sendResetPasswordEmail(@Valid @RequestBody @NotEmpty List<Integer> ids){
|
||||
try {
|
||||
for (Integer id : ids) {
|
||||
String password=RandomUtil.randomString(6);
|
||||
String email=appUserService.resetPassword(id,password);
|
||||
emailService.sendEmail(email, "密码重置",
|
||||
"随机码为:" + password + ",点击链接激活账号: " + activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString(email.getBytes()));
|
||||
}
|
||||
}catch (Exception ex){
|
||||
throw new NflgException(STATE.BusinessError,"发送邮件失败:"+ex.getMessage());
|
||||
}
|
||||
return ApiResult.success();
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ import com.nflg.mobilebroken.common.pojo.PageData;
|
|||
import com.nflg.mobilebroken.common.pojo.request.FileSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.FileVO;
|
||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.repository.entity.FileUploadRecord;
|
||||
import com.nflg.mobilebroken.repository.service.IFileUploadRecordService;
|
||||
import com.nflg.mobilebroken.starter.service.FileUploadService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -18,6 +19,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -47,9 +49,11 @@ public class FileController extends ControllerBase {
|
|||
*/
|
||||
@PostMapping("uploadSingleFile")
|
||||
@ApiMark(moduleName = "文件管理", apiName = "上传单个文件")
|
||||
public ApiResult<String> uploadSingleFile(@RequestParam("file") MultipartFile file) {
|
||||
public ApiResult<String> uploadSingleFile(@Valid @NotNull @RequestParam("file") MultipartFile file,@Valid @NotNull @RequestParam("ticketId") Integer ticketId) {
|
||||
try {
|
||||
return ApiResult.success(fileUploadService.upload(buildFilePath(file.getOriginalFilename()), file));
|
||||
String url=fileUploadService.upload(buildFilePath(file.getOriginalFilename()), file);
|
||||
fileUploadRecordService.save(buildFileUploadRecord(ticketId,file,url));
|
||||
return ApiResult.success(url);
|
||||
} catch (Exception ex) {
|
||||
throw new NflgException(STATE.BusinessError, "上传文件失败:" + ex.getMessage());
|
||||
}
|
||||
|
|
@ -67,21 +71,36 @@ public class FileController extends ControllerBase {
|
|||
*/
|
||||
@PostMapping("uploadMultipleFiles")
|
||||
@ApiMark(moduleName = "文件管理", apiName = "上传多个文件")
|
||||
public ApiResult<List<String>> uploadMultipleFiles(@Valid @RequestParam("files") @NotEmpty List<MultipartFile> files) {
|
||||
public ApiResult<List<String>> uploadMultipleFiles(@Valid @RequestParam("files") @NotEmpty List<MultipartFile> files,@Valid @NotNull @RequestParam("ticketId") Integer ticketId) {
|
||||
try {
|
||||
List<String> list = new ArrayList<>();
|
||||
List<FileUploadRecord> records = new ArrayList<>();
|
||||
for (MultipartFile f : files) {
|
||||
list.add(fileUploadService.upload(buildFilePath(f.getOriginalFilename()), f));
|
||||
String url=fileUploadService.upload(buildFilePath(f.getOriginalFilename()), f);
|
||||
list.add(url);
|
||||
records.add(buildFileUploadRecord(ticketId,f,url));
|
||||
}
|
||||
fileUploadRecordService.saveBatch(records);
|
||||
return ApiResult.success(list);
|
||||
} catch (Exception ex) {
|
||||
throw new NflgException(STATE.BusinessError, "上传文件失败:" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private FileUploadRecord buildFileUploadRecord(Integer ticketId, MultipartFile file, String url){
|
||||
return new FileUploadRecord()
|
||||
.setFileName(file.getOriginalFilename())
|
||||
.setFileType(file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")))
|
||||
.setFrom("admin")
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
.setSource((byte) 0)
|
||||
.setSourceId(ticketId)
|
||||
.setUrl(url)
|
||||
.setCreateBy(AdminUserUtil.getUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索文件
|
||||
*
|
||||
* @param request 搜索条件
|
||||
* @return 搜索到的文件列表
|
||||
*/
|
||||
|
|
@ -93,7 +112,6 @@ public class FileController extends ControllerBase {
|
|||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param ids 文件id列表
|
||||
*/
|
||||
@PostMapping("deleteFile")
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import com.nflg.mobilebroken.common.constant.STATE;
|
|||
import com.nflg.mobilebroken.common.exception.NflgException;
|
||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||
import com.nflg.mobilebroken.common.util.AppUserUtil;
|
||||
import com.nflg.mobilebroken.repository.entity.FileUploadRecord;
|
||||
import com.nflg.mobilebroken.repository.service.IFileUploadRecordService;
|
||||
import com.nflg.mobilebroken.starter.service.FileUploadService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
@ -16,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -33,6 +36,9 @@ public class FileController extends ControllerBase {
|
|||
@Resource
|
||||
private FileUploadService fileUploadService;
|
||||
|
||||
@Resource
|
||||
private IFileUploadRecordService fileUploadRecordService;
|
||||
|
||||
private static final DateTimeFormatter FORMATTER= DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
||||
/**
|
||||
|
|
@ -41,9 +47,11 @@ public class FileController extends ControllerBase {
|
|||
* @return 可访问的文件url
|
||||
*/
|
||||
@PostMapping("uploadSingleFile")
|
||||
public ApiResult<String> uploadSingleFile(@RequestParam("file") MultipartFile file) {
|
||||
public ApiResult<String> uploadSingleFile(@Valid @NotNull @RequestParam("file") MultipartFile file,@Valid @NotNull @RequestParam("ticketId") Integer ticketId) {
|
||||
try {
|
||||
return ApiResult.success(fileUploadService.upload(buildFilePath(file.getOriginalFilename()), file));
|
||||
String url=fileUploadService.upload(buildFilePath(file.getOriginalFilename()), file);
|
||||
fileUploadRecordService.save(buildFileUploadRecord(ticketId,file,url));
|
||||
return ApiResult.success(url);
|
||||
}catch (Exception ex){
|
||||
throw new NflgException(STATE.BusinessError,"上传文件失败:"+ex.getMessage());
|
||||
}
|
||||
|
|
@ -60,15 +68,31 @@ public class FileController extends ControllerBase {
|
|||
* @return 可访问的文件url列表
|
||||
*/
|
||||
@PostMapping("uploadMultipleFiles")
|
||||
public ApiResult<List<String>> uploadMultipleFiles(@Valid @RequestParam("files") @NotEmpty List<MultipartFile> files) {
|
||||
public ApiResult<List<String>> uploadMultipleFiles(@Valid @RequestParam("files") @NotEmpty List<MultipartFile> files,@Valid @NotNull @RequestParam("ticketId") Integer ticketId) {
|
||||
try {
|
||||
List<String> list = new ArrayList<>();
|
||||
List<FileUploadRecord> records = new ArrayList<>();
|
||||
for (MultipartFile f : files) {
|
||||
list.add(fileUploadService.upload(buildFilePath(f.getOriginalFilename()), f));
|
||||
String url=fileUploadService.upload(buildFilePath(f.getOriginalFilename()), f);
|
||||
list.add(url);
|
||||
records.add(buildFileUploadRecord(ticketId,f,url));
|
||||
}
|
||||
fileUploadRecordService.saveBatch(records);
|
||||
return ApiResult.success(list);
|
||||
} catch (Exception ex) {
|
||||
throw new NflgException(STATE.BusinessError, "上传文件失败:" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private FileUploadRecord buildFileUploadRecord(Integer ticketId,MultipartFile file,String url){
|
||||
return new FileUploadRecord()
|
||||
.setFileName(file.getOriginalFilename())
|
||||
.setFileType(file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")))
|
||||
.setFrom("app")
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
.setSource((byte) 0)
|
||||
.setSourceId(ticketId)
|
||||
.setUrl(url)
|
||||
.setCreateBy(AppUserUtil.getUserName());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ package com.nflg.mobilebroken.common.pojo.request;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Data
|
||||
public class PrimaryAppUserUpdateRequest extends PrimaryAppUserAddRequest {
|
||||
|
|
@ -12,6 +10,5 @@ public class PrimaryAppUserUpdateRequest extends PrimaryAppUserAddRequest {
|
|||
private Integer id;
|
||||
|
||||
//是否启用
|
||||
@NotNull
|
||||
private Boolean enable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class FileUploadRecord implements Serializable {
|
|||
/**
|
||||
* 关联id
|
||||
*/
|
||||
private String sourceId;
|
||||
private Integer sourceId;
|
||||
|
||||
/**
|
||||
* 访问地址
|
||||
|
|
|
|||
|
|
@ -199,8 +199,10 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
.setCompanyId(StrUtil.join(",", request.getCompanyIds()))
|
||||
.setIsPrimary(true)
|
||||
// .setUpdateBy(AdminUserUtil.getUserId())
|
||||
.setUpdateTime(LocalDateTime.now())
|
||||
.setState(request.getEnable() ? UserState.Activated.getState() : UserState.Disabled.getState());
|
||||
.setUpdateTime(LocalDateTime.now());
|
||||
if (Objects.nonNull(request.getEnable())){
|
||||
user.setState(request.getEnable() ? UserState.Activated.getState() : UserState.Disabled.getState());
|
||||
}
|
||||
updateById(user);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,9 @@ public class DictionaryItemServiceImpl extends ServiceImpl<DictionaryItemMapper,
|
|||
List<DictionaryItemTranslate> forAdd = new ArrayList<>();
|
||||
List<DictionaryItemTranslate> forUpdate = new ArrayList<>();
|
||||
for (TranslateMap translate : request.getLanguages()) {
|
||||
if(StrUtil.isBlank(translate.getValue())){
|
||||
continue;
|
||||
}
|
||||
DictionaryItemTranslate t = new DictionaryItemTranslate()
|
||||
.setDictionaryItemId(id)
|
||||
.setLanguageCode(translate.getCode())
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> impleme
|
|||
if (Objects.nonNull(request.getAreaId())) {
|
||||
request.setAreaIds(appAreaService.getAllhildrens(request.getAreaId()));
|
||||
}
|
||||
if (Objects.nonNull(request.getEndTime())){
|
||||
request.setEndTime(request.getEndTime().plusDays(1));
|
||||
}
|
||||
if (request.getType()==1){
|
||||
return baseMapper.searchMy(new Page<>(request.getPage(), request.getPageSize()), request, user.getId());
|
||||
}else if (request.getType()==2){
|
||||
|
|
|
|||
|
|
@ -129,11 +129,7 @@ public class WebComponentServiceImpl extends ServiceImpl<WebComponentMapper, Web
|
|||
WebComponent webComponent = getById(id);
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(webComponent)).throwMessage("未找到组件");
|
||||
List<WebComponentTranslate> translates = webComponentTranslateService.lambdaQuery().eq(WebComponentTranslate::getComponentId, id).list();
|
||||
List<Language> languages = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(translates)) {
|
||||
languages = languageService.listByIds(translates.stream().map(WebComponentTranslate::getLanguageId).collect(Collectors.toList()));
|
||||
}
|
||||
List<Language> finalLanguages = languages;
|
||||
List<Language> languages = languageService.getLanguages();
|
||||
return new WebComponentInfoVO()
|
||||
.setId(webComponent.getId())
|
||||
.setModuleName(webComponent.getModuleName())
|
||||
|
|
@ -142,10 +138,12 @@ public class WebComponentServiceImpl extends ServiceImpl<WebComponentMapper, Web
|
|||
.setPageCode(webComponent.getPageCode())
|
||||
.setComponetName(webComponent.getComponentName())
|
||||
.setComponetCode(webComponent.getComponentCode())
|
||||
.setTraslates(translates.stream().map(t -> new WebComponentTraslateVO()
|
||||
.setLanguageId(t.getLanguageId())
|
||||
.setLanguageName(finalLanguages.stream().filter(l -> l.getId().equals(t.getLanguageId())).findFirst().get().getName())
|
||||
.setValue(t.getValue())).collect(Collectors.toList()));
|
||||
.setTraslates(languages.stream().map(l->{
|
||||
return new WebComponentTraslateVO()
|
||||
.setLanguageId(l.getId())
|
||||
.setLanguageName(l.getName())
|
||||
.setValue(translates.stream().filter(t->Objects.equals(t.getLanguageId(),l.getId())).findFirst().orElse(new WebComponentTranslate().setValue("")).getValue());
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@
|
|||
LEFT JOIN app_user u ON t.user_id=u.id
|
||||
LEFT JOIN app_area a ON u.area_id=a.id
|
||||
LEFT JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.user_id=#{userId} AND tf.from=0
|
||||
WHERE t.user_id=#{userId}
|
||||
WHERE t.user_id=#{userId} AND t.state!=4
|
||||
<include refid="searchWhereCondition"/>
|
||||
ORDER BY t.create_time DESC
|
||||
</select>
|
||||
|
|
@ -88,7 +88,7 @@
|
|||
LEFT JOIN app_user u ON t.user_id=u.id
|
||||
LEFT JOIN app_area a ON u.area_id=a.id
|
||||
LEFT JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.from=0
|
||||
WHERE tf.user_id=#{userId}
|
||||
WHERE tf.user_id=#{userId} AND t.state!=4
|
||||
<include refid="searchWhereCondition"/>
|
||||
ORDER BY t.create_time DESC
|
||||
</select>
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
FROM ticket t
|
||||
LEFT JOIN app_user u ON t.user_id=u.id
|
||||
LEFT JOIN app_area a ON u.area_id=a.id
|
||||
WHERE u.company_id IN
|
||||
WHERE t.state!=4 AND u.company_id IN
|
||||
<foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
|
||||
#{companyId}
|
||||
</foreach>
|
||||
|
|
|
|||
Loading…
Reference in New Issue